author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 10 Jun 2013 17:32:35 +0100 | |
branch | jv |
changeset 18066 | 89d51443ba6f |
parent 18057 | 8da7c39a6322 |
parent 15354 | 21ebb380b376 |
child 18071 | 009cf668b0ed |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
252 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5556 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1 | 14 |
PositionableStream subclass:#WriteStream |
1295 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Streams' |
|
1 | 19 |
! |
20 |
||
1965 | 21 |
!WriteStream class methodsFor:'documentation'! |
1 | 22 |
|
88 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
252 | 26 |
All Rights Reserved |
88 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
68 | 37 |
documentation |
38 |
" |
|
2883 | 39 |
Streams for writing into. |
40 |
WriteStreams are especially useful, if big strings are to be constructed |
|
41 |
from pieces - create a writeStream, add the pieces (with #nextPut or |
|
42 |
#nextPutAll) and finally fetch the concatenated string via #contents. |
|
43 |
This is much better than constructing the big string by concatenating via |
|
44 |
the comma (,) operator, since less intermediate garbage objects are created. |
|
45 |
||
46 |
This implementation currently DOES change the |
|
261 | 47 |
identity if the streamed-upon collection IF it cannot grow easily. |
48 |
Collections which cannot grow easily are for example: Array, ByteArray and String. |
|
88 | 49 |
Thus it is slightly incompatible to ST-80 since 'aStream contents' does |
50 |
not always return the original collection. This may change. |
|
1295 | 51 |
|
52 |
[author:] |
|
10281 | 53 |
Claus Gittinger |
54 |
||
55 |
[see also:] |
|
56 |
CharacterWriteStream (if streaming for a unicode string) |
|
68 | 57 |
" |
2883 | 58 |
! |
59 |
||
60 |
examples |
|
61 |
" |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
62 |
[exBegin] |
2883 | 63 |
|s| |
64 |
||
65 |
s := WriteStream on:''. |
|
66 |
s nextPutAll:'hello'; |
|
67 |
space; |
|
68 |
nextPutAll:'world'. |
|
69 |
||
70 |
s contents inspect |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
71 |
[exEnd] |
2883 | 72 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
73 |
[exBegin] |
2883 | 74 |
|s| |
75 |
||
76 |
s := WriteStream on:''. |
|
77 |
s nextPutAll:'hello'; |
|
78 |
space; |
|
79 |
nextPutAll:'world'. |
|
80 |
||
81 |
Transcript nextPutLine:(s contents) |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
82 |
[exEnd] |
2883 | 83 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
84 |
[exBegin] |
2883 | 85 |
|s| |
86 |
||
87 |
s := '' writeStream. |
|
88 |
s nextPutAll:'hello'; |
|
89 |
space; |
|
90 |
nextPutAll:'world'. |
|
91 |
||
92 |
Transcript nextPutLine:(s contents) |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
93 |
[exEnd] |
2883 | 94 |
" |
95 |
||
345 | 96 |
! ! |
97 |
||
7261 | 98 |
!WriteStream methodsFor:'Compatibility-Dolphin'! |
6325 | 99 |
|
100 |
display:someObject |
|
6871
1c4a799a048c
display: use printOn instead of printString.
Claus Gittinger <cg@exept.de>
parents:
6326
diff
changeset
|
101 |
someObject printOn:self. |
6325 | 102 |
! ! |
103 |
||
1 | 104 |
!WriteStream methodsFor:'accessing'! |
105 |
||
15179 | 106 |
clear |
107 |
"for compatibility with Transcript" |
|
108 |
||
109 |
self reset |
|
110 |
! |
|
111 |
||
1 | 112 |
contents |
345 | 113 |
"return the current contents (a collection) of the stream. |
114 |
Currently, this returns the actual collection if possible |
|
115 |
(and reset is implemented to create a new one) in contrast to |
|
116 |
ST80, where contents returns a copy and reset only sets the writePointer. |
|
117 |
The ST/X behavior creates less temporary garbage in the normal case |
|
2410 | 118 |
(where things are written for the contents only) but may be incompatible |
345 | 119 |
with some applications. Time will show, if this is to be changed." |
1 | 120 |
|
260 | 121 |
|lastIndex| |
122 |
||
15347 | 123 |
lastIndex := position. |
260 | 124 |
collection size == lastIndex ifFalse:[ |
15347 | 125 |
collection isFixedSize ifTrue:[ |
126 |
" |
|
127 |
grow is expensive - return a copy. |
|
128 |
(is this what users of writeStream expect ?) |
|
129 |
" |
|
130 |
collection := collection copyFrom:1 to:lastIndex |
|
131 |
] ifFalse:[ |
|
132 |
collection grow:lastIndex |
|
133 |
] |
|
1 | 134 |
]. |
135 |
^ collection |
|
2410 | 136 |
|
3087 | 137 |
"Modified: / 19.2.1997 / 08:57:28 / stefan" |
138 |
"Modified: / 30.10.1997 / 16:21:23 / cg" |
|
1 | 139 |
! |
140 |
||
5888 | 141 |
last |
142 |
"return the last element - report an error if the stream is empty" |
|
143 |
||
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
144 |
|position1Based| |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
145 |
|
15347 | 146 |
position1Based := position + 1. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
147 |
^ collection at:(position1Based - 1). |
5888 | 148 |
|
149 |
" |
|
150 |
|s| |
|
151 |
||
152 |
s := '' writeStream. |
|
153 |
s nextPut:$a. |
|
154 |
s last. |
|
155 |
s nextPut:$b. |
|
156 |
s last. |
|
157 |
s nextPut:$c. |
|
158 |
s last. |
|
159 |
" |
|
160 |
! |
|
161 |
||
162 |
last:n |
|
163 |
"return the last n elements as species of the underlying collection; |
|
164 |
Report an error if the stream is empty" |
|
165 |
||
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
166 |
|position1Based| |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
167 |
|
15347 | 168 |
position1Based := position + 1. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
169 |
^ collection copyFrom:(position1Based - n) to:(position1Based - 1). |
5888 | 170 |
|
171 |
" |
|
172 |
|s| |
|
173 |
||
174 |
s := '' writeStream. |
|
175 |
s nextPut:$a. |
|
176 |
s last:1. |
|
177 |
s nextPut:$b. |
|
178 |
s last:1. |
|
179 |
s last:2. |
|
180 |
s nextPut:$c. |
|
181 |
s last:1. |
|
182 |
s last:2. |
|
183 |
s last:3. |
|
184 |
" |
|
185 |
! |
|
186 |
||
329 | 187 |
reset |
345 | 188 |
"reset the stream; write anew. |
2410 | 189 |
See the comment in WriteStream>>contents" |
329 | 190 |
|
191 |
collection := collection species new:(collection size). |
|
192 |
super reset |
|
2410 | 193 |
|
194 |
"Modified: 19.2.1997 / 08:57:00 / stefan" |
|
1 | 195 |
! ! |
196 |
||
611 | 197 |
!WriteStream methodsFor:'positioning'! |
198 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
199 |
position0Based:index0Based |
611 | 200 |
"redefined to allow positioning past the readLimit" |
201 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
202 |
((index0Based > collection size) or:[index0Based < 0]) ifTrue: [^ self positionError]. |
15347 | 203 |
position := index0Based |
611 | 204 |
! ! |
205 |
||
206 |
!WriteStream methodsFor:'private'! |
|
207 |
||
208 |
growCollection |
|
2863
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
209 |
"grow the streamed collection to at least 10 elements" |
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
210 |
|
611 | 211 |
self growCollection:10 |
2863
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
212 |
|
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
213 |
"Modified: 19.8.1997 / 17:53:28 / cg" |
611 | 214 |
! |
215 |
||
216 |
growCollection:minNewSize |
|
217 |
"grow the streamed collection to at least minNewSize" |
|
218 |
||
219 |
|oldSize newSize newColl| |
|
220 |
||
221 |
oldSize := collection size. |
|
222 |
(oldSize == 0) ifTrue:[ |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
223 |
newSize := minNewSize |
611 | 224 |
] ifFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
225 |
newSize := oldSize * 2. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
226 |
(newSize < minNewSize) ifTrue:[newSize := minNewSize]. |
611 | 227 |
]. |
228 |
collection isFixedSize ifTrue:[ |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
229 |
newColl := collection species new:newSize. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
230 |
newColl replaceFrom:1 to:oldSize with:collection startingAt:1. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
231 |
collection := newColl |
611 | 232 |
] ifFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
233 |
collection grow:newSize |
611 | 234 |
]. |
2863
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
235 |
|
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
236 |
"Modified: 19.8.1997 / 17:53:11 / cg" |
611 | 237 |
! ! |
238 |
||
7260 | 239 |
!WriteStream methodsFor:'private-accessing'! |
611 | 240 |
|
11794
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
241 |
on:aCollection |
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
242 |
super on:aCollection. |
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
243 |
readLimit := 0. |
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
244 |
! |
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
245 |
|
611 | 246 |
on:aCollection from:start to:last |
247 |
"create and return a new stream for writing onto aCollection, where |
|
248 |
writing is limited to the elements in the range start to last." |
|
249 |
||
250 |
super on:aCollection from:start to:last. |
|
251 |
writeLimit := last. |
|
252 |
! ! |
|
253 |
||
254 |
!WriteStream methodsFor:'queries'! |
|
255 |
||
3098
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
256 |
isReadable |
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
257 |
"return true if the receiver supports reading - thats not true" |
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
258 |
|
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
259 |
^ false |
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
260 |
|
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
261 |
"Created: / 8.11.1997 / 14:06:07 / cg" |
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
262 |
! |
4203b0d13fc8
added #isReadable (ST80 compat)
Claus Gittinger <cg@exept.de>
parents:
3087
diff
changeset
|
263 |
|
611 | 264 |
isWritable |
1405 | 265 |
"return true, if writing is supported by the recevier. |
266 |
Always return true here" |
|
267 |
||
611 | 268 |
^ true |
1405 | 269 |
|
270 |
"Modified: 16.5.1996 / 14:44:49 / cg" |
|
3031 | 271 |
! |
272 |
||
273 |
size |
|
274 |
"return the current size" |
|
275 |
||
15347 | 276 |
^ position |
611 | 277 |
! ! |
278 |
||
63 | 279 |
!WriteStream methodsFor:'reading'! |
1 | 280 |
|
281 |
next |
|
10 | 282 |
"catch read access to write stream - report an error" |
1 | 283 |
|
10 | 284 |
self shouldNotImplement |
1 | 285 |
! |
286 |
||
287 |
peek |
|
10 | 288 |
"catch read access to write stream - report an error" |
1 | 289 |
|
10 | 290 |
self shouldNotImplement |
63 | 291 |
! ! |
292 |
||
5556 | 293 |
!WriteStream methodsFor:'testing'! |
294 |
||
295 |
isEmpty |
|
296 |
"return true, if the contents of the stream is empty" |
|
297 |
||
15347 | 298 |
^ self position0Based == 0 |
5556 | 299 |
|
300 |
"Created: 14.10.1997 / 20:44:37 / cg" |
|
301 |
! ! |
|
302 |
||
611 | 303 |
!WriteStream methodsFor:'writing'! |
369 | 304 |
|
611 | 305 |
next:count put:anObject |
306 |
"append anObject count times to the receiver. |
|
307 |
Redefined to avoid count grows of the underlying collection - |
|
308 |
instead a single grow on the final size is performed." |
|
309 |
||
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
310 |
|final position1Based| |
611 | 311 |
|
312 |
(collection isNil or:[writeLimit notNil]) ifTrue:[ |
|
12131 | 313 |
super next:count put:anObject. |
314 |
^ self. |
|
611 | 315 |
]. |
369 | 316 |
|
15347 | 317 |
position1Based := position + 1. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
318 |
final := position1Based + count - 1. |
611 | 319 |
(final > collection size) ifTrue:[ |
7113 | 320 |
self growCollection:final |
611 | 321 |
]. |
369 | 322 |
|
7113 | 323 |
position1Based to:final do:[:index | |
324 |
collection at:index put:anObject. |
|
611 | 325 |
]. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
326 |
position1Based := position1Based + count. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
327 |
(position1Based > readLimit) ifTrue:[readLimit := position1Based - 1]. |
15347 | 328 |
position := position1Based - 1. |
12131 | 329 |
"/ ^ anObject -- return self |
611 | 330 |
! |
1 | 331 |
|
5198
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
332 |
next:n putAll:aCollection startingAt:pos1 |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
333 |
"append some elements of the argument, aCollection to the stream." |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
334 |
|
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
335 |
^ self nextPutAll:aCollection startingAt:pos1 to:pos1+n-1 |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
336 |
|
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
337 |
" |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
338 |
|s| |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
339 |
|
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
340 |
s := '' writeStream. |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
341 |
s nextPutAll:'hello '. |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
342 |
s next:5 putAll:'1234world012345' startingAt:5. |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
343 |
s contents |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
344 |
" |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
345 |
|
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
346 |
"Modified: 12.7.1996 / 10:31:36 / cg" |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
347 |
! |
ca2c2f7ec69c
added #next:putAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
4406
diff
changeset
|
348 |
|
1 | 349 |
nextPut:anObject |
1584 | 350 |
"append the argument, anObject to the stream. |
2863
aec08a0c2c2e
no need for unsigned compare against 0
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
351 |
Specially tuned for appending to String, ByteArray and Array streams." |
1 | 352 |
|
63 | 353 |
%{ /* NOCONTEXT */ |
354 |
||
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
355 |
#ifndef NO_PRIM_STREAM |
63 | 356 |
REGISTER int pos; |
357 |
unsigned ch; |
|
358 |
OBJ coll; |
|
2883 | 359 |
OBJ p, wL, rL; |
1584 | 360 |
int __readLimit = -1; |
63 | 361 |
|
1136 | 362 |
coll = __INST(collection); |
363 |
p = __INST(position); |
|
63 | 364 |
|
293 | 365 |
if (__isNonNilObject(coll) && __isSmallInteger(p)) { |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
366 |
pos = __intVal(p); |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
367 |
/* make 1-based */ |
15347 | 368 |
pos = pos + 1; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
369 |
wL = __INST(writeLimit); |
63 | 370 |
|
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
371 |
if ((wL == nil) |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
372 |
|| (__isSmallInteger(wL) && (pos <= __intVal(wL)))) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
373 |
OBJ cls; |
252 | 374 |
|
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
375 |
cls = __qClass(coll); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
376 |
|
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
377 |
rL = __INST(readLimit); |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
378 |
if (__isSmallInteger(rL)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
379 |
__readLimit = __intVal(rL); |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
380 |
} |
293 | 381 |
|
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
382 |
if (cls == @global(String)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
383 |
if (__isCharacter(anObject) |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
384 |
&& ((ch = __intVal(__characterVal(anObject))) <= 255) /* ch is unsigned */ |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
385 |
&& (pos <= __stringSize(coll))) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
386 |
__StringInstPtr(coll)->s_element[pos-1] = ch; |
8615 | 387 |
advancePositionAndReturn: ; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
388 |
if ((__readLimit >= 0) && (pos >= __readLimit)) { |
8913 | 389 |
__INST(readLimit) = __mkSmallInteger(pos); |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
390 |
} |
8913 | 391 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
392 |
RETURN ( anObject ); |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
393 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
394 |
} else if (cls == @global(ByteArray)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
395 |
if (__isSmallInteger(anObject) |
8296 | 396 |
&& ((ch = __intVal(anObject)) <= 0xFF) /* ch is unsigned */ |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
397 |
&& (pos <= __byteArraySize(coll))) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
398 |
__ByteArrayInstPtr(coll)->ba_element[pos-1] = ch; |
8615 | 399 |
goto advancePositionAndReturn; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
400 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
401 |
} else if (cls == @global(Array)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
402 |
if (pos <= __arraySize(coll)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
403 |
__ArrayInstPtr(coll)->a_element[pos-1] = anObject; |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
404 |
__STORE(coll, anObject); |
8615 | 405 |
goto advancePositionAndReturn; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
406 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
407 |
} else if (cls == @global(Unicode16String)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
408 |
if (__isCharacter(anObject) |
8296 | 409 |
&& ((ch = __intVal(__characterVal(anObject))) <= 0xFFFF) /* ch is unsigned */ |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
410 |
&& (pos <= __unicode16StringSize(coll))) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
411 |
__Unicode16StringInstPtr(coll)->s_element[pos-1] = ch; |
8615 | 412 |
goto advancePositionAndReturn; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
413 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
414 |
} else if (cls == @global(Unicode32String)) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
415 |
if (__isCharacter(anObject) |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
416 |
&& (pos <= __unicode32StringSize(coll))) { |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
417 |
__Unicode32StringInstPtr(coll)->s_element[pos-1] = __intVal(__characterVal(anObject)); |
8615 | 418 |
goto advancePositionAndReturn; |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
419 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
420 |
} |
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
421 |
} |
63 | 422 |
} |
2894 | 423 |
#endif |
260 | 424 |
%}. |
293 | 425 |
(writeLimit isNil |
15347 | 426 |
or:[(position + 1) <= writeLimit]) ifTrue:[ |
15354 | 427 |
(position >= collection size) ifTrue:[self growCollection]. |
15347 | 428 |
collection at:(position + 1) put:anObject. |
15354 | 429 |
(position >= readLimit) ifTrue:[readLimit := (position + 1)]. |
8293
dcffeb2c11e0
Optimize #nextPut: on UnicodeStrings
Stefan Vogel <sv@exept.de>
parents:
7686
diff
changeset
|
430 |
position := position + 1. |
838 | 431 |
] ifFalse:[ |
8320
229adaeaf183
Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents:
8296
diff
changeset
|
432 |
WriteError raiseErrorString:'write beyond writeLimit' |
293 | 433 |
]. |
1 | 434 |
^anObject |
435 |
! |
|
436 |
||
437 |
nextPutAll:aCollection |
|
63 | 438 |
"append all elements of the argument, aCollection to the stream. |
439 |
Redefined to avoid count grows of the underlying collection - |
|
440 |
instead a single grow on the final size is performed." |
|
1 | 441 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
442 |
|nMore final position1Based| |
1 | 443 |
|
77 | 444 |
collection isNil ifTrue:[ |
12130 | 445 |
super nextPutAll:aCollection. |
446 |
^ self |
|
77 | 447 |
]. |
13628 | 448 |
aCollection isSequenceable ifFalse:[ |
449 |
super nextPutAll:aCollection. |
|
450 |
^ self. |
|
451 |
]. |
|
77 | 452 |
|
15347 | 453 |
position1Based := position + 1. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
454 |
|
1 | 455 |
nMore := aCollection size. |
9499 | 456 |
nMore == 0 ifTrue:[ |
457 |
"/ for the programmer.. |
|
458 |
aCollection isCollection ifFalse:[ |
|
10070 | 459 |
self error:'invalid argument (not a collection)' mayProceed:true |
9499 | 460 |
]. |
461 |
]. |
|
462 |
||
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
463 |
final := position1Based + nMore - 1. |
293 | 464 |
(writeLimit notNil |
465 |
and:[final > writeLimit]) ifTrue:[ |
|
7686
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
466 |
final := writeLimit. |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
467 |
nMore := final - position1Based + 1 |
293 | 468 |
]. |
1 | 469 |
(final > collection size) ifTrue:[ |
7686
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
470 |
self growCollection:final |
1 | 471 |
]. |
7686
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
472 |
collection |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
473 |
replaceFrom:position1Based |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
474 |
to:final |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
475 |
with:aCollection |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7620
diff
changeset
|
476 |
startingAt:1. |
1 | 477 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
478 |
position1Based := position1Based + nMore. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
479 |
(position1Based > readLimit) ifTrue:[readLimit := position1Based - 1]. |
15347 | 480 |
position := position1Based - 1. |
12130 | 481 |
"/ ^ aCollection -- self |
13628 | 482 |
|
483 |
"Modified: / 04-09-2011 / 20:03:32 / cg" |
|
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
484 |
! |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
485 |
|
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
486 |
nextPutAll:aCollection startingAt:pos1 to:pos2 |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
487 |
"append some elements of the argument, aCollection to the stream. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
488 |
Redefined to avoid count grows of the underlying collection - |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
489 |
instead a single grow on the final size is performed." |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
490 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
491 |
|nMore final position1Based| |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
492 |
|
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
493 |
collection isNil ifTrue:[ |
12131 | 494 |
^ super nextPutAll:aCollection startingAt:pos1 to:pos2 |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
495 |
]. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
496 |
|
15347 | 497 |
position1Based := position + 1. |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
498 |
nMore := pos2 - pos1 + 1. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
499 |
final := position1Based + nMore - 1. |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
500 |
(writeLimit notNil |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
501 |
and:[final > writeLimit]) ifTrue:[ |
12131 | 502 |
final := writeLimit. |
503 |
nMore := final - position1Based + 1 |
|
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
504 |
]. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
505 |
(final > collection size) ifTrue:[ |
12131 | 506 |
self growCollection:final |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
507 |
]. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
508 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
509 |
collection replaceFrom:position1Based |
12131 | 510 |
to:final |
511 |
with:aCollection |
|
512 |
startingAt:pos1. |
|
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
513 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
514 |
position1Based := position1Based + nMore. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6871
diff
changeset
|
515 |
(position1Based > readLimit) ifTrue:[readLimit := position1Based - 1]. |
15347 | 516 |
position := position1Based - 1. |
12131 | 517 |
"/ ^ aCollection -- return self |
1539
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
518 |
|
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
519 |
" |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
520 |
|s| |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
521 |
|
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
522 |
s := '' writeStream. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
523 |
s nextPutAll:'hello '. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
524 |
s nextPutAll:'1234world012345' startingAt:5 to:9. |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
525 |
s contents |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
526 |
" |
b1ac096a81e3
added #nextPutAll:startingAt:to:
Claus Gittinger <cg@exept.de>
parents:
1405
diff
changeset
|
527 |
|
1541 | 528 |
"Modified: 12.7.1996 / 10:31:36 / cg" |
8361 | 529 |
! |
530 |
||
11324 | 531 |
nextPutAllUnicode:aString |
532 |
"normal streams can not handle multi-byte characters, so convert them to utf8" |
|
533 |
||
14562 | 534 |
(collection isString and:[collection isWideString not]) ifTrue:[ |
11324 | 535 |
aString do:[:eachCharacter| |
536 |
self nextPutUtf8:eachCharacter. |
|
537 |
]. |
|
538 |
] ifFalse:[ |
|
539 |
self nextPutAll:aString |
|
540 |
]. |
|
13738
e11fccebb0c3
changed: #nextPutAllUnicode:
Claus Gittinger <cg@exept.de>
parents:
13628
diff
changeset
|
541 |
|
e11fccebb0c3
changed: #nextPutAllUnicode:
Claus Gittinger <cg@exept.de>
parents:
13628
diff
changeset
|
542 |
"Modified: / 28-09-2011 / 16:15:52 / cg" |
11324 | 543 |
! |
544 |
||
8615 | 545 |
nextPutByte:anObject |
546 |
"append the argument, anObject to the stream. |
|
547 |
Specially tuned for appending to String and ByteArray streams." |
|
548 |
||
549 |
%{ /* NOCONTEXT */ |
|
550 |
||
551 |
#ifndef NO_PRIM_STREAM |
|
552 |
REGISTER int pos; |
|
553 |
OBJ coll; |
|
554 |
OBJ p, wL, rL; |
|
555 |
int __readLimit = -1; |
|
556 |
||
557 |
coll = __INST(collection); |
|
558 |
p = __INST(position); |
|
559 |
||
560 |
if (__isNonNilObject(coll) && __isSmallInteger(p) && __isSmallInteger(anObject)) { |
|
561 |
unsigned ch; |
|
562 |
||
563 |
ch = __intVal(anObject); |
|
564 |
||
565 |
pos = __intVal(p); |
|
566 |
/* make 1-based */ |
|
567 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
|
568 |
wL = __INST(writeLimit); |
|
569 |
||
570 |
if ((wL == nil) |
|
571 |
|| (__isSmallInteger(wL) && (pos <= __intVal(wL)))) { |
|
572 |
OBJ cls; |
|
573 |
||
574 |
cls = __qClass(coll); |
|
575 |
||
576 |
rL = __INST(readLimit); |
|
577 |
if (__isSmallInteger(rL)) { |
|
578 |
__readLimit = __intVal(rL); |
|
579 |
} |
|
580 |
||
581 |
if (cls == @global(String)) { |
|
582 |
if ((pos <= __stringSize(coll)) |
|
583 |
&& (ch <= 0xFF)) { /* ch is unsigned */ |
|
584 |
__StringInstPtr(coll)->s_element[pos-1] = ch; |
|
585 |
advancePositionAndReturn: ; |
|
586 |
if ((__readLimit >= 0) && (pos >= __readLimit)) { |
|
8913 | 587 |
__INST(readLimit) = __mkSmallInteger(pos); |
8615 | 588 |
} |
8913 | 589 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8615 | 590 |
RETURN ( anObject ); |
591 |
} |
|
592 |
} else if (cls == @global(ByteArray)) { |
|
593 |
if ((pos <= __byteArraySize(coll)) |
|
594 |
&& (ch <= 0xFF)) { /* ch is unsigned */ |
|
595 |
__ByteArrayInstPtr(coll)->ba_element[pos-1] = ch; |
|
596 |
goto advancePositionAndReturn; |
|
597 |
} |
|
598 |
} |
|
599 |
} |
|
600 |
} |
|
601 |
#endif |
|
602 |
%}. |
|
603 |
^ super nextPutByte:anObject |
|
604 |
! |
|
605 |
||
8361 | 606 |
nextPutBytes:count from:anObject startingAt:start |
607 |
"write count bytes from an object starting at index start. |
|
608 |
Return the number of bytes written. |
|
609 |
The object must have non-pointer indexed instvars |
|
610 |
(i.e. be a ByteArray, String, Float- or DoubleArray). |
|
611 |
Use with care - non object oriented i/o. |
|
612 |
This is provided for compatibility with externalStream; |
|
613 |
to support binary storage" |
|
614 |
||
11794
ad5fcc151a09
#on: - set readLimit to 0, so that setToEnd positions to end of written
Stefan Vogel <sv@exept.de>
parents:
11324
diff
changeset
|
615 |
anObject isByteCollection ifTrue:[ |
8361 | 616 |
self nextPutAll:anObject startingAt:start to:(start + count - 1). |
617 |
^ count. |
|
618 |
]. |
|
619 |
^ super nextPutBytes:count from:anObject startingAt:start |
|
11324 | 620 |
! |
621 |
||
622 |
nextPutUnicode:aCharacter |
|
623 |
"normal streams can not handle multi-byte characters, so convert them to utf8" |
|
624 |
||
14562 | 625 |
(collection isString and:[collection isWideString not]) ifTrue:[ |
11324 | 626 |
self nextPutUtf8:aCharacter. |
627 |
] ifFalse:[ |
|
628 |
self nextPut:aCharacter. |
|
629 |
]. |
|
1 | 630 |
! ! |
631 |
||
1965 | 632 |
!WriteStream class methodsFor:'documentation'! |
701 | 633 |
|
634 |
version |
|
15354 | 635 |
^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.78 2013-06-03 18:39:07 cg Exp $' |
12130 | 636 |
! |
637 |
||
638 |
version_CVS |
|
15354 | 639 |
^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.78 2013-06-03 18:39:07 cg Exp $' |
701 | 640 |
! ! |
14935 | 641 |