FourByteString.st
author Claus Gittinger <cg@exept.de>
Mon, 18 Mar 2019 11:03:24 +0100
changeset 4881 bdff8a3ce9d6
parent 4512 0d6157b7ce6e
child 4920 8c94a1a0ed25
permissions -rw-r--r--
#DOCUMENTATION by cg class: URI added: #readStreamDo: comment/format in: #readStreamsDo:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1415
3ef6a2c42611 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 1404
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
3533
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    14
"{ NameSpace: Smalltalk }"
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    15
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
CharacterArray variableLongSubclass:#FourByteString
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Collections-Text'
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!FourByteString class methodsFor:'documentation'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2004 by eXept Software AG
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    FourByteStrings are like strings, but storing 32bits per character.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    The integration of them into the system is not completed ....
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    [author:]
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
        Claus Gittinger
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    [see also:]
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
        Text TwoByteString UnicodeEncodedString
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        StringCollection
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
!FourByteString class methodsFor:'initialization'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
initialize
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    "initialize the class - private"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    self flags:(Behavior flagLongs)
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    "
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
     FourByteString initialize
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    "
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "Modified: 22.4.1996 / 16:14:14 / cg"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!FourByteString class methodsFor:'instance creation'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
basicNew:anInteger
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    "return a new empty string with anInteger characters"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    ^ (super basicNew:anInteger) atAllPut:(Character space)
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "Modified: 26.2.1996 / 14:38:47 / cg"
3533
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    75
!
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    76
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    77
uninitializedNew:anInteger
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    78
    "return a new empty string with anInteger characters"
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    79
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    80
    ^ super basicNew:anInteger
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    81
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    82
    "
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    83
        self uninitializedNew:10
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
    84
    "
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
!FourByteString methodsFor:'accessing'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
basicAt:index
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "return the character at position index, an Integer
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
     - reimplemented here since we return 32-bit characters"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    |val|
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    val := super basicAt:index.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ^ Character value:val
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
basicAt:index put:aCharacter
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "store the argument, aCharacter at position index, an Integer.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
     Returns aCharacter (sigh).
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
     - reimplemented here since we store 32-bit characters"
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    |val|
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
1415
3ef6a2c42611 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 1404
diff changeset
   106
    val := aCharacter codePoint.
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    super basicAt:index put:val.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    ^ aCharacter
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
!FourByteString methodsFor:'queries'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
bitsPerCharacter
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    "return the number of bits each character has.
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
     Here, 32 is returned (storing quad byte characters)."
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    ^ 32
2865
6f8b04862cc9 class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 1415
diff changeset
   118
!
6f8b04862cc9 class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 1415
diff changeset
   119
3826
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   120
bytesPerCharacter
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   121
    "return the number of bytes each character has.
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   122
     Here, 4 is returned (storing quad byte characters)."
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   123
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   124
    ^ 4
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   125
!
63c5834d27c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   126
2865
6f8b04862cc9 class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 1415
diff changeset
   127
isWideString
3805
9cb0780df5fc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3586
diff changeset
   128
    "true if I require more than one byte per character"
9cb0780df5fc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3586
diff changeset
   129
2865
6f8b04862cc9 class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 1415
diff changeset
   130
    ^ true
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
4511
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   133
!FourByteString methodsFor:'testing'!
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   134
4512
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   135
isSingleByteCollection
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   136
    "return true, if the receiver has access methods for bytes;
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   137
     i.e. #at: and #at:put: accesses a byte and are equivalent to #byteAt: and byteAt:put:
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   138
     and #replaceFrom:to: is equivalent to #replaceBytesFrom:to:. 
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   139
     false is returned here since at: returns 4-byte characters and not bytes 
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   140
      - the method is redefined from UninterpretedBytes."
0d6157b7ce6e #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4511
diff changeset
   141
4511
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   142
    ^ false
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   143
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   144
    "Created: / 30-08-2017 / 23:31:02 / cg"
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   145
! !
d7c52631ad33 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 3840
diff changeset
   146
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
!FourByteString class methodsFor:'documentation'!
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
version
3586
a6d20359cdf4 class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 3533
diff changeset
   150
    ^ '$Header$'
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
! !
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
3533
1465b5fed73e class: FourByteString
Stefan Vogel <sv@exept.de>
parents: 2865
diff changeset
   153
1404
776eb9467dc3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
FourByteString initialize!