author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 2015 14:42:18 +0200 | |
changeset 18452 | 5724547da8de |
parent 18394 | 80d135c6aecb |
child 18397 | 20527009f352 |
child 18478 | 245b268192d5 |
permissions | -rw-r--r-- |
17610 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
216 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5392
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
15 |
|
17330 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
1 | 18 |
Object subclass:#Stream |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
19 |
instanceVariableNames:'signalAtEnd' |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
20 |
classVariableNames:'StreamErrorSignal PositionErrorSignal ReadErrorSignal |
5392
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
21 |
WriteErrorSignal EndOfStreamSignal LineTooLongErrorSignal |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
22 |
ChunkSeparator' |
743 | 23 |
poolDictionaries:'' |
24 |
category:'Streams' |
|
1 | 25 |
! |
26 |
||
1949 | 27 |
!Stream class methodsFor:'documentation'! |
88 | 28 |
|
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
216 | 32 |
All Rights Reserved |
88 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
An abstract class defining common behavior for all stream-like objects. |
|
46 |
See concrete subclasses for more detail. |
|
345 | 47 |
|
1404 | 48 |
The protocol as implemented here is often only provided as a fallBack |
49 |
for very uncommon cases. Much of it is redefined for performance. |
|
50 |
(In streams which know more about their internal representation ...) |
|
51 |
||
52 |
||
345 | 53 |
Subclasses should (at least) implement: |
17555 | 54 |
#next (if readable) |
55 |
#nextPut: (if writable) |
|
56 |
#contents |
|
57 |
#atEnd |
|
58 |
#isReadable |
|
59 |
#isWritable |
|
1295 | 60 |
|
1404 | 61 |
Peekable & Positionable streams should (at least) implement: |
17555 | 62 |
#peek |
63 |
#position |
|
64 |
#position: |
|
1404 | 65 |
|
66 |
||
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
67 |
[instance variables:] |
17555 | 68 |
signalAtEnd <nil | Boolean> controls behavior when a read |
69 |
is attempted past the end-of-stream |
|
70 |
if true, the endOfStreamSignal is raised. |
|
71 |
if false, nil is returned. |
|
72 |
if nil (the default), the signal |
|
73 |
is raised, but if there is no handler, |
|
74 |
nil is returned. |
|
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
75 |
|
8309 | 76 |
[Class variables / Exceptions:] |
17555 | 77 |
StreamError <Exception> parent of all stream errors |
78 |
||
79 |
PositionError <Exception> position attemted on a stream |
|
80 |
which does not support positioning, |
|
81 |
or if the position is invalid. |
|
82 |
||
83 |
ReadError <Exception> raised on read errors |
|
84 |
||
85 |
WriteError <Exception> raised on write errors |
|
86 |
||
87 |
EndOfStreamSignal <Signal> raised at end of stream if signalAtEnd |
|
88 |
is enabled. |
|
89 |
||
90 |
[caveat:] |
|
91 |
The Stream hierarchy has a few little quirks in it, which are a consequence of some early historic |
|
92 |
decisions. The biggest problem is the distinction between readable and writeable streams based on inheritance, |
|
17561 | 93 |
instead of by either using state (i.e. a flag) or delegation. |
17555 | 94 |
The problem is that there are streams which can be both, and maybe even dynamically change their opinion, |
95 |
on whether being readable/writable. |
|
96 |
(For example, a buffer may be write-only while filled, but become readonly, when given to a consumer.) |
|
97 |
||
98 |
The above decision to base this on inheritance lead to the ugly ReadStream - WriteStream - ReadWriteStream |
|
17561 | 99 |
hierarchy, with some subclasses undoing the blocking of their superclass. |
100 |
||
101 |
Classes named 'ReadStream', 'WriteStream', 'ReadWriteStream', 'PeekableStream' and 'PositionableStream' should |
|
102 |
all be eliminated in favour of a few flags in the 'Stream' superclass. |
|
17556 | 103 |
|
17555 | 104 |
It is really time for a new stream hierarchy (XStreams, for example). |
105 |
(On the other hand: there is so much code around, which depends on the current situation, that such a change |
|
106 |
must really be thought through - most got used to these issues and live with it more or less happily) |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
107 |
|
1295 | 108 |
[author:] |
17555 | 109 |
Claus Gittinger |
88 | 110 |
" |
111 |
! ! |
|
1 | 112 |
|
1949 | 113 |
!Stream class methodsFor:'initialization'! |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
114 |
|
5991 | 115 |
initSignals |
116 |
StreamErrorSignal := StreamError. |
|
117 |
StreamErrorSignal notifierString:'Stream error'. |
|
118 |
||
8071 | 119 |
PositionErrorSignal := PositionError. |
6314 | 120 |
PositionErrorSignal notifierString:'stream has no concept of a position'. |
5991 | 121 |
|
8071 | 122 |
ReadErrorSignal := ReadError. |
5991 | 123 |
ReadErrorSignal notifierString:'read error'. |
124 |
||
8071 | 125 |
WriteErrorSignal := WriteError. |
5991 | 126 |
WriteErrorSignal notifierString:'write error'. |
127 |
||
128 |
LineTooLongErrorSignal := QuerySignal new. |
|
8515 | 129 |
LineTooLongErrorSignal parent:StreamError. |
5991 | 130 |
LineTooLongErrorSignal nameClass:self message:#lineTooLongErrorSignal. |
131 |
LineTooLongErrorSignal notifierString:'line too long'. |
|
132 |
||
8515 | 133 |
EndOfStreamSignal := EndOfStreamNotification. |
5991 | 134 |
EndOfStreamSignal notifierString:'end of stream'. |
135 |
||
136 |
"Created: / 7.9.2001 / 14:15:13 / cg" |
|
137 |
"Modified: / 7.9.2001 / 14:15:27 / cg" |
|
138 |
! |
|
139 |
||
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
140 |
initialize |
5392
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
141 |
ChunkSeparator := $!!. |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
142 |
|
8309 | 143 |
LineTooLongErrorSignal isNil ifTrue:[ |
6373
d6ffb0101dde
workaround bitShift-bitOr codeGenerator bug in stc
Claus Gittinger <cg@exept.de>
parents:
6360
diff
changeset
|
144 |
self initSignals |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
145 |
] |
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
146 |
|
3911 | 147 |
"Modified: / 1.11.1998 / 15:57:37 / stefan" |
5991 | 148 |
"Modified: / 7.9.2001 / 14:15:51 / cg" |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
149 |
! ! |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
150 |
|
1949 | 151 |
!Stream class methodsFor:'instance creation'! |
611 | 152 |
|
153 |
new |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1117
diff
changeset
|
154 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1117
diff
changeset
|
155 |
|
611 | 156 |
"report an error - Streams are created using on:-messages" |
157 |
||
4530
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4467
diff
changeset
|
158 |
self error:'Streams cannot be created with new' |
611 | 159 |
! ! |
160 |
||
1949 | 161 |
!Stream class methodsFor:'Signal constants'! |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
162 |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
163 |
endOfStreamSignal |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
164 |
"return the signal raised if read past end of stream is attemted" |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
165 |
|
8515 | 166 |
^ EndOfStreamNotification |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
167 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
168 |
|
6348 | 169 |
incompleteNextCountSignal |
170 |
"return the signal raised if not all requested elements are returned" |
|
171 |
||
172 |
^ IncompleteNextCountError |
|
173 |
! |
|
174 |
||
3877
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
175 |
lineTooLongErrorSignal |
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
176 |
"return the signal raised if a line is read which is too long (>32k)" |
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
177 |
|
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
178 |
^ LineTooLongErrorSignal |
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
179 |
|
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
180 |
"Created: / 15.10.1998 / 12:11:14 / cg" |
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
181 |
! |
16673e28625b
added LineTooLongErrorSignal
Claus Gittinger <cg@exept.de>
parents:
3593
diff
changeset
|
182 |
|
611 | 183 |
positionErrorSignal |
184 |
"return the signal raised if positioning is requested for |
|
185 |
a stream which does not support that kind of operation" |
|
186 |
||
8309 | 187 |
^ PositionError |
611 | 188 |
! |
189 |
||
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
190 |
readErrorSignal |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
191 |
"return the signal raised on read errors" |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
192 |
|
8309 | 193 |
^ ReadError |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
194 |
! |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
195 |
|
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
196 |
streamErrorSignal |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
197 |
"return the parent of all stream errors; |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
198 |
handling this one also handles all other errors. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
199 |
Also, this one may be raised for errors not related to read/write |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
200 |
operations, such as failed ioctls in externalStream etc." |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
201 |
|
8309 | 202 |
^ StreamError |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
203 |
! |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
204 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
205 |
writeErrorSignal |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
206 |
"return the signal raised on write errors" |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
207 |
|
8309 | 208 |
^ WriteError |
1 | 209 |
! ! |
210 |
||
5392
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
211 |
!Stream class methodsFor:'constants'! |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
212 |
|
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
213 |
chunkSeparator |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
214 |
"return the chunk-separation character" |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
215 |
|
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
216 |
^ ChunkSeparator |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
217 |
! ! |
deafa504029a
moved chunkSeparator from PositionableStream
Claus Gittinger <cg@exept.de>
parents:
5072
diff
changeset
|
218 |
|
17549 | 219 |
!Stream methodsFor:'Compatibility-Dolphin'! |
220 |
||
221 |
display:someObject |
|
222 |
"dolphin compatibility" |
|
223 |
||
224 |
"/ someObject printOn:self. |
|
225 |
self nextPutAll: someObject asString. |
|
226 |
! ! |
|
227 |
||
17673 | 228 |
|
1 | 229 |
!Stream methodsFor:'accessing'! |
230 |
||
231 |
contents |
|
11693 | 232 |
"return the entire contents of the stream. |
233 |
For a readStream, that is the rest (i.e. upToEnd), |
|
234 |
for a writeStream, that is the collected data. As we do not know here, |
|
235 |
what we are, this is the responsibility of a subclass..." |
|
236 |
||
237 |
^ self subclassResponsibility |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
238 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
239 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
240 |
signalAtEnd |
3105 | 241 |
"return the signalAtEnd flag setting. |
242 |
If true, reading past the end will always raise an EndOfStream exception. |
|
243 |
If false, no exception is raised and nil is returned from all reading messages. |
|
244 |
If nil (default), the exception is raised if there is a handler; otherwise, nil is returned. |
|
245 |
The default is nil (for ST80 compatibility) i.e. to only raise a signal if there is a handler." |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
246 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
247 |
^ signalAtEnd |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
248 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
249 |
"Created: 5.2.1996 / 18:24:53 / stefan" |
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
250 |
"Modified: 15.5.1996 / 17:35:55 / cg" |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
251 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
252 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
253 |
signalAtEnd:aBoolean |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
254 |
"set the signalAtEnd flag setting. If true, reading past the end |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
255 |
will raise an EndOfStream exception. If false, no exception is |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
256 |
raised and nil is returned from all reading messages. |
16791 | 257 |
The default is to raise a signal, but return nil if not handled (st80 compatibility)." |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
258 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
259 |
signalAtEnd := aBoolean. |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
260 |
|
3591 | 261 |
"default behavior: return nil if unhandled ... |
262 |
|s| |
|
263 |
||
264 |
s := '12' readStream. |
|
265 |
Transcript showCR:s next. |
|
266 |
Transcript showCR:s next. |
|
267 |
Transcript showCR:s next. |
|
268 |
Transcript showCR:s next. |
|
269 |
" |
|
270 |
||
271 |
"... raise error if handled. |
|
272 |
|s| |
|
273 |
||
274 |
s := '12' readStream. |
|
275 |
Stream endOfStreamSignal handle:[:ex | |
|
16791 | 276 |
Transcript showCR:'end reached'. |
277 |
ex return |
|
3591 | 278 |
] do:[ |
16791 | 279 |
Transcript showCR:s next. |
280 |
Transcript showCR:s next. |
|
281 |
Transcript showCR:s next. |
|
282 |
Transcript showCR:s next. |
|
3591 | 283 |
] |
284 |
" |
|
285 |
||
286 |
"force raise (useful for debugging): |
|
287 |
|s| |
|
288 |
||
289 |
s := '12' readStream. |
|
290 |
s signalAtEnd:true. |
|
291 |
Transcript showCR:s next. |
|
292 |
Transcript showCR:s next. |
|
293 |
Transcript showCR:s next. |
|
294 |
Transcript showCR:s next. |
|
295 |
" |
|
296 |
||
297 |
||
298 |
"force no-raise (useful for compatibility with other systems): |
|
299 |
|s| |
|
300 |
||
301 |
s := '12' readStream. |
|
302 |
s signalAtEnd:false. |
|
303 |
Stream endOfStreamSignal handle:[:ex | |
|
16791 | 304 |
Transcript showCR:'end reached'. |
305 |
ex return |
|
3591 | 306 |
] do:[ |
16791 | 307 |
Transcript showCR:s next. |
308 |
Transcript showCR:s next. |
|
309 |
Transcript showCR:s next. |
|
310 |
Transcript showCR:s next. |
|
3591 | 311 |
] |
312 |
" |
|
313 |
||
314 |
"Modified: / 16.6.1998 / 16:04:41 / cg" |
|
1 | 315 |
! ! |
316 |
||
8630 | 317 |
!Stream methodsFor:'converting'! |
318 |
||
16086 | 319 |
asLineNumberReadStream |
18393 | 320 |
"returns a new stream, which keeps track of the line number. |
321 |
It can be asked for the current linenumber, |
|
322 |
which is useful eg. for error message generation" |
|
323 |
||
16086 | 324 |
^ LineNumberReadStream on:self |
325 |
! |
|
326 |
||
8630 | 327 |
asStream |
328 |
^ self |
|
329 |
! ! |
|
330 |
||
1401 | 331 |
!Stream methodsFor:'emphasis'! |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
332 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
333 |
bold |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
334 |
"set emphasis to #bold. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
335 |
this allows Streams to be used interchangeable with printStreams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
336 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
337 |
self emphasis:#bold. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
338 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
339 |
"Created: 14.5.1996 / 17:37:37 / cg" |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
340 |
"Modified: 3.6.1996 / 16:57:17 / cg" |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
341 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
342 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
343 |
boldItalic |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
344 |
"set emphasis to #boldItalic |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
345 |
this allows Streams to be used interchangeable with printStreams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
346 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
347 |
self emphasis:#(bold italic). |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
348 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
349 |
"Created: 14.5.1996 / 17:37:47 / cg" |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
350 |
"Modified: 3.6.1996 / 17:15:22 / cg" |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
351 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
352 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
353 |
emphasis |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
354 |
"ignored here - allows Streams to be used interchangable with |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
355 |
text streams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
356 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
357 |
^ nil |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
358 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
359 |
"Created: 14.5.1996 / 17:39:45 / cg" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
360 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
361 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
362 |
emphasis:anEmphasis |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
363 |
"ignored here. |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
364 |
this allows Streams to be used interchangeable with printStreams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
365 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
366 |
^ self |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
367 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
368 |
"Created: 14.5.1996 / 17:38:07 / cg" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
369 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
370 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
371 |
italic |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
372 |
"set emphasis to #italic. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
373 |
this allows Streams to be used interchangeable with printStreams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
374 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
375 |
self emphasis:#italic. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
376 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
377 |
"Created: 14.5.1996 / 17:37:55 / cg" |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
378 |
"Modified: 3.6.1996 / 17:15:32 / cg" |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
379 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
380 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
381 |
normal |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
382 |
"set emphasis to #normal. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
383 |
this allows Streams to be used interchangeable with printStreams" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
384 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
385 |
self emphasis:nil |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
386 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
387 |
"Created: 14.5.1996 / 17:37:59 / cg" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
388 |
"Modified: 3.6.1996 / 17:15:35 / cg" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
389 |
! |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
390 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
391 |
strikeout |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
392 |
"set emphasis to #strikeout. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
393 |
this allows Streams to be used interchangeable with printStreams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
394 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
395 |
self emphasis:#strikeout. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
396 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
397 |
"Modified: 3.6.1996 / 16:57:56 / cg" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
398 |
"Created: 3.6.1996 / 17:15:45 / cg" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
399 |
! |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
400 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
401 |
underline |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
402 |
"set emphasis to #underline. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
403 |
this allows Streams to be used interchangeable with printStreams" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
404 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
405 |
self emphasis:#underline. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
406 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
407 |
"Created: 3.6.1996 / 17:00:03 / cg" |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
408 |
"Modified: 3.6.1996 / 17:15:38 / cg" |
14347 | 409 |
! |
410 |
||
411 |
withEmphasis:anEmphasis do:aBlock |
|
412 |
"evaluate aBlock while my emphasis has been changed to anEmphasis. |
|
413 |
Emphasis is ignored here, but implemented in some subclasses (PrinterStream, TextCollector etc.)." |
|
414 |
||
415 |
|oldEmphasis| |
|
416 |
||
417 |
oldEmphasis := self emphasis. |
|
418 |
[ |
|
419 |
self emphasis:anEmphasis. |
|
420 |
aBlock value |
|
421 |
] ensure:[ |
|
422 |
self emphasis:oldEmphasis. |
|
423 |
]. |
|
424 |
||
425 |
"Created: / 06-09-2012 / 16:12:55 / cg" |
|
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
426 |
! ! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
427 |
|
1401 | 428 |
!Stream methodsFor:'enumerating'! |
429 |
||
430 |
do:aBlock |
|
431 |
"evaluate the argument, aBlock for all remaining elements, |
|
432 |
up to the end of the stream" |
|
433 |
||
434 |
[self atEnd] whileFalse:[ |
|
435 |
aBlock value:(self next) |
|
436 |
] |
|
437 |
||
438 |
" |
|
439 |
|s| |
|
440 |
s := ReadStream on:#(1 2 3 4 5 6 7 8 9). |
|
441 |
s next. |
|
442 |
s next. |
|
1422 | 443 |
s do:[:element | Transcript showCR:element] |
1401 | 444 |
" |
6384 | 445 |
! |
446 |
||
447 |
linesDo:aBlock |
|
448 |
"evaluate the argument, aBlock for all lines, |
|
449 |
up to the end of the stream" |
|
450 |
||
451 |
[self atEnd] whileFalse:[ |
|
452 |
aBlock value:(self nextLine) |
|
453 |
] |
|
454 |
||
455 |
" |
|
456 |
|s| |
|
457 |
s := '/etc/hosts' asFilename readStream. |
|
458 |
s linesDo:[:line | Transcript showCR:line]. |
|
459 |
s close |
|
460 |
" |
|
461 |
||
462 |
" |
|
463 |
Filename readingFile:'/etc/hosts' |
|
464 |
do:[:s | |
|
465 |
s linesDo:[:line | Transcript showCR:line]. |
|
466 |
]. |
|
467 |
" |
|
1401 | 468 |
! ! |
469 |
||
470 |
!Stream methodsFor:'error handling'! |
|
471 |
||
7104
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
472 |
checkNilFileStream |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
473 |
"Do nothing if this is a valid FileStream |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
474 |
(i.e. the previous open operation was successful). |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
475 |
Also implemented in UndefinedObject, to raise an Error there. |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
476 |
|
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
477 |
This is an aid for converting from the old error reporting (returning nil) |
8309 | 478 |
to the new error reporting (with real Exceptions). |
7104
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
479 |
|
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
480 |
It will vanish as soon as the conversion has been done" |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
481 |
|
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
482 |
^ self |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
483 |
! |
c88669d779f5
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
7013
diff
changeset
|
484 |
|
1401 | 485 |
pastEnd |
486 |
"someone tried to read after the end of the stream. |
|
3104
4b817b05cde0
vw compatible readPastEnd: only raise the signal if its handled;
Claus Gittinger <cg@exept.de>
parents:
3084
diff
changeset
|
487 |
If signalAtEnd == true, raise a signal. If its false, return nil. |
4b817b05cde0
vw compatible readPastEnd: only raise the signal if its handled;
Claus Gittinger <cg@exept.de>
parents:
3084
diff
changeset
|
488 |
Otherwise raise the signal, but only if handled; otherwise return nil." |
1401 | 489 |
|
8622 | 490 |
<resource: #obsolete> |
491 |
||
9061 | 492 |
self obsoleteMethodWarning:'use #pastEndRead'. |
10181 | 493 |
^ self pastEndRead |
494 |
||
495 |
"Modified: / 18-11-2006 / 15:36:44 / cg" |
|
8614 | 496 |
! |
497 |
||
498 |
pastEndRead |
|
499 |
"someone tried to read after the end of the stream. |
|
8992
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
500 |
If signalAtEnd == true, raise a signal. |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
501 |
If it is false, return nil. |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
502 |
Otherwise raise a notification, which is ignored if not handled; |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
503 |
otherwise return nil." |
8614 | 504 |
|
13380 | 505 |
|shouldSignalAtEnd| |
506 |
||
507 |
shouldSignalAtEnd := self signalAtEnd. |
|
508 |
||
509 |
shouldSignalAtEnd == true ifTrue:[ |
|
8992
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
510 |
"raise - a hard error..." |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
511 |
^ EndOfStreamError raiseRequestFrom:self |
3104
4b817b05cde0
vw compatible readPastEnd: only raise the signal if its handled;
Claus Gittinger <cg@exept.de>
parents:
3084
diff
changeset
|
512 |
]. |
13380 | 513 |
shouldSignalAtEnd == false ifTrue:[ |
8515 | 514 |
"never raise ..." |
515 |
^ nil |
|
1401 | 516 |
]. |
517 |
||
8992
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
518 |
"EndOfStreamNotification is ignored, if there is no handler. |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
519 |
In this case, nil is returned" |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
520 |
|
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
521 |
^ EndOfStreamNotification raiseRequestFrom:self |
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
522 |
|
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
523 |
|
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
524 |
" ... no handler, no raise |
3591 | 525 |
|s| |
526 |
||
527 |
s := '12' readStream. |
|
528 |
Transcript showCR:s next. |
|
529 |
Transcript showCR:s next. |
|
530 |
Transcript showCR:s next. |
|
531 |
Transcript showCR:s next. |
|
532 |
" |
|
533 |
||
534 |
"... raise error if handled. |
|
535 |
|s| |
|
536 |
||
537 |
s := '12' readStream. |
|
8992
0feb5e68e5a7
Raise EndOfStreamError when signalAtEnd: is set to true
Stefan Vogel <sv@exept.de>
parents:
8988
diff
changeset
|
538 |
EndOfStreamNotification handle:[:ex | |
8515 | 539 |
Transcript showCR:'end reached'. |
540 |
ex return |
|
3591 | 541 |
] do:[ |
8515 | 542 |
Transcript showCR:s next. |
543 |
Transcript showCR:s next. |
|
544 |
Transcript showCR:s next. |
|
545 |
Transcript showCR:s next. |
|
3591 | 546 |
] |
547 |
" |
|
3104
4b817b05cde0
vw compatible readPastEnd: only raise the signal if its handled;
Claus Gittinger <cg@exept.de>
parents:
3084
diff
changeset
|
548 |
|
3591 | 549 |
"force raise (useful for debugging): |
550 |
|s| |
|
551 |
||
552 |
s := '12' readStream. |
|
553 |
s signalAtEnd:true. |
|
554 |
Transcript showCR:s next. |
|
555 |
Transcript showCR:s next. |
|
556 |
Transcript showCR:s next. |
|
557 |
Transcript showCR:s next. |
|
558 |
" |
|
559 |
||
560 |
||
561 |
"force no-raise (useful for compatibility with other systems): |
|
562 |
|s| |
|
563 |
||
564 |
s := '12' readStream. |
|
565 |
s signalAtEnd:false. |
|
566 |
Stream endOfStreamSignal handle:[:ex | |
|
8515 | 567 |
Transcript showCR:'end reached'. |
568 |
ex return |
|
3591 | 569 |
] do:[ |
8515 | 570 |
Transcript showCR:s next. |
571 |
Transcript showCR:s next. |
|
572 |
Transcript showCR:s next. |
|
573 |
Transcript showCR:s next. |
|
3591 | 574 |
] |
575 |
" |
|
576 |
||
577 |
"Modified: / 16.6.1998 / 16:04:13 / cg" |
|
1401 | 578 |
! ! |
579 |
||
611 | 580 |
!Stream methodsFor:'misc'! |
581 |
||
582 |
binary |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
583 |
"switch to binary mode. In binary mode, reading of text streams |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
584 |
returns byte-valued integers instead of characters; writing expects |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
585 |
byte-valued integers respectively. |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
586 |
Ignored here, but added to make internalStreams protocol compatible |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
587 |
with externalStreams." |
611 | 588 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
589 |
"Modified: 15.5.1996 / 17:38:36 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
590 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
591 |
|
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
592 |
blocking:aBoolean |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
593 |
"set non-blocking mode. |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
594 |
Ignored, since internal streams never block" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
595 |
|
7498
9637184b10fe
ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents:
7497
diff
changeset
|
596 |
^ false. |
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
597 |
! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
598 |
|
16775 | 599 |
eolMode |
600 |
"Dummy here, but added to make internalStreams protocol compatible |
|
601 |
with externalStreams." |
|
602 |
||
603 |
^ nil "/ transparent |
|
604 |
! |
|
605 |
||
8507
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
606 |
eolMode:aSymbol |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
607 |
"Ignored here, but added to make internalStreams protocol compatible |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
608 |
with externalStreams." |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
609 |
! |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
610 |
|
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
611 |
lineEndCRLF |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
612 |
"Ignored here, but added to make internalStreams protocol compatible |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
613 |
with externalStreams." |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
614 |
! |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
615 |
|
17673 | 616 |
lineEndLF |
617 |
"Ignored here, but added to make internalStreams protocol compatible |
|
618 |
with externalStreams." |
|
619 |
! |
|
620 |
||
8507
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
621 |
lineEndTransparent |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
622 |
"Ignored here, but added to make internalStreams protocol compatible |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
623 |
with externalStreams." |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
624 |
! |
9d392516725c
more external stream compatibility
Stefan Vogel <sv@exept.de>
parents:
8338
diff
changeset
|
625 |
|
14434 | 626 |
stream |
627 |
"for compatibility with encodedStream" |
|
628 |
||
629 |
^ self |
|
630 |
! |
|
631 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
632 |
text |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
633 |
"switch to text mode. |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
634 |
Ignored here, but added to make internalStreams protocol compatible |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
635 |
with externalStreams." |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
636 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
637 |
"Modified: 15.5.1996 / 17:38:36 / cg" |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
638 |
"Created: 13.9.1996 / 18:33:26 / cg" |
611 | 639 |
! ! |
640 |
||
8768 | 641 |
!Stream methodsFor:'misc functions'! |
642 |
||
9001 | 643 |
copy:numberOfBytes into:outStream bufferSize:bufferSize |
644 |
"read from the receiver, and write all data up to count or the end to another stream. |
|
645 |
Return the number of bytes which have been transferred" |
|
646 |
||
647 |
|bufferSpecies buffer bytesWritten readCount writeCount count freeBuffer remaining| |
|
648 |
||
649 |
bytesWritten := 0. |
|
650 |
bufferSpecies := self contentsSpecies. |
|
651 |
bufferSpecies == ByteArray ifTrue:[ |
|
652 |
buffer:= ExternalBytes unprotectedNew:bufferSize. |
|
653 |
freeBuffer := true. |
|
654 |
] ifFalse:[ |
|
655 |
buffer := self contentsSpecies new:bufferSize. |
|
656 |
freeBuffer := false. |
|
657 |
]. |
|
658 |
||
659 |
remaining := numberOfBytes. |
|
660 |
"Note: atEnd will block if reading from an empty pipe or socket" |
|
661 |
[remaining ~~ 0 and:[self atEnd]] whileFalse:[ |
|
662 |
readCount := self nextAvailableBytes:(bufferSize min:remaining) into:buffer startingAt:1. |
|
663 |
readCount > 0 ifTrue:[ |
|
664 |
writeCount := 0. |
|
665 |
[ |
|
666 |
count := outStream nextPutBytes:readCount-writeCount |
|
667 |
from:buffer |
|
668 |
startingAt:writeCount+1. |
|
669 |
bytesWritten := bytesWritten + count. |
|
670 |
writeCount := writeCount + count. |
|
671 |
writeCount < readCount ifTrue:[ |
|
672 |
outStream writeWait. |
|
673 |
true. |
|
674 |
] ifFalse:[ |
|
675 |
false |
|
676 |
]. |
|
677 |
] whileTrue. |
|
678 |
remaining := remaining - writeCount. |
|
679 |
]. |
|
680 |
]. |
|
681 |
freeBuffer ifTrue:[ buffer free ]. |
|
682 |
^ bytesWritten |
|
683 |
||
684 |
" |
|
685 |
'hello world' readStream copyToEndInto:'/tmp/mist' asFilename writeStream. |
|
686 |
'hello world' readStream copyToEndInto:#[] writeStream. |
|
687 |
('/tmp/mist' asFilename readStream binary; yourself) copyToEndInto:#[] writeStream |
|
688 |
#[1 2 3 4 5 6 7] readStream copyToEndInto:'/tmp/mist' asFilename writeStream. |
|
689 |
#[1 2 3 4 5 6 7] readStream copyToEndInto:'' writeStream. |
|
690 |
||
691 |
" |
|
692 |
! |
|
693 |
||
11745 | 694 |
copyToEndFrom:inStream |
695 |
"read from inStream, and write all data up to the end to the receiver. |
|
696 |
Return the number of bytes which have been transferred. |
|
697 |
Same functionality as copyToEnd:, but reversed arg and receiver |
|
698 |
(useful in a cascade message of the writeStream)" |
|
699 |
||
700 |
^ inStream copyToEndInto:self |
|
701 |
! |
|
702 |
||
8768 | 703 |
copyToEndInto:outStream |
704 |
"read from the receiver, and write all data up to the end to another stream. |
|
705 |
Return the number of bytes which have been transferred" |
|
706 |
||
707 |
^ self copyToEndInto:outStream bufferSize:(128*1024) |
|
708 |
||
709 |
"/ data rate to USB2.0 stick (Win32): |
|
710 |
"/ 120 KB/s 8Kb SingleBuffer |
|
711 |
"/ 741 KB/s 64Kb SingleBuffer |
|
712 |
"/ 1345 KB/s 128Kb SingleBuffer |
|
713 |
"/ 2087 KB/s 256Kb SingleBuffer |
|
714 |
"/ 3573 KB/s 1024Kb SingleBuffer |
|
715 |
||
716 |
"/|t retVal| |
|
717 |
"/ |
|
718 |
"/t := Time millisecondsToRun:[ |
|
719 |
"/ retVal := self copyToEndInto:outStream bufferSize:(64*1024). |
|
720 |
"/]. |
|
721 |
"/ |
|
722 |
"/Transcript showCR:('%1 KB copied in %2s (%3 KB/s)' |
|
723 |
"/ bindWith:((retVal/1024)asFixedPoint:2) |
|
724 |
"/ with:((t/1000)asFixedPoint:2) |
|
725 |
"/ with:((retVal/1024/(t/1000))asFixedPoint:2)). |
|
726 |
"/^ retVal. |
|
727 |
"/ |
|
728 |
! |
|
729 |
||
730 |
copyToEndInto:outStream bufferSize:bufferSize |
|
731 |
"read from the receiver, and write all data up to the end to another stream. |
|
732 |
Return the number of bytes which have been transferred" |
|
733 |
||
17610 | 734 |
|bufferSpecies buffer countWritten freeBuffer| |
735 |
||
736 |
countWritten := 0. |
|
8768 | 737 |
bufferSpecies := self contentsSpecies. |
738 |
bufferSpecies == ByteArray ifTrue:[ |
|
17610 | 739 |
"an ExternalBytes buffer is faster when writing to a windows ExternalStream" |
8768 | 740 |
buffer:= ExternalBytes unprotectedNew:bufferSize. |
741 |
freeBuffer := true. |
|
742 |
] ifFalse:[ |
|
743 |
buffer := self contentsSpecies new:bufferSize. |
|
744 |
freeBuffer := false. |
|
745 |
]. |
|
746 |
||
16486 | 747 |
"read loop: read until end of stream" |
17610 | 748 |
[ |
749 |
|readCount| |
|
750 |
||
751 |
readCount := self nextAvailable:bufferSize into:buffer startingAt:1. |
|
8768 | 752 |
readCount > 0 ifTrue:[ |
17610 | 753 |
|writeCount| |
754 |
||
8768 | 755 |
writeCount := 0. |
16486 | 756 |
"write loop: write until all is written" |
8768 | 757 |
[ |
17610 | 758 |
|count| |
759 |
||
760 |
count := outStream |
|
761 |
nextPutAll:readCount-writeCount |
|
762 |
from:buffer |
|
763 |
startingAt:writeCount+1. |
|
8768 | 764 |
writeCount := writeCount + count. |
765 |
writeCount < readCount ifTrue:[ |
|
766 |
outStream writeWait. |
|
767 |
true. |
|
768 |
] ifFalse:[ |
|
769 |
false |
|
770 |
]. |
|
771 |
] whileTrue. |
|
17610 | 772 |
countWritten := countWritten + writeCount. |
16486 | 773 |
]. |
774 |
"Note: atEnd will block if reading from an empty pipe or socket. |
|
775 |
avoid atEnd if possible, because it reads a single byte." |
|
776 |
readCount ~~ 0 or:[self atEnd not] |
|
777 |
] whileTrue. |
|
778 |
||
8768 | 779 |
freeBuffer ifTrue:[ buffer free ]. |
17610 | 780 |
^ countWritten |
8768 | 781 |
|
782 |
" |
|
783 |
'hello world' readStream copyToEndInto:'/tmp/mist' asFilename writeStream. |
|
784 |
'hello world' readStream copyToEndInto:#[] writeStream. |
|
785 |
('/tmp/mist' asFilename readStream binary; yourself) copyToEndInto:#[] writeStream |
|
786 |
#[1 2 3 4 5 6 7] readStream copyToEndInto:'/tmp/mist' asFilename writeStream. |
|
17610 | 787 |
#(1 2 3 a 'b' 6.4 true) readStream next; copyToEndInto:#() writeStream inspect. |
8768 | 788 |
|
789 |
" |
|
790 |
! ! |
|
791 |
||
611 | 792 |
!Stream methodsFor:'non homogenous reading'! |
793 |
||
7497
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
794 |
nextAvailableBytes:numBytes into:aCollection startingAt:initialIndex |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
795 |
"for compatibility with ExternalStream" |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
796 |
|
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
797 |
^ self nextBytes:numBytes into:aCollection startingAt:initialIndex |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
798 |
! |
cc29afd51151
Do not block when writing to pipes
Stefan Vogel <sv@exept.de>
parents:
7483
diff
changeset
|
799 |
|
8988
2e82cf20dbbd
define #nextByte as subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
8970
diff
changeset
|
800 |
nextByte |
2e82cf20dbbd
define #nextByte as subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
8970
diff
changeset
|
801 |
"return the next byte of the stream |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
802 |
- we do not know here how to do it, it should be redefined in subclass" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
803 |
|
15839 | 804 |
^ self next asInteger |
8988
2e82cf20dbbd
define #nextByte as subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
8970
diff
changeset
|
805 |
! |
2e82cf20dbbd
define #nextByte as subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
8970
diff
changeset
|
806 |
|
2714 | 807 |
nextBytes:count |
11249 | 808 |
"read the next count bytes and return it as a byteArray. |
809 |
If EOF is encountered while reading, a truncated byteArray is returned. |
|
810 |
If EOF is already reached before the first byte can be read, |
|
15839 | 811 |
an error is raised." |
2714 | 812 |
|
813 |
|data n| |
|
814 |
||
7187 | 815 |
data := ByteArray uninitializedNew:count. |
2714 | 816 |
n := self nextBytes:count into:data startingAt:1. |
817 |
n ~~ count ifTrue:[ |
|
7187 | 818 |
n == 0 ifTrue:[ |
15839 | 819 |
^ self pastEndRead. |
7187 | 820 |
]. |
821 |
data := data copyTo:n |
|
2714 | 822 |
]. |
823 |
^ data |
|
824 |
||
3346 | 825 |
"Created: / 21.6.1997 / 11:18:57 / cg" |
826 |
"Modified: / 30.3.1998 / 18:04:58 / cg" |
|
2714 | 827 |
! |
828 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
829 |
nextBytes:count into:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
830 |
"read the next count bytes into an object and return the number of |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
831 |
bytes read. On EOF, 0 is returned. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
832 |
If the receiver is some socket/pipe-like stream, an exception |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
833 |
is raised if the connection is broken. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
834 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
835 |
The object must have non-pointer indexed instvars (i.e. it must be |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
836 |
a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
837 |
If anObject is a string or byteArray and reused, this provides the |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
838 |
fastest possible physical I/O (since no new objects are allocated). |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
839 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
840 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
841 |
Warning: in general, you cannot use this method to pass data from other |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
842 |
architectures since it does not care for byte order or float representation." |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
843 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
844 |
^ self nextBytes:count into:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
845 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
846 |
"Modified: 22.4.1997 / 10:41:39 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
847 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
848 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
849 |
nextBytes:numBytes into:aCollection startingAt:initialIndex |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
850 |
"return the next numBytes from the stream. If the end is |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
851 |
reached before, only that many bytes are copyied into the |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
852 |
collection. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
853 |
Returns the number of bytes that have been actually read. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
854 |
The receiver must support reading of binary bytes. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
855 |
|
9001 | 856 |
Notice: this method is provided here for protocol completeness |
7506 | 857 |
with externalStreams - it is normally not used with other |
858 |
streams." |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
859 |
|
17610 | 860 |
|n "{Class: SmallInteger }"| |
861 |
||
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
862 |
n := 0. |
7506 | 863 |
|
17610 | 864 |
[n ~= numBytes and:[self atEnd not]] whileTrue:[ |
865 |
aCollection byteAt:initialIndex+n put:self nextByte. |
|
15839 | 866 |
n := n + 1. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
867 |
]. |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
868 |
^ n |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
869 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
870 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
871 |
|s n buffer| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
872 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
873 |
buffer := ByteArray new:10. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
874 |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
875 |
s := ReadStream on:#[1 2 3 4 5 6 7 8 9]. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
876 |
s next:3. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
877 |
n := s nextBytes:9 into:buffer startingAt:1. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
878 |
Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer) |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
879 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
880 |
|
17610 | 881 |
" |
882 |
|s n buffer| |
|
883 |
||
884 |
buffer := String new:10. |
|
885 |
||
886 |
s := ReadStream on:'Hello World'. |
|
887 |
s next:6. |
|
888 |
n := s nextBytes:5 into:buffer startingAt:1. |
|
889 |
Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer) |
|
890 |
" |
|
891 |
||
892 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
893 |
"Modified: 22.4.1997 / 10:43:08 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
894 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
895 |
|
2587 | 896 |
nextBytes:numBytes into:aCollection startingAt:initialIndex blockSize:blockSize |
897 |
"like nextBytes:into:startingAt:, but read in blocks of the given size. |
|
898 |
This leads to better beahvior when reading large chunks from a slow device, |
|
899 |
such as a cdrom drive (since a single unix-read is not interruptable)." |
|
900 |
||
901 |
|nR oR n| |
|
902 |
||
903 |
nR := numBytes. |
|
904 |
oR := initialIndex. |
|
905 |
[nR > 0] whileTrue:[ |
|
3154 | 906 |
n := nR. |
907 |
n > blockSize ifTrue:[n := blockSize]. |
|
908 |
n := self nextBytes:n into:aCollection startingAt:oR. |
|
909 |
n == 0 ifTrue:[ |
|
910 |
^ numBytes - nR |
|
911 |
]. |
|
912 |
oR := oR + n. |
|
913 |
nR := nR - n |
|
2587 | 914 |
]. |
915 |
^ numBytes |
|
916 |
||
917 |
"Created: 24.4.1997 / 21:09:34 / cg" |
|
918 |
"Modified: 24.4.1997 / 21:19:50 / cg" |
|
919 |
! |
|
920 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
921 |
nextBytesInto:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
922 |
"read bytes into an object, regardless of binary/text mode. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
923 |
The number of bytes to read is defined by the objects size. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
924 |
Return the number of bytes read. On EOF, 0 is returned. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
925 |
If the receiver is some socket/pipe-like stream, an exception |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
926 |
is raised if the connection is broken. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
927 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
928 |
The object to read into must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
929 |
(i.e. it must be a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
930 |
If anObject is a string or byteArray and reused, this provides the |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
931 |
fastest possible physical I/O (since no new objects are allocated). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
932 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
933 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
934 |
Warning: in general, you cannot use this method to pass data from other |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
935 |
architectures since it does not care for byte order or float representation." |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
936 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
937 |
^ self nextBytes:(anObject byteSize) into:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
938 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
939 |
" to read 100 bytes from a stream: |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
940 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
941 |
|b aStream| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
942 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
943 |
aStream := 'smalltalk.rc' asFilename readStream. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
944 |
b := ByteArray new:100. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
945 |
aStream nextBytesInto:b. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
946 |
aStream close. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
947 |
b inspect |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
948 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
949 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
950 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
951 |
|s aStream| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
952 |
aStream := 'smalltalk.rc' asFilename readStream. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
953 |
s := String new:100. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
954 |
aStream nextBytesInto:s. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
955 |
aStream close. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
956 |
s inspect |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
957 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
958 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
959 |
"Modified: 22.4.1997 / 10:42:02 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
960 |
"Created: 22.4.1997 / 10:42:26 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
961 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
962 |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
963 |
nextHyperMSB:msbFlag |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
964 |
"return a signed hyper (8 bytes) from the stream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
965 |
The receiver must support reading of binary bytes. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
966 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
967 |
The msbFlag argument controls if the integer is to be read with |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
968 |
most-significant-byte-first (true) or least-first (false). |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
969 |
This interface is provided to allow talking to external programs, |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
970 |
where its known that the byte order is some definite one. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
971 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
972 |
order, please use the corresponding xxxNet methods, which use a standard |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
973 |
network byte order." |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
974 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
975 |
|uval| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
976 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
977 |
uval := self nextUnsignedHyperMSB:msbFlag. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
978 |
"change from unsigned 0..FF..FF to signed -80..00..7FF..FF" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
979 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
980 |
uval >= 16r8000000000000000 ifTrue:[ |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
981 |
^ uval - 16r10000000000000000 |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
982 |
]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
983 |
^ uval |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
984 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
985 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
986 |
|bytes s| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
987 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
988 |
bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
989 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
990 |
Transcript showCR:(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
991 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
992 |
Transcript showCR:(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
993 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
994 |
bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
995 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
996 |
Transcript showCR:(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
997 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
998 |
Transcript showCR:(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
999 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1000 |
bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1001 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1002 |
Transcript showCR:(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1003 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1004 |
Transcript showCR:(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1005 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1006 |
bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1007 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1008 |
Transcript showCR:(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1009 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1010 |
Transcript showCR:(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1011 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1012 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1013 |
"Modified: / 14.1.1998 / 15:40:41 / cg" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1014 |
! |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1015 |
|
11616
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1016 |
nextIEEEDouble |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1017 |
"read an 8-byte IEEE double precision float number" |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1018 |
|
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1019 |
^ Float readBinaryIEEEDoubleFrom:self |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1020 |
! |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1021 |
|
17628 | 1022 |
nextIEEEDoubleMSB:msbFirst |
1023 |
"read an 8-byte IEEE double precision float number" |
|
1024 |
||
1025 |
^ Float readBinaryIEEEDoubleFrom:self MSB:msbFirst |
|
1026 |
! |
|
1027 |
||
11616
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1028 |
nextIEEESingle |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1029 |
"read a 4-byte IEEE single precision float number" |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1030 |
|
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1031 |
^ ShortFloat readBinaryIEEESingleFrom:self |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1032 |
! |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1033 |
|
17628 | 1034 |
nextIEEESingleMSB:msbFirst |
1035 |
"read a 4-byte IEEE single precision float number" |
|
1036 |
||
1037 |
^ ShortFloat readBinaryIEEESingleFrom:self MSB:msbFirst |
|
1038 |
! |
|
1039 |
||
611 | 1040 |
nextLongMSB:msbFlag |
1041 |
"return a signed long (4 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1042 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1043 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1044 |
The msbFlag argument controls if the integer is to be read with |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1045 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1046 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1047 |
where its known that the byte order is some definite one. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1048 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1049 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1050 |
network byte order." |
611 | 1051 |
|
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1052 |
|b1 b2 b3 b4 uval "{ Class: SmallInteger }" val| |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1053 |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1054 |
b1 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1055 |
b2 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1056 |
b3 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1057 |
b4 := self nextByte. |
611 | 1058 |
|
1059 |
msbFlag ifTrue:[ |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1060 |
"most significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1061 |
uval := (b1 bitShift:8) bitOr:b2. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1062 |
uval := (uval bitShift:8) bitOr:b3. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1063 |
val := (uval bitShift:8) bitOr:b4. |
611 | 1064 |
] ifFalse:[ |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1065 |
"least significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1066 |
uval := (b4 bitShift:8) bitOr:b3. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1067 |
uval := (uval bitShift:8) bitOr:b2. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1068 |
val := (uval bitShift:8) bitOr:b1. |
611 | 1069 |
]. |
1070 |
"change from unsigned 0..FFFFFFFF to signed -80000000..7FFFFFFF" |
|
1071 |
||
3176 | 1072 |
val >= 16r80000000 ifTrue:[ |
1073 |
^ val - 16r100000000 |
|
1074 |
]. |
|
1075 |
^ val |
|
1076 |
||
1077 |
" |
|
1078 |
|bytes s| |
|
1079 |
||
1080 |
bytes := #[16rFF 16rFF 16rFF 16rFF]. |
|
1081 |
s := bytes readStream. |
|
1082 |
Transcript showCR:(s nextLongMSB:true). |
|
1083 |
s reset. |
|
1084 |
Transcript showCR:(s nextLongMSB:false). |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1085 |
|
3176 | 1086 |
bytes := #[16r12 16r34 16r56 16r78]. |
1087 |
s := bytes readStream. |
|
1088 |
Transcript showCR:(s nextLongMSB:true). |
|
1089 |
s reset. |
|
1090 |
Transcript showCR:(s nextLongMSB:false). |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1091 |
|
3176 | 1092 |
bytes := #[16r89 16rab 16rcd 16ref]. |
1093 |
s := bytes readStream. |
|
1094 |
Transcript showCR:(s nextLongMSB:true). |
|
1095 |
s reset. |
|
1096 |
Transcript showCR:(s nextLongMSB:false). |
|
1097 |
" |
|
1098 |
||
1099 |
"Modified: / 14.1.1998 / 15:40:41 / cg" |
|
611 | 1100 |
! |
1101 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1102 |
nextLongNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1103 |
"return a signed long (4 bytes) in network byte order from the stream. |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1104 |
The receiver must support reading of binary bytes." |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1105 |
|
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1106 |
^ self nextLongMSB:true |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1107 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1108 |
"Created: 10.1.1996 / 19:49:28 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1109 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1110 |
|
12129 | 1111 |
nextNumber:numBytes |
611 | 1112 |
"Return the next n bytes as a positive Integer; bytes are taken msb-first." |
1113 |
||
12129 | 1114 |
^ self nextUnsigned:numBytes MSB:true |
611 | 1115 |
! |
1116 |
||
1117 |
nextShortMSB:msbFlag |
|
1118 |
"return a signed short (2 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1119 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1120 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1121 |
The msbFlag argument controls if the integer is to be read with |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1122 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1123 |
This interface is provided to allow talking to external programs, |
16791 | 1124 |
where it's known that the byte order is some definite one. |
1125 |
If you don't care (i.e. talk to other smalltalks) or you can control the |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1126 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1127 |
network byte order." |
611 | 1128 |
|
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1129 |
|b1 b2 uval "{ Class: SmallInteger }"| |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1130 |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1131 |
b1 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1132 |
b2 := self nextByte. |
611 | 1133 |
|
1134 |
msbFlag ifTrue:[ |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1135 |
"most significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1136 |
uval := b1 bitShift:8. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1137 |
uval := uval bitOr:b2. |
611 | 1138 |
] ifFalse:[ |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1139 |
"least significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1140 |
uval := b2 bitShift:8. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1141 |
uval := uval bitOr:b1. |
611 | 1142 |
]. |
1143 |
"change from unsigned 0..FFFF to signed -8000..7FFF" |
|
1144 |
uval >= 16r8000 ifTrue:[ |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1145 |
^ uval - 16r10000 |
611 | 1146 |
]. |
1147 |
^ uval |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1148 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1149 |
"Modified: 11.7.1996 / 10:07:04 / cg" |
611 | 1150 |
! |
1151 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1152 |
nextShortNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1153 |
"return a signed short (2 bytes) in network byte order from the stream. |
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1154 |
The receiver must support reading of binary bytes. |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1155 |
Network byte order is MSB per definition" |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1156 |
|
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1157 |
^ self nextShortMSB:true |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1158 |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1159 |
"Created: 10.1.1996 / 19:49:41 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1160 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1161 |
|
4588 | 1162 |
nextSignedByte |
1163 |
"return a signed byte (-128..127) from the stream. |
|
1164 |
The receiver must support reading of binary bytes." |
|
1165 |
||
1166 |
|uval "{ Class: SmallInteger }"| |
|
1167 |
||
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1168 |
uval := self nextByte. |
4588 | 1169 |
"change from unsigned 0..FF to signed -80..7F" |
1170 |
uval >= 16r80 ifTrue:[ |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1171 |
^ uval - 16r100 |
4588 | 1172 |
]. |
1173 |
^ uval |
|
1174 |
||
1175 |
" |
|
1176 |
#[16rFF 16r80 16r7F 16r01] readStream nextSignedByte |
|
1177 |
" |
|
1178 |
! |
|
1179 |
||
12129 | 1180 |
nextUnsigned:numBytes MSB:msbFlag |
1181 |
"return a numBytes-sized unsigned (numBytes bytes) from the stream as an Integer. |
|
1182 |
The receiver must support reading of binary bytes. |
|
1183 |
||
1184 |
The msbFlag argument controls if the integer is to be read with |
|
1185 |
most-significant-byte-first (true) or least-first (false). |
|
1186 |
This interface is provided to allow talking to external programs, |
|
1187 |
where its known that the byte order is some definite one. |
|
1188 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
|
1189 |
order, please use the corresponding xxxNet methods, which use a standard |
|
1190 |
network byte order." |
|
1191 |
||
1192 |
|val shift| |
|
1193 |
||
1194 |
"claus: this method is central in binaryStorage - |
|
1195 |
therefore it has been tuned a bit (and needs even more tuning)" |
|
1196 |
||
1197 |
numBytes == 1 ifTrue:[ |
|
1198 |
^ self nextByte |
|
1199 |
]. |
|
1200 |
numBytes == 2 ifTrue:[ |
|
1201 |
^ self nextUnsignedShortMSB:msbFlag |
|
1202 |
]. |
|
1203 |
numBytes == 3 ifTrue:[ |
|
1204 |
val := self nextUnsignedShortMSB:msbFlag. |
|
1205 |
msbFlag ifTrue:[ |
|
1206 |
^ (val bitShift:8) + self nextByte |
|
1207 |
]. |
|
1208 |
^ val + (self nextByte bitShift:16) |
|
1209 |
]. |
|
1210 |
numBytes == 4 ifTrue:[ |
|
1211 |
^ self nextUnsignedLongMSB:msbFlag |
|
1212 |
]. |
|
1213 |
||
1214 |
val := 0. |
|
1215 |
msbFlag ifTrue:[ |
|
1216 |
numBytes timesRepeat:[ |
|
1217 |
val := (val bitShift:8) + self nextByte |
|
1218 |
]. |
|
1219 |
] ifFalse:[ |
|
1220 |
shift := 0. |
|
1221 |
numBytes timesRepeat:[ |
|
1222 |
val := val + (self nextByte bitShift:shift). |
|
1223 |
shift := shift + 8. |
|
1224 |
]. |
|
1225 |
]. |
|
1226 |
^ val |
|
1227 |
||
1228 |
" |
|
1229 |
|s| |
|
1230 |
||
1231 |
s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
|
1232 |
(s nextUnsigned:3 MSB:true) hexPrintString. |
|
1233 |
||
1234 |
s := #[ 16r01 16r02 16r03 16r04 16r05 ] readStream. |
|
1235 |
(s nextUnsigned:3 MSB:false) hexPrintString. |
|
1236 |
" |
|
1237 |
! |
|
1238 |
||
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1239 |
nextUnsignedHyperMSB:msbFlag |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1240 |
"return an unsigned hyper (8 bytes) from the stream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1241 |
The receiver must support reading of binary bytes. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1242 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1243 |
The msbFlag argument controls if the integer is to be read with |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1244 |
most-significant-byte-first (true) or least-first (false). |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1245 |
This interface is provided to allow talking to external programs, |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1246 |
where its known that the byte order is some definite one. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1247 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1248 |
order, please use the corresponding xxxNet methods, which use a standard |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1249 |
network byte order." |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1250 |
|
6373
d6ffb0101dde
workaround bitShift-bitOr codeGenerator bug in stc
Claus Gittinger <cg@exept.de>
parents:
6360
diff
changeset
|
1251 |
|bytes uval t| |
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1252 |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1253 |
bytes := self nextBytes:8. |
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1254 |
uval := 0. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1255 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1256 |
msbFlag ifTrue:[ |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1257 |
"most significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1258 |
1 to:8 do:[:i | |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1259 |
t := (uval bitShift:8). |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1260 |
uval := t bitOr:(bytes at:i). |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1261 |
]. |
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1262 |
] ifFalse:[ |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1263 |
"least significant first" |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1264 |
8 to:1 by:-1 do:[:i | |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1265 |
t := (uval bitShift:8). |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1266 |
uval := t bitOr:(bytes at:i). |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1267 |
]. |
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1268 |
]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1269 |
^ uval |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1270 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1271 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1272 |
|bytes s| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1273 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1274 |
bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1275 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1276 |
Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1277 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1278 |
Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1279 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1280 |
bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1281 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1282 |
Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1283 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1284 |
Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1285 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1286 |
bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1287 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1288 |
Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1289 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1290 |
Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1291 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1292 |
bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1293 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1294 |
Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1295 |
s reset. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1296 |
Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1297 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1298 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1299 |
"Modified: / 14.1.1998 / 15:40:41 / cg" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1300 |
! |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1301 |
|
611 | 1302 |
nextUnsignedLongMSB:msbFlag |
1303 |
"return an unsigned long (4 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1304 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1305 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1306 |
The msbFlag argument controls if the integer is to be read with |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1307 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1308 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1309 |
where its known that the byte order is some definite one. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1310 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1311 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1312 |
network byte order." |
611 | 1313 |
|
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1314 |
|b1 b2 b3 b4 val| |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1315 |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1316 |
b1 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1317 |
b2 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1318 |
b3 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1319 |
b4 := self nextByte. |
611 | 1320 |
|
1321 |
msbFlag ifTrue:[ |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1322 |
val := b1. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1323 |
val := (val bitShift:8) bitOr:b2. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1324 |
val := (val bitShift:8) bitOr:b3. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1325 |
val := (val * 256) + b4. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1326 |
^ val |
611 | 1327 |
]. |
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1328 |
val := b4. |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1329 |
val := (val bitShift:8) bitOr:b3. |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1330 |
val := (val bitShift:8) bitOr:b2. |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1331 |
val := (val * 256) + b1. |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1332 |
^ val |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1333 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1334 |
"Modified: 11.7.1996 / 10:07:13 / cg" |
611 | 1335 |
! |
1336 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1337 |
nextUnsignedLongNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1338 |
"return an unsigned long (4 bytes) in network byte order from the stream. |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1339 |
The receiver must support reading of binary bytes." |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1340 |
|
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1341 |
^ self nextUnsignedLongMSB:true |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1342 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1343 |
"Created: 10.1.1996 / 19:49:02 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1344 |
"Modified: 10.1.1996 / 19:49:50 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1345 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1346 |
|
611 | 1347 |
nextUnsignedShortMSB:msbFlag |
1348 |
"return an unsigned short (2 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1349 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1350 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1351 |
The msbFlag argument controls if the integer is to be read with |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1352 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1353 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1354 |
where its known that the byte order is some definite one. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1355 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1356 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1357 |
network byte order." |
611 | 1358 |
|
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1359 |
|b1 b2| |
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1360 |
|
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1361 |
b1 := self nextByte. |
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1362 |
b2 := self nextByte. |
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1363 |
|
611 | 1364 |
msbFlag ifTrue:[ |
9266
3563ddfd55d2
use nextByte to access bytes (for InternalStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
9070
diff
changeset
|
1365 |
^ (b1 bitShift:8) bitOr:b2 |
611 | 1366 |
]. |
6355
fb179369bd9f
#nextUnsignedLong:MSB: was wrong for lsb case
Claus Gittinger <cg@exept.de>
parents:
6348
diff
changeset
|
1367 |
^ (b2 bitShift:8) bitOr:b1 |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1368 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1369 |
"Modified: 11.7.1996 / 10:07:20 / cg" |
611 | 1370 |
! |
1371 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1372 |
nextUnsignedShortNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1373 |
"return an unsigned short (2 bytes) in network byte order from the stream. |
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1374 |
The receiver must support reading of binary bytes. |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1375 |
Network byte order is MSB per definition" |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1376 |
|
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1377 |
^ self nextUnsignedShortMSB:true |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1378 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1379 |
"Created: 10.1.1996 / 19:50:02 / cg" |
611 | 1380 |
! ! |
1381 |
||
1382 |
!Stream methodsFor:'non homogenous writing'! |
|
1383 |
||
1384 |
nextLongPut:aNumber |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1385 |
"for ST-80 compatibility: |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1386 |
Write the argument, aNumber as a long (four bytes). |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1387 |
The most significant byte is sent first." |
611 | 1388 |
|
1389 |
^ self nextPutLong:aNumber MSB:true |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1390 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1391 |
"Modified: 10.1.1996 / 19:38:54 / cg" |
611 | 1392 |
! |
1393 |
||
1394 |
nextNumber:n put:v |
|
1395 |
"Append to the receiver the argument, v, which is a positive Integer, |
|
1396 |
as the next n bytes. Bytes are written msb first. |
|
1397 |
Possibly pad with leading zeros. |
|
1398 |
The receiver must support writing of binary bytes." |
|
1399 |
||
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1400 |
|vlen "{ Class: SmallInteger }" |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1401 |
i "{ Class: SmallInteger }"| |
611 | 1402 |
|
1403 |
"claus: this method is central in binaryStorage - |
|
1404 |
therefore it has been tuned a bit (and needs even more tuning)" |
|
1405 |
||
1406 |
v class == SmallInteger ifTrue:[ "- this is a hint to stc" |
|
9407 | 1407 |
n == 1 ifTrue:[ |
1408 |
(v between:0 and:16rFF) ifTrue:[ |
|
1409 |
self nextPutByte:v. |
|
1410 |
^ self |
|
1411 |
]. |
|
1412 |
]. |
|
1413 |
n == 2 ifTrue:[ |
|
1414 |
(v between:0 and:16rFFFF) ifTrue:[ |
|
1415 |
self nextPutByte:(v bitShift:-8); nextPutByte:(v bitAnd:16rFF). |
|
1416 |
^ self |
|
1417 |
]. |
|
1418 |
]. |
|
1419 |
n == 3 ifTrue:[ |
|
1420 |
(v between:0 and:16rFFFFFF) ifTrue:[ |
|
1421 |
self nextPutByte:((v bitShift:-16) bitAnd:16rFF). |
|
1422 |
self nextPutByte:((v bitShift:-8) bitAnd:16rFF). |
|
1423 |
self nextPutByte:(v bitAnd:16rFF). |
|
1424 |
^ self |
|
1425 |
]. |
|
1426 |
]. |
|
1427 |
n == 4 ifTrue:[ |
|
1428 |
(v >= 0) ifTrue:[ |
|
1429 |
self nextPutByte:((v bitShift:-24) bitAnd:16rFF). |
|
1430 |
self nextPutByte:((v bitShift:-16) bitAnd:16rFF). |
|
1431 |
self nextPutByte:((v bitShift:-8) bitAnd:16rFF). |
|
1432 |
self nextPutByte:(v bitAnd:16rFF). |
|
1433 |
^ self |
|
1434 |
]. |
|
1435 |
]. |
|
611 | 1436 |
]. |
1437 |
||
1438 |
" |
|
1439 |
arbitrary long |
|
1440 |
" |
|
1441 |
n < (vlen := v digitLength) ifTrue: [ |
|
9407 | 1442 |
" |
1443 |
the number is too big to be repesented in n bytes |
|
1444 |
" |
|
1445 |
self error:'number too big' |
|
611 | 1446 |
]. |
1447 |
||
1448 |
"pad with leading zeros" |
|
1449 |
i := n. |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1450 |
[i > vlen] whileTrue:[ |
9407 | 1451 |
self nextPutByte:0. |
1452 |
i := i - 1 |
|
611 | 1453 |
]. |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1454 |
|
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1455 |
i == 1 ifTrue:[ |
9407 | 1456 |
^ self nextPutByte:v |
611 | 1457 |
]. |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1458 |
|
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1459 |
[i > 0] whileTrue:[ |
9407 | 1460 |
self nextPutByte:(v digitAt:i). |
1461 |
i := i - 1 |
|
611 | 1462 |
] |
9407 | 1463 |
|
1464 |
"Modified: / 22-06-2006 / 11:31:13 / fm" |
|
611 | 1465 |
! |
1466 |
||
15654 | 1467 |
nextPutAllUtf16:aString |
1468 |
"write a string as UTF-16 bytes" |
|
1469 |
||
17620 | 1470 |
|sz "{Class: SmallInteger}"| |
1471 |
||
1472 |
sz := aString size. |
|
1473 |
1 to:sz do:[:idx| |
|
1474 |
self nextPutUtf16:(aString at:idx). |
|
15654 | 1475 |
]. |
1476 |
! |
|
1477 |
||
11322 | 1478 |
nextPutAllUtf8:aString |
1479 |
"normal streams can not handle multi-byte characters, so convert them to utf8" |
|
1480 |
||
17620 | 1481 |
|sz "{Class: SmallInteger}"| |
1482 |
||
1483 |
sz := aString size. |
|
1484 |
1 to:sz do:[:idx| |
|
1485 |
self nextPutUtf8:(aString at:idx). |
|
11322 | 1486 |
]. |
1487 |
! |
|
1488 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1489 |
nextPutByte:aByteValue |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1490 |
"write a byte. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1491 |
Same as nextPut: here; for protocol compatibility with externalStream." |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1492 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1493 |
self nextPut:aByteValue |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1494 |
|
9407 | 1495 |
"Created: / 22-04-1997 / 10:43:55 / cg" |
1496 |
"Modified: / 23-06-2006 / 12:19:47 / fm" |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1497 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1498 |
|
12093 | 1499 |
nextPutBytes:anObject |
1500 |
"write bytes from an object; the number of bytes is defined by |
|
1501 |
the objects size. |
|
1502 |
Return the number of bytes written or nil on error. |
|
1503 |
The object must have non-pointer indexed instvars |
|
1504 |
(i.e. be a ByteArray, String, Float- or DoubleArray). |
|
1505 |
Use with care - non object oriented i/o. |
|
1506 |
Warning: in general, you cannot use this method to pass non-byte data to other |
|
1507 |
architectures since it does not care for byte order or float representation." |
|
1508 |
||
1509 |
^ self nextPutBytes:(anObject size) from:anObject startingAt:1 |
|
1510 |
||
1511 |
"Created: 22.4.1997 / 10:44:18 / cg" |
|
1512 |
! |
|
1513 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1514 |
nextPutBytes:count from:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1515 |
"write count bytes from an object. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1516 |
Return the number of bytes written or nil on error. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1517 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1518 |
(i.e. be a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1519 |
Use with care - non object oriented i/o. |
12093 | 1520 |
Warning: in general, you cannot use this method to pass non-byte data to other |
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1521 |
architectures since it does not care for byte order or float representation." |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1522 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1523 |
^ self nextPutBytes:count from:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1524 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1525 |
"Created: 22.4.1997 / 10:43:59 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1526 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1527 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1528 |
nextPutBytes:count from:anObject startingAt:start |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1529 |
"write count bytes from an object starting at index start. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1530 |
Return the number of bytes written. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1531 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1532 |
(i.e. be a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1533 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1534 |
This is provided for compatibility with externalStream; |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1535 |
to support binary storage" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1536 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1537 |
|idx| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1538 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1539 |
idx := start. |
7506 | 1540 |
self isBinary ifTrue:[ |
1541 |
1 to:count do:[:i | |
|
1542 |
self nextPutByte:(anObject byteAt:idx). |
|
1543 |
idx := idx + 1 |
|
1544 |
]. |
|
1545 |
] ifFalse:[ |
|
1546 |
1 to:count do:[:i | |
|
1547 |
self nextPut:(anObject at:idx). |
|
1548 |
idx := idx + 1 |
|
1549 |
]. |
|
1550 |
]. |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1551 |
^ count |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1552 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1553 |
"Created: 22.4.1997 / 10:44:09 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1554 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1555 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1556 |
nextPutBytesFrom:anObject |
12093 | 1557 |
"write bytes from an object; the number of bytes is defined by the objects size. |
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1558 |
Return the number of bytes written or nil on error. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1559 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1560 |
(i.e. be a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1561 |
Use with care - non object oriented i/o. |
12093 | 1562 |
Warning: in general, you cannot use this method to pass non-byte data to other |
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1563 |
architectures since it does not care for byte order or float representation." |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1564 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1565 |
^ self nextPutBytes:(anObject size) from:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1566 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1567 |
"Created: 22.4.1997 / 10:44:18 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1568 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
1569 |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1570 |
nextPutHyper:aNumber MSB:msbFlag |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1571 |
"Write the argument, aNumber as a hyper (8 bytes). |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1572 |
If msbFlag is true, data is written most-significant byte first; |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1573 |
otherwise least first. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1574 |
Returns the receiver on ok, nil on error. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1575 |
The receiver must support writing of binary bytes. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1576 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1577 |
This interface is provided to allow talking to external programs, |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1578 |
where its known that the byte order is some definite one. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1579 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1580 |
order, please use the corresponding xxxNet methods, which use a standard |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1581 |
network byte order." |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1582 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1583 |
msbFlag ifTrue:[ |
9407 | 1584 |
1 to:8 do:[:i | |
1585 |
self nextPutByte:(aNumber digitByteAt:8+1-i) |
|
1586 |
]. |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1587 |
] ifFalse:[ |
9407 | 1588 |
1 to:8 do:[:i | |
1589 |
self nextPutByte:(aNumber digitByteAt:i) |
|
1590 |
]. |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1591 |
]. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1592 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1593 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1594 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1595 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1596 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1597 |
s nextPutHyper:16r123456789abcdef0 MSB:false. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1598 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1599 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1600 |
(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1601 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1602 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1603 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1604 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1605 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1606 |
s nextPutHyper:16r123456789abcdef0 MSB:true. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1607 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1608 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1609 |
(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1610 |
. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1611 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1612 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1613 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1614 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1615 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1616 |
s nextPutHyper:16r-8000000000000000 MSB:true. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1617 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1618 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1619 |
(s nextHyperMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1620 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1621 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1622 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1623 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1624 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1625 |
s nextPutHyper:16r-8000000000000000 MSB:false. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1626 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1627 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1628 |
(s nextHyperMSB:false) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1629 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1630 |
|
9407 | 1631 |
"Modified: / 01-11-1997 / 18:30:52 / cg" |
1632 |
"Modified: / 22-06-2006 / 11:31:37 / fm" |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1633 |
! |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1634 |
|
11616
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1635 |
nextPutIEEEDouble:aFloat |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1636 |
"write an 8-byte IEEE double precision float number" |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1637 |
|
17628 | 1638 |
Float storeBinaryIEEEDouble:aFloat on:self MSB:(UninterpretedBytes isBigEndian) |
1639 |
! |
|
1640 |
||
17629 | 1641 |
nextPutIEEEDouble:aFloat MSB:msb |
17628 | 1642 |
"write an 8-byte IEEE double precision float number" |
1643 |
||
1644 |
Float storeBinaryIEEEDouble:aFloat on:self MSB:msb |
|
11616
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1645 |
! |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1646 |
|
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1647 |
nextPutIEEESingle:aFloat |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1648 |
"write a 4-byte IEEE single precision float number" |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1649 |
|
17628 | 1650 |
ShortFloat storeBinaryIEEESingle:aFloat on:self MSB:(UninterpretedBytes isBigEndian). |
1651 |
! |
|
1652 |
||
17629 | 1653 |
nextPutIEEESingle:aFloat MSB:msb |
17628 | 1654 |
"write a 4-byte IEEE single precision float number" |
1655 |
||
1656 |
ShortFloat storeBinaryIEEESingle:aFloat on:self MSB:msb. |
|
11616
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1657 |
! |
0ca41183ee3e
added IEESingle and IEEDouble readers and writers
Claus Gittinger <cg@exept.de>
parents:
11322
diff
changeset
|
1658 |
|
611 | 1659 |
nextPutLong:aNumber MSB:msbFlag |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1660 |
"Write the argument, aNumber as a long (four bytes). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1661 |
If msbFlag is true, data is written most-significant byte first; |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1662 |
otherwise least first. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1663 |
Returns the receiver on ok, nil on error. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1664 |
The receiver must support writing of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1665 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1666 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1667 |
where its known that the byte order is some definite one. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1668 |
If you dont care (i.e. talk to other smalltalks) or you can control the |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1669 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1670 |
network byte order." |
611 | 1671 |
|
5960 | 1672 |
|hh hl lh ll b1 b2 b3 b4| |
1673 |
||
1674 |
ll := aNumber digitByteAt:1. |
|
1675 |
lh := aNumber digitByteAt:2. |
|
1676 |
hl := aNumber digitByteAt:3. |
|
1677 |
hh := aNumber digitByteAt:4. |
|
611 | 1678 |
msbFlag ifTrue:[ |
9407 | 1679 |
"high byte first" |
1680 |
b1 := hh. |
|
1681 |
b2 := hl. |
|
1682 |
b3 := lh. |
|
1683 |
b4 := ll. |
|
2332 | 1684 |
] ifFalse:[ |
9407 | 1685 |
"low word first" |
1686 |
b1 := ll. |
|
1687 |
b2 := lh. |
|
1688 |
b3 := hl. |
|
1689 |
b4 := hh. |
|
611 | 1690 |
]. |
9407 | 1691 |
self nextPutByte:b1. |
1692 |
self nextPutByte:b2. |
|
1693 |
self nextPutByte:b3. |
|
1694 |
self nextPutByte:b4. |
|
5960 | 1695 |
|
1696 |
" |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1697 |
|s bytes| |
5960 | 1698 |
|
1699 |
s := #[] writeStream. |
|
1700 |
s nextPutLong:16r12345678 MSB:false. |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1701 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1702 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1703 |
(s nextLongMSB:false) hexPrintString. |
5960 | 1704 |
" |
1705 |
" |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1706 |
|s bytes| |
5960 | 1707 |
|
1708 |
s := #[] writeStream. |
|
1709 |
s nextPutLong:16r12345678 MSB:true. |
|
6360
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1710 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1711 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1712 |
(s nextLongMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1713 |
. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1714 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1715 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1716 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1717 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1718 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1719 |
s nextPutLong:16r-80000000 MSB:true. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1720 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1721 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1722 |
(s nextLongMSB:true) hexPrintString. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1723 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1724 |
" |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1725 |
|s bytes| |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1726 |
|
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1727 |
s := #[] writeStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1728 |
s nextPutLong:16r-80000000 MSB:false. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1729 |
bytes := s contents. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1730 |
s := bytes readStream. |
9bb87d3988c5
read/write of hypers (8byte ints)
Claus Gittinger <cg@exept.de>
parents:
6355
diff
changeset
|
1731 |
(s nextLongMSB:false) hexPrintString. |
5960 | 1732 |
" |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1733 |
|
9407 | 1734 |
"Modified: / 01-11-1997 / 18:30:52 / cg" |
1735 |
"Modified: / 22-06-2006 / 11:31:43 / fm" |
|
611 | 1736 |
! |
1737 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1738 |
nextPutLongNet:aNumber |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1739 |
"Write the argument, aNumber as a long (four bytes) in the network byte order. |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1740 |
Returns the receiver on ok, nil on error. |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1741 |
The receiver must support writing of binary bytes." |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1742 |
|
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1743 |
^ self nextPutLong:aNumber MSB:true |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1744 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1745 |
"Modified: 10.1.1996 / 19:47:10 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1746 |
"Created: 10.1.1996 / 19:50:23 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1747 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1748 |
|
15654 | 1749 |
nextPutShort:anIntegerOrCharacter MSB:msbFlag |
1750 |
"Write the argument, anIntegerOrCharacter as a short (two bytes). |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1751 |
If msbFlag is true, data is written most-significant byte first; |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1752 |
otherwise least first. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1753 |
Returns the receiver on ok, nil on error. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1754 |
The receiver must support writing of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1755 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1756 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1757 |
where its known that the byte order is some definite one. |
15654 | 1758 |
If you don't care (i.e. talk to other smalltalks) or you can control the |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1759 |
order, please use the corresponding xxxNet methods, which use a standard |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1760 |
network byte order." |
611 | 1761 |
|
2332 | 1762 |
|iNum "{ Class: SmallInteger }" hi lo b1 b2| |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
1763 |
|
15654 | 1764 |
iNum := anIntegerOrCharacter asInteger. |
5960 | 1765 |
lo := iNum digitByteAt:1. |
1766 |
hi := iNum digitByteAt:2. |
|
611 | 1767 |
msbFlag ifTrue:[ |
9407 | 1768 |
"high word first" |
1769 |
b1 := hi. |
|
1770 |
b2 := lo. |
|
2332 | 1771 |
] ifFalse:[ |
9407 | 1772 |
"low word first" |
1773 |
b1 := lo. |
|
1774 |
b2 := hi. |
|
611 | 1775 |
]. |
9407 | 1776 |
self nextPutByte:b1. |
1777 |
self nextPutByte:b2. |
|
5960 | 1778 |
|
1779 |
" |
|
1780 |
|s| |
|
1781 |
||
1782 |
s := #[] writeStream. |
|
1783 |
s nextPutShort:16r1234 MSB:false. |
|
1784 |
s contents. |
|
1785 |
" |
|
1786 |
" |
|
1787 |
|s| |
|
1788 |
||
1789 |
s := #[] writeStream. |
|
1790 |
s nextPutShort:16r1234 MSB:true. |
|
1791 |
s contents. |
|
1792 |
" |
|
9407 | 1793 |
|
1794 |
"Modified: / 22-06-2006 / 11:30:26 / fm" |
|
611 | 1795 |
! |
1796 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1797 |
nextPutShortNet:aNumber |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1798 |
"Write the argument, aNumber as a short (two bytes) in the network byte order. |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1799 |
Returns the receiver on ok, nil on error. |
8894
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1800 |
The receiver must support writing of binary bytes. |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1801 |
Network byte order is MSB per definition" |
63cd83aa44e8
No need to ask Socket>>#networkXXXOrderIsMSB, because the return value is
Stefan Vogel <sv@exept.de>
parents:
8815
diff
changeset
|
1802 |
|
8970 | 1803 |
^ self nextPutShort:aNumber MSB:true. |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1804 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1805 |
"Created: 10.1.1996 / 19:50:33 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1806 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1807 |
|
15652 | 1808 |
nextPutUtf16:aCharacter |
1809 |
"append my UTF-16 representation to the argument, aStream. |
|
15654 | 1810 |
UTF-16 can encode only characters with code points between 0 to 16r10FFFF. |
1811 |
The collection must be able to store 2-byte values (TwoByteString, OrderedCollection)" |
|
1812 |
||
17620 | 1813 |
|codePoint "{Class: SmallInteger}"| |
15654 | 1814 |
|
1815 |
codePoint := aCharacter codePoint. |
|
1816 |
(codePoint <= 16rD7FF |
|
1817 |
or:[codePoint >= 16rE000 and:[codePoint <= 16rFFFF]]) ifTrue:[ |
|
1818 |
self nextPut:aCharacter. |
|
1819 |
] ifFalse:[codePoint <= 16r10FFFF ifTrue:[ |
|
1820 |
|highBits lowBits| |
|
1821 |
||
1822 |
codePoint := codePoint - 16r100000. |
|
1823 |
highBits := codePoint bitShift:-10. |
|
1824 |
lowBits := codePoint bitAnd:16r3FF. |
|
1825 |
self nextPut:(Character codePoint:highBits+16rD800). |
|
1826 |
self nextPut:(Character codePoint:lowBits+16rDC00). |
|
1827 |
] ifFalse:[ |
|
1828 |
EncodingError raiseWith:aCharacter errorString:'Character cannot be encoded as UTF-16'. |
|
1829 |
]]. |
|
1830 |
||
1831 |
" |
|
1832 |
((WriteStream on:Unicode16String new) |
|
1833 |
nextPutUtf16:$B; |
|
17610 | 1834 |
nextPutUtf16:$Ä; |
15654 | 1835 |
nextPutUtf16:(Character codePoint:16r10CCCC) |
1836 |
yourself) contents |
|
1837 |
" |
|
15652 | 1838 |
! |
1839 |
||
11322 | 1840 |
nextPutUtf8:aCharacter |
1841 |
"append my UTF-8 representation to the argument, aStream. |
|
1842 |
Up to 31 bits can be encoded in up to 6 bytes. |
|
14593 | 1843 |
However, currently, characters are limited to 31 bits." |
11322 | 1844 |
|
17620 | 1845 |
|codePoint "{Class: SmallInteger}" |
1846 |
v "{Class: SmallInteger}" |
|
1847 |
b1 b2 b3 b4 b5| |
|
11322 | 1848 |
|
1849 |
codePoint := aCharacter codePoint. |
|
1850 |
||
1851 |
codePoint <= 16r7F ifTrue:[ |
|
1852 |
self nextPut:aCharacter. |
|
1853 |
^ self. |
|
1854 |
]. |
|
1855 |
||
1856 |
b1 := Character codePoint:((codePoint bitAnd:16r3F) bitOr:2r10000000). |
|
1857 |
v := codePoint bitShift:-6. |
|
1858 |
v <= 16r1F ifTrue:[ |
|
1859 |
self nextPut:(Character value:(v bitOr:2r11000000)). |
|
1860 |
self nextPut:b1. |
|
1861 |
^ self. |
|
1862 |
]. |
|
1863 |
b2 := Character codePoint:((v bitAnd:16r3F) bitOr:2r10000000). |
|
1864 |
v := v bitShift:-6. |
|
1865 |
v <= 16r0F ifTrue:[ |
|
1866 |
self nextPut:(Character value:(v bitOr:2r11100000)). |
|
1867 |
self nextPut:b2; nextPut:b1. |
|
1868 |
^ self. |
|
1869 |
]. |
|
1870 |
b3 := Character codePoint:((v bitAnd:16r3F) bitOr:2r10000000). |
|
1871 |
v := v bitShift:-6. |
|
1872 |
v <= 16r07 ifTrue:[ |
|
1873 |
self nextPut:(Character value:(v bitOr:2r11110000)). |
|
1874 |
self nextPut:b3; nextPut:b2; nextPut:b1. |
|
1875 |
^ self. |
|
1876 |
]. |
|
1877 |
b4 := Character codePoint:((v bitAnd:16r3F) bitOr:2r10000000). |
|
1878 |
v := v bitShift:-6. |
|
1879 |
v <= 16r03 ifTrue:[ |
|
1880 |
self nextPut:(Character value:(v bitOr:2r11111000)). |
|
1881 |
self nextPut:b4; nextPut:b3; nextPut:b2; nextPut:b1. |
|
1882 |
^ self. |
|
1883 |
]. |
|
1884 |
b5 := Character codePoint:((v bitAnd:16r3F) bitOr:2r10000000). |
|
1885 |
v := v bitShift:-6. |
|
1886 |
v <= 16r01 ifTrue:[ |
|
1887 |
self nextPut:(Character value:(v bitOr:2r11111100)). |
|
1888 |
self nextPut:b5; nextPut:b4; nextPut:b3; nextPut:b2; nextPut:b1. |
|
1889 |
^ self. |
|
1890 |
]. |
|
1891 |
||
17620 | 1892 |
EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'. |
11322 | 1893 |
|
1894 |
" |
|
1895 |
(String streamContents:[:s| |
|
1896 |
s nextPutUtf8:$a. |
|
17610 | 1897 |
s nextPutUtf8:$ü. |
11322 | 1898 |
s nextPutUtf8: (Character value:16r1fff). |
1899 |
s nextPutUtf8: (Character value:16rffff). |
|
14593 | 1900 |
s nextPutUtf8: (Character value:16r1ffffff). |
11322 | 1901 |
s nextPutUtf8: (Character value:16r800). |
1902 |
]) |
|
1903 |
asByteArray |
|
1904 |
||
1905 |
" |
|
1906 |
! |
|
1907 |
||
611 | 1908 |
nextPutWord:aNumber |
1909 |
"write the argument, aNumber as a signed short (two bytes); |
|
1910 |
write msb-first for compatibility with other smalltalks. |
|
1911 |
The receiver must support writing of binary bytes. |
|
1912 |
I dont know if it should be named nextPutWord: or nextWordPut:; |
|
1913 |
one of them will vanish ..." |
|
1914 |
||
1915 |
^ self nextPutShort:aNumber MSB:true |
|
1916 |
! |
|
1917 |
||
9407 | 1918 |
nextTwoBytesPut: anInteger |
15397 | 1919 |
<resource: #obsolete> |
9407 | 1920 |
"Write anInteger as the next two bytes of the |
1921 |
receiver stream." |
|
15397 | 1922 |
|
1923 |
self obsoleteMethodWarning:'use #nextPutShort:MSB:'. |
|
1924 |
||
9407 | 1925 |
self |
1926 |
nextPutByte: (anInteger bitAnd: 255); |
|
1927 |
nextPutByte: ((anInteger bitShift: -8) bitAnd: 255) |
|
1928 |
||
1929 |
"Created: / 21-06-2006 / 19:42:10 / fm" |
|
1930 |
! |
|
1931 |
||
611 | 1932 |
nextWordPut:aNumber |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1933 |
"for ST-80 compatibility: |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1934 |
Write the argument, aNumber as a short (two bytes). |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1935 |
The most significant byte is sent first." |
611 | 1936 |
|
1937 |
^ self nextPutShort:aNumber MSB:true |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1938 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
1939 |
"Modified: 10.1.1996 / 19:39:19 / cg" |
611 | 1940 |
! ! |
1941 |
||
16454 | 1942 |
!Stream methodsFor:'open / close'! |
1943 |
||
1944 |
close |
|
1945 |
"close the stream - nothing done here. |
|
1946 |
Added for compatibility with external streams." |
|
1947 |
||
1948 |
^ self |
|
1949 |
! ! |
|
1950 |
||
611 | 1951 |
!Stream methodsFor:'private'! |
1952 |
||
1953 |
contentsSpecies |
|
1954 |
"this should return the class of which an instance is |
|
1403 | 1955 |
returned by the #contents method. Here, Array is returned, |
1956 |
since the abstract Stream-class has no idea of the underlying |
|
1957 |
collection class. |
|
1958 |
It is redefined in some subclasses - for example, to return String." |
|
611 | 1959 |
|
1960 |
^ Array |
|
1403 | 1961 |
|
1962 |
"Modified: 15.5.1996 / 17:53:31 / cg" |
|
611 | 1963 |
! ! |
1964 |
||
1965 |
!Stream methodsFor:'queries'! |
|
1966 |
||
16472 | 1967 |
canReadWithoutBlocking |
18394 | 1968 |
"return true, if the stream can be read without blocking the program (actually: suspending the thread). |
1969 |
This is redefined in external streams, which read from a communication line |
|
1970 |
(sockets and devices). |
|
1971 |
Always true here, because all internal streams never block" |
|
1972 |
||
16472 | 1973 |
^ true |
1974 |
! |
|
1975 |
||
1976 |
canWriteWithoutBlocking |
|
18394 | 1977 |
"return true, if the stream can be written without blocking the program (actually: suspending the thread). |
1978 |
This is redefined in external streams, which write to a communication line |
|
1979 |
(sockets and devices). |
|
1980 |
Always true here, because all internal streams never block" |
|
1981 |
||
16472 | 1982 |
^ true |
1983 |
! |
|
1984 |
||
15719 | 1985 |
current |
1986 |
"for compatibility with Transcript - allow Transcript current, |
|
1987 |
even if redirected to the standardError" |
|
1988 |
||
1989 |
self == Transcript ifTrue:[ |
|
1990 |
^ self |
|
1991 |
]. |
|
1992 |
"/ this will raise an DNU error, usually. |
|
1993 |
^ super current |
|
1994 |
||
1995 |
"Modified (comment): / 29-08-2013 / 11:09:21 / cg" |
|
1996 |
! |
|
1997 |
||
15590 | 1998 |
inputStream |
1999 |
"return the receiver. |
|
2000 |
for compatibility with filtering streams" |
|
2001 |
||
2002 |
self isReadable ifFalse:[ ^ nil ]. |
|
2003 |
^ self |
|
2004 |
! |
|
2005 |
||
611 | 2006 |
isBinary |
1403 | 2007 |
"return true, if in binary mode. Always returns false here, |
2008 |
to make internalStreams protocol compatible with externalStreams." |
|
611 | 2009 |
|
7503 | 2010 |
^ self contentsSpecies == ByteArray |
1403 | 2011 |
|
2012 |
"Modified: 15.5.1996 / 17:53:51 / cg" |
|
611 | 2013 |
! |
2014 |
||
11948 | 2015 |
isOpen |
2016 |
"for compatibility with externalStream: |
|
2017 |
return true, if this stream is open." |
|
2018 |
||
2019 |
^ true |
|
2020 |
! |
|
2021 |
||
611 | 2022 |
isReadable |
2023 |
"return true, if reading is supported by the recevier. |
|
1403 | 2024 |
This has to be redefined in concrete subclasses." |
611 | 2025 |
|
2026 |
^ self subclassResponsibility |
|
1403 | 2027 |
|
2028 |
"Modified: 15.5.1996 / 17:54:31 / cg" |
|
611 | 2029 |
! |
2030 |
||
2031 |
isWritable |
|
2032 |
"return true, if writing is supported by the recevier. |
|
1403 | 2033 |
This has to be redefined in concrete subclasses." |
611 | 2034 |
|
2035 |
^ self subclassResponsibility |
|
1403 | 2036 |
|
2037 |
"Modified: 15.5.1996 / 17:54:54 / cg" |
|
611 | 2038 |
! |
2039 |
||
2040 |
lineLength |
|
1403 | 2041 |
"return the lineLength which `looks good' when pretty printed |
2042 |
text is sent to this stream. |
|
2043 |
This has NO meaning whatsoever to regular streams; |
|
2044 |
however, it may be used as a layout hint for prettyprinting functions |
|
2045 |
- for compatibility with TextCollectors, which returns its views actual |
|
2046 |
line length, and allows the prettyprinter to wrap at that position." |
|
611 | 2047 |
|
2048 |
^ 80 |
|
1403 | 2049 |
|
2050 |
"Modified: 15.5.1996 / 17:57:01 / cg" |
|
3493
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2051 |
! |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2052 |
|
5395 | 2053 |
lineNumber |
15591 | 2054 |
"return the current lineNumber if known |
2055 |
(for compatibility with LineNumberReadStream)" |
|
5395 | 2056 |
|
2057 |
^ nil |
|
2058 |
! |
|
2059 |
||
8645 | 2060 |
numberOfTerminalCols |
2061 |
^ self lineLength |
|
2062 |
! |
|
2063 |
||
2064 |
numberOfTerminalLines |
|
2065 |
^ 24 |
|
2066 |
! |
|
2067 |
||
15590 | 2068 |
outputStream |
2069 |
"return the receiver. |
|
2070 |
for compatibility with filtering streams" |
|
2071 |
||
2072 |
self isWritable ifFalse:[ ^ nil ]. |
|
2073 |
^ self |
|
2074 |
! |
|
2075 |
||
3493
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2076 |
pageFormat |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2077 |
"return the pageFormat - nil here. |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2078 |
This has NO meaning whatsoever to regular streams; |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2079 |
however, it has been added for protocol compatibility with printerStreams" |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2080 |
|
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2081 |
^ nil |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2082 |
|
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2083 |
"Modified: / 15.5.1996 / 17:57:01 / cg" |
87864e021c20
added #pageFormat for printerStream protocol compatibility.
Claus Gittinger <cg@exept.de>
parents:
3462
diff
changeset
|
2084 |
"Created: / 29.5.1998 / 16:57:48 / cg" |
8645 | 2085 |
! |
2086 |
||
14303 | 2087 |
size |
2088 |
"return the number of elements in the streamed collection." |
|
2089 |
||
2090 |
self subclassResponsibility |
|
2091 |
||
2092 |
"Created: / 05-08-2012 / 18:38:12 / cg" |
|
2093 |
! |
|
2094 |
||
8645 | 2095 |
terminalType |
2096 |
^ 'dump' |
|
611 | 2097 |
! ! |
2098 |
||
62 | 2099 |
!Stream methodsFor:'reading'! |
1 | 2100 |
|
2101 |
next |
|
2102 |
"return the next element of the stream |
|
2103 |
- we do not know here how to do it, it must be redefined in subclass" |
|
2104 |
||
2105 |
^ self subclassResponsibility |
|
2106 |
! |
|
2107 |
||
2108 |
next:count |
|
1403 | 2109 |
"return the next count elements of the stream as aCollection, |
2110 |
which depends on the streams type - (see #contentsSpecies)." |
|
1 | 2111 |
|
329 | 2112 |
|answerStream |
285 | 2113 |
cnt "{ Class: SmallInteger }" | |
1 | 2114 |
|
285 | 2115 |
cnt := count. |
7467 | 2116 |
answerStream := WriteStream on:(self contentsSpecies new:cnt). |
12426 | 2117 |
1 to:cnt do:[:index | |next| |
2118 |
next := self next. |
|
2119 |
next isNil ifTrue:[ |
|
2120 |
"if next did not raise EndOfStreamError, we have to do it" |
|
2121 |
EndOfStreamError raiseRequestFrom:self. |
|
12623 | 2122 |
"if you proceed, you get what we have already collected" |
2123 |
^ answerStream contents |
|
12426 | 2124 |
]. |
2125 |
answerStream nextPut:next. |
|
1 | 2126 |
]. |
329 | 2127 |
^ answerStream contents |
1 | 2128 |
|
275 | 2129 |
" |
2130 |
(ReadStream on:#(1 2 3 4 5)) next:3 |
|
2131 |
(ReadStream on:'hello') next:3 |
|
2132 |
" |
|
1403 | 2133 |
|
2134 |
"Modified: 15.5.1996 / 17:57:58 / cg" |
|
1 | 2135 |
! |
2136 |
||
7467 | 2137 |
next:count into:aWriteStream |
2138 |
"put the next count elements of the stream into aWriteStream" |
|
2139 |
||
2140 |
|cnt "{ Class: SmallInteger }" | |
|
2141 |
||
2142 |
cnt := count. |
|
12426 | 2143 |
1 to:cnt do:[:index | |next| |
2144 |
next := self next. |
|
2145 |
next isNil ifTrue:[ |
|
2146 |
"if next did not raise EndOfStreamError, we have to do it" |
|
2147 |
EndOfStreamError raiseRequestFrom:self. |
|
2148 |
]. |
|
2149 |
aWriteStream nextPut:next. |
|
7467 | 2150 |
]. |
2151 |
||
2152 |
" |
|
2153 |
|writeStream| |
|
2154 |
writeStream := #() writeStream. |
|
2155 |
#(1 2 3 4 5) readStream next:3 into:writeStream. |
|
2156 |
writeStream contents. |
|
2157 |
||
2158 |
|writeStream| |
|
2159 |
writeStream := '' writeStream. |
|
2160 |
'hello' readStream next:3 into:writeStream. |
|
2161 |
writeStream contents. |
|
2162 |
" |
|
2163 |
||
2164 |
"Modified: 15.5.1996 / 17:57:58 / cg" |
|
2165 |
! |
|
2166 |
||
17610 | 2167 |
next:numObjects into:aCollection startingAt:initialIndex |
2168 |
"return the next numObjects from the stream." |
|
2169 |
||
2170 |
|n "{Class: SmallInteger }"| |
|
2171 |
||
2172 |
n := 0. |
|
2173 |
||
2174 |
[n ~~ numObjects] whileTrue:[ |
|
2175 |
self atEnd ifTrue:[ |
|
2176 |
^ aCollection copyFrom:1 to:initialIndex+n-1. |
|
2177 |
]. |
|
2178 |
aCollection at:(initialIndex + n) put:self next. |
|
2179 |
n := n + 1. |
|
2180 |
]. |
|
2181 |
^ aCollection. |
|
2182 |
||
2183 |
" |
|
2184 |
|s n buffer| |
|
2185 |
||
2186 |
buffer := Array new:10. |
|
2187 |
||
2188 |
s := ReadStream on:#(1 2 3 4 5 6 7 8 9). |
|
2189 |
s next:3. |
|
2190 |
n := s next:9 into:buffer startingAt:2. |
|
2191 |
Transcript showCR:('n = %1; buffer = %2' bindWith:n with:buffer) |
|
2192 |
" |
|
2193 |
||
2194 |
"Modified: 22.4.1997 / 10:43:08 / cg" |
|
2195 |
! |
|
2196 |
||
285 | 2197 |
nextAvailable:count |
1403 | 2198 |
"return the next count elements of the stream as aCollection. |
285 | 2199 |
If the stream reaches the end before count elements have been read, |
1403 | 2200 |
return what is available. (i.e. a shorter collection). |
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
2201 |
The type of collection is specified in #contentsSpecies." |
285 | 2202 |
|
345 | 2203 |
|answerStream |
285 | 2204 |
cnt "{ Class: SmallInteger }"| |
2205 |
||
2206 |
cnt := count. |
|
10358
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2207 |
answerStream := WriteStream on:(self contentsSpecies new:cnt). |
285 | 2208 |
1 to:cnt do:[:index | |
10358
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2209 |
self atEnd ifTrue:[ |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2210 |
^ answerStream contents |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2211 |
]. |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2212 |
answerStream nextPut:(self next) |
285 | 2213 |
]. |
329 | 2214 |
^ answerStream contents |
285 | 2215 |
|
2216 |
" |
|
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
2217 |
(ReadStream on:#(1 2 3 4 5)) nextAvailable:3 |
285 | 2218 |
(ReadStream on:#(1 2 3 4 5)) nextAvailable:10 |
2219 |
(ReadStream on:'hello') nextAvailable:3 |
|
2220 |
(ReadStream on:'hello') nextAvailable:10 |
|
2221 |
" |
|
1403 | 2222 |
|
3590
d22de87c7fbd
removed endOfStreamQuery - instead, handle unhandled exception
Claus Gittinger <cg@exept.de>
parents:
3586
diff
changeset
|
2223 |
"Modified: / 16.6.1998 / 15:52:41 / cg" |
285 | 2224 |
! |
2225 |
||
17610 | 2226 |
nextAvailable:numObjects into:aCollection startingAt:initialIndex |
2227 |
"return the next numObjects from the stream." |
|
2228 |
||
2229 |
|n "{Class: SmallInteger }"| |
|
2230 |
||
2231 |
n := 0. |
|
2232 |
||
2233 |
[n ~= numObjects and:[self atEnd not]] whileTrue:[ |
|
2234 |
aCollection at:(initialIndex + n) put:self next. |
|
2235 |
n := n + 1. |
|
2236 |
]. |
|
2237 |
^ n. |
|
2238 |
! |
|
2239 |
||
1 | 2240 |
nextMatchFor:anObject |
62 | 2241 |
"read an element from the receiver, return true if it was equal to |
1403 | 2242 |
the argument, anObject; false otherwise." |
62 | 2243 |
|
2244 |
^ (self next = anObject) |
|
2245 |
||
2246 |
" |
|
2247 |
|s| |
|
2248 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2249 |
s nextMatchFor:2 |
|
2250 |
" |
|
2251 |
" |
|
2252 |
|s| |
|
2253 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2254 |
s nextMatchFor:2. |
|
2255 |
s nextMatchFor:2 |
|
2256 |
" |
|
1403 | 2257 |
|
2258 |
"Modified: 15.5.1996 / 17:58:57 / cg" |
|
62 | 2259 |
! |
2260 |
||
6862 | 2261 |
nextOrNil |
2262 |
"like #next, this returns the next element, if available. |
|
7118 | 2263 |
If nothing is available, this does never raise a read-beyond end signal. |
6862 | 2264 |
Instead, nil is returned immediately." |
2265 |
||
2266 |
self atEnd ifTrue:[^ nil]. |
|
2267 |
^ self next |
|
2268 |
! |
|
2269 |
||
7242 | 2270 |
skip:numberToSkip |
2271 |
"skip numberToSkip objects, return the receiver" |
|
345 | 2272 |
|
16208 | 2273 |
"don't know how to unread ..." |
7242 | 2274 |
numberToSkip < 0 ifTrue:[ |
8309 | 2275 |
PositionError raiseRequest. |
7242 | 2276 |
^ self |
62 | 2277 |
]. |
16208 | 2278 |
numberToSkip timesRepeat:[self next] |
62 | 2279 |
|
2280 |
" |
|
2281 |
|s| |
|
2282 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2283 |
s skip:4. |
|
2284 |
s next |
|
2285 |
" |
|
4467 | 2286 |
|
2287 |
"Modified: / 30.7.1999 / 12:12:10 / cg" |
|
62 | 2288 |
! |
2289 |
||
2290 |
skipFor:anObject |
|
1403 | 2291 |
"skip all objects up-to and including anObject; |
15639 | 2292 |
read and return the element after anObject." |
62 | 2293 |
|
2294 |
(self skipThrough:anObject) notNil ifTrue:[ |
|
15639 | 2295 |
^ self next |
62 | 2296 |
]. |
2297 |
^ nil |
|
2298 |
||
2299 |
" |
|
15639 | 2300 |
|s next rest| |
62 | 2301 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
15639 | 2302 |
next := s skipFor:4. |
2303 |
rest := s upToEnd. |
|
6010 | 2304 |
" |
2305 |
" |
|
15639 | 2306 |
|s next rest| |
6010 | 2307 |
s := ReadStream on:'12345678'. |
15639 | 2308 |
next := s skipFor:$4. |
2309 |
rest := s upToEnd. |
|
62 | 2310 |
" |
1403 | 2311 |
|
2312 |
"Modified: 15.5.1996 / 17:59:23 / cg" |
|
62 | 2313 |
! |
2314 |
||
10360
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2315 |
skipLine |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2316 |
"read the next line (characters up to newline) skip only; |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2317 |
return nil if EOF reached, self otherwise. |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2318 |
Not allowed in binary mode." |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2319 |
|
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2320 |
^ self skipThrough:Character cr |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2321 |
! |
f8a5e7c8c8d8
new: #skipLine (was only in ExternalStream)
Stefan Vogel <sv@exept.de>
parents:
10359
diff
changeset
|
2322 |
|
62 | 2323 |
skipThrough:anObject |
6010 | 2324 |
"skip all objects up-to and including anObject. |
2325 |
Return the receiver if skip was successful, |
|
2326 |
otherwise (i.e. if not found) return nil and leave the stream positioned at the end. |
|
62 | 2327 |
The next read operation will return the element after anObject." |
1 | 2328 |
|
2329 |
|nextElement| |
|
2330 |
||
10358
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2331 |
[ |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2332 |
nextElement := self nextOrNil. |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2333 |
(nextElement isNil and:[self atEnd]) ifTrue:[ |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2334 |
^ nil. |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2335 |
]. |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2336 |
nextElement = anObject |
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2337 |
] whileFalse. |
2 | 2338 |
|
62 | 2339 |
" |
2340 |
|s| |
|
10358
5a679e45aeaa
Speed up #nextAvailable: and #skipThrough:
Stefan Vogel <sv@exept.de>
parents:
10181
diff
changeset
|
2341 |
s := ReadStream on:#(1 nil 2 3 4 5 6 7 8). |
62 | 2342 |
s skipThrough:4. |
2343 |
s next |
|
2344 |
" |
|
6010 | 2345 |
" |
2346 |
|s| |
|
2347 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2348 |
s skipThrough:4. |
|
2349 |
s skipThrough:4. |
|
2350 |
s next |
|
2351 |
" |
|
2352 |
" |
|
2353 |
|s| |
|
2354 |
s := ReadStream on:'12345678'. |
|
2355 |
s skipThrough:$4. |
|
2356 |
s next |
|
2357 |
" |
|
2358 |
" |
|
2359 |
|s| |
|
2360 |
s := ReadStream on:'12345678'. |
|
2361 |
s skipThrough:$4. |
|
2362 |
s skipThrough:$4. |
|
2363 |
s next |
|
2364 |
" |
|
2365 |
" |
|
2366 |
|s| |
|
2367 |
s := ReadStream on:'12345678'. |
|
2368 |
s skipThrough:$4. |
|
2369 |
s skipThrough:$4. |
|
2370 |
s atEnd |
|
2371 |
" |
|
77 | 2372 |
! |
2373 |
||
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2374 |
skipThroughAll:aCollection |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2375 |
"skip for and through the sequence given by the argument, aCollection; |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2376 |
return nil if not found, the receiver otherwise. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2377 |
On a successful match, the next read will return elements after aCollection; |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2378 |
if no match was found, the receiver will be positioned at the end." |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2379 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2380 |
|buffer l first idx| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2381 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2382 |
l := aCollection size. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2383 |
first := aCollection at:1. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2384 |
[self atEnd] whileFalse:[ |
2332 | 2385 |
buffer isNil ifTrue:[ |
2386 |
buffer := self nextAvailable:l. |
|
2387 |
]. |
|
2388 |
buffer = aCollection ifTrue:[ |
|
2389 |
^ self |
|
2390 |
]. |
|
2391 |
idx := buffer indexOf:first startingAt:2. |
|
2392 |
idx == 0 ifTrue:[ |
|
2393 |
buffer := nil |
|
2394 |
] ifFalse:[ |
|
2395 |
buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1)) |
|
2396 |
] |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2397 |
]. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2398 |
^ nil |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2399 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2400 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2401 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2402 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2403 |
s skipThroughAll:'901'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2404 |
s upToEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2405 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2406 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2407 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2408 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2409 |
s skipThroughAll:'1234'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2410 |
s upToEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2411 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2412 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2413 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2414 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2415 |
s skipThroughAll:'999'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2416 |
s atEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2417 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2418 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2419 |
"Created: 11.1.1997 / 18:55:13 / cg" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2420 |
"Modified: 11.1.1997 / 19:09:06 / cg" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2421 |
! |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2422 |
|
15639 | 2423 |
skipUntil:aBlock |
2424 |
"skip all elements for which aBlock returns false. |
|
2425 |
Return true if more elements can be read, false if eof has been reached." |
|
2426 |
||
2427 |
[self atEnd] whileFalse:[ |
|
2428 |
(aBlock value: self peek) ifTrue:[^ true]. |
|
2429 |
self next |
|
2430 |
]. |
|
2431 |
^ false |
|
2432 |
||
2433 |
" |
|
2434 |
#(1 2 3 4 5 6 7 8 9 10) readStream |
|
2435 |
skipUntil:[:el | el >= 5]; |
|
2436 |
next |
|
2437 |
" |
|
2438 |
! |
|
2439 |
||
2440 |
skipWhile:aBlock |
|
2441 |
"skip all elements for which aBlock returns true. Return true if more elements can be read, |
|
2442 |
false if eof has been reached." |
|
2443 |
||
2444 |
[self atEnd] whileFalse:[ |
|
2445 |
(aBlock value: self peek) ifFalse:[^ true]. |
|
2446 |
self next |
|
2447 |
]. |
|
2448 |
^ false |
|
2449 |
||
2450 |
" |
|
2451 |
#(1 2 3 4 5 6 7 8 9 10) readStream |
|
2452 |
skipWhile:[:el | el <= 5]; |
|
2453 |
next |
|
2454 |
" |
|
2455 |
||
2456 |
"Created: / 23-09-2011 / 13:32:40 / cg" |
|
2457 |
! |
|
2458 |
||
611 | 2459 |
through:anObject |
2460 |
"read a collection of all objects up-to anObject and return these |
|
2461 |
elements, including anObject. |
|
2462 |
The next read operation will return the element after anObject. |
|
1409 | 2463 |
If anObject is not encountered, all elements up to the end are read |
2464 |
and returned. |
|
611 | 2465 |
Compare this with #upTo: which also reads up to some object |
2466 |
and also positions behind it, but does not include it in the returned |
|
2467 |
value." |
|
2468 |
||
2469 |
|answerStream element| |
|
2470 |
||
2471 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2472 |
[self atEnd] whileFalse:[ |
|
2332 | 2473 |
element := self next. |
2474 |
answerStream nextPut:element. |
|
2475 |
(element = anObject) ifTrue: [ |
|
2476 |
^ answerStream contents |
|
2477 |
] |
|
611 | 2478 |
]. |
2479 |
^ answerStream contents |
|
2480 |
||
2481 |
" |
|
2482 |
|s| |
|
2483 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 2484 |
Transcript showCR:(s through:4). |
2485 |
Transcript showCR:s next |
|
1409 | 2486 |
|
2487 |
|s| |
|
2488 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 2489 |
Transcript showCR:(s through:9). |
2490 |
Transcript showCR:s next |
|
1409 | 2491 |
|
611 | 2492 |
|s| |
2493 |
s := ReadStream on:'hello world'. |
|
1422 | 2494 |
Transcript showCR:(s through:Character space). |
2495 |
Transcript showCR:(s upToEnd) |
|
611 | 2496 |
" |
1409 | 2497 |
|
2498 |
"Modified: 17.5.1996 / 08:51:40 / cg" |
|
611 | 2499 |
! |
2500 |
||
1548 | 2501 |
throughAll:aCollection |
2502 |
"read & return a collection of all objects up-to and including |
|
2503 |
a subcollection given by aCollection. |
|
2504 |
(i.e. read until a ``substring'' is encountered.) |
|
2505 |
The next read operation will return the element after aCollection. |
|
2506 |
If aCollection is not encountered, all elements up to the end are read |
|
2507 |
and returned." |
|
2508 |
||
2509 |
|answerStream element last rslt| |
|
2510 |
||
2511 |
last := aCollection last. |
|
2512 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2513 |
[self atEnd] whileFalse:[ |
|
2332 | 2514 |
element := self next. |
2515 |
answerStream nextPut:element. |
|
2516 |
element == last ifTrue:[ |
|
2517 |
((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
|
2518 |
^ rslt |
|
2519 |
] |
|
2520 |
]. |
|
1548 | 2521 |
]. |
2522 |
^ answerStream contents |
|
2523 |
||
2524 |
" |
|
2525 |
|s| |
|
2526 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2527 |
Transcript showCR:(s throughAll:#(4 4 4)). |
|
2528 |
Transcript showCR:s next |
|
2529 |
||
2530 |
|s| |
|
2531 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
2532 |
Transcript showCR:(s throughAll:#(4 5 6)). |
|
2533 |
Transcript showCR:s next |
|
2534 |
||
2535 |
|s| |
|
2536 |
s := ReadStream on:'hello world, this is some text'. |
|
2537 |
Transcript showCR:(s throughAll:'world'). |
|
2538 |
Transcript showCR:(s throughAll:'some'). |
|
2539 |
Transcript showCR:s upToEnd. |
|
2540 |
" |
|
2541 |
||
2542 |
"Modified: 15.7.1996 / 09:08:07 / cg" |
|
2543 |
! |
|
2544 |
||
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2545 |
throughAny:aCollection |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2546 |
"read & return a collection of all objects up-to and including |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2547 |
an element contained in aCollection. |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2548 |
(i.e. read until any from aCollection is encountered.) |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2549 |
If no such character is encountered, all elements up to the end are read |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2550 |
and returned." |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2551 |
|
9070 | 2552 |
|answerStream element| |
2553 |
||
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2554 |
answerStream := WriteStream on:(self contentsSpecies new). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2555 |
[self atEnd] whileFalse:[ |
9070 | 2556 |
element := self next. |
2557 |
answerStream nextPut:element. |
|
2558 |
(aCollection includes:element) ifTrue:[ |
|
2559 |
^ answerStream contents |
|
2560 |
]. |
|
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2561 |
]. |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2562 |
^ answerStream contents |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2563 |
|
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2564 |
" |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2565 |
|s| |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2566 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2567 |
Transcript showCR:(s throughAny:#(3 4 5)). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2568 |
Transcript showCR:s next |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2569 |
|
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2570 |
|s| |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2571 |
s := ReadStream on:'hello world, this is some text'. |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2572 |
Transcript showCR:(s throughAny:'wt'). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2573 |
Transcript showCR:(s throughAny:'wt'). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2574 |
Transcript showCR:s upToEnd. |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2575 |
" |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2576 |
|
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2577 |
"Modified: / 11.1.1998 / 15:28:04 / cg" |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2578 |
! |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2579 |
|
15639 | 2580 |
throughElementForWhich:aBlock |
2581 |
"read elements until aBlock returns true for an element. |
|
2582 |
Return the collected elements including that element. |
|
2583 |
Leave the stream positioned for the next read to return the element after that one." |
|
2584 |
||
2585 |
|answerStream element| |
|
2586 |
||
2587 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2588 |
||
2589 |
[self atEnd] whileFalse:[ |
|
2590 |
element := self next. |
|
2591 |
answerStream nextPut:element. |
|
2592 |
(aBlock value:element) ifTrue: [ |
|
2593 |
^ answerStream contents |
|
2594 |
] |
|
2595 |
]. |
|
2596 |
^ answerStream contents |
|
2597 |
||
2598 |
" |
|
2599 |
#(1 2 3 4 5 6 7 8 9 10) readStream |
|
2600 |
throughElementForWhich:[:el | el > 5]; |
|
2601 |
" |
|
2602 |
! |
|
2603 |
||
427 | 2604 |
upTo:anObject |
2605 |
"read a collection of all objects up-to anObject and return these |
|
2606 |
elements, but excluding anObject. |
|
2607 |
The next read operation will return the element after anObject. |
|
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2608 |
(i.e. anObject is considered a separator, which is skipped) |
3172
f73912c49864
Implement #upToAll: consistent with #upTo: and #upToAny: in Stream.
Stefan Vogel <sv@exept.de>
parents:
3169
diff
changeset
|
2609 |
Similar to #through:, but the matching object is not included in the |
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2610 |
returned collection. |
1409 | 2611 |
If anObject is not encountered, all elements up to the end are read |
2612 |
and returned. |
|
427 | 2613 |
Compare this with #through: which also reads up to some object |
2614 |
and also positions behind it, but DOES include it in the returned |
|
2615 |
value." |
|
2616 |
||
11659 | 2617 |
|answerStream| |
427 | 2618 |
|
2619 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
11659 | 2620 |
self upTo:anObject into:answerStream. |
427 | 2621 |
^ answerStream contents |
2622 |
||
2623 |
" |
|
2624 |
|s| |
|
2625 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 2626 |
Transcript showCR:(s upTo:4). |
2627 |
Transcript showCR:s next |
|
427 | 2628 |
|
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2629 |
compare the above to: |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2630 |
|s| |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2631 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2632 |
Transcript showCR:(s through:4). |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2633 |
Transcript showCR:s next |
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2634 |
|
427 | 2635 |
|s| |
1409 | 2636 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
1422 | 2637 |
Transcript showCR:(s upTo:9). |
2638 |
Transcript showCR:s next |
|
1409 | 2639 |
|
2640 |
|s| |
|
427 | 2641 |
s := ReadStream on:'hello world'. |
1422 | 2642 |
Transcript showCR:(s upTo:Character space). |
2643 |
Transcript showCR:(s upToEnd) |
|
427 | 2644 |
|
15778 | 2645 |
(ReadStream on:'12345678905') upTo:$5; next |
2646 |
||
427 | 2647 |
(ReadStream on:'12345678905') upTo:$5; upTo:$5 |
2648 |
||
2649 |
(ReadStream on:'123456') upTo:$7 |
|
2650 |
||
2651 |
(ReadStream on:#(1 2 3 4 5 6)) upTo:4 |
|
2652 |
||
2653 |
(ReadStream on:'line 1 |
|
10359 | 2654 |
line 2') upTo:Character cr |
427 | 2655 |
|
2656 |
'Makefile' asFilename readStream upTo:Character cr;upTo:Character cr |
|
2657 |
" |
|
1409 | 2658 |
|
3169
cef3b9a6de2c
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
2659 |
"Modified: / 12.1.1998 / 21:58:38 / cg" |
3172
f73912c49864
Implement #upToAll: consistent with #upTo: and #upToAny: in Stream.
Stefan Vogel <sv@exept.de>
parents:
3169
diff
changeset
|
2660 |
"Modified: / 15.1.1998 / 23:28:47 / stefan" |
f73912c49864
Implement #upToAll: consistent with #upTo: and #upToAny: in Stream.
Stefan Vogel <sv@exept.de>
parents:
3169
diff
changeset
|
2661 |
! |
f73912c49864
Implement #upToAll: consistent with #upTo: and #upToAny: in Stream.
Stefan Vogel <sv@exept.de>
parents:
3169
diff
changeset
|
2662 |
|
11659 | 2663 |
upTo:anObject into:aStream |
2664 |
"read a collection of all objects up-to anObject and append these |
|
2665 |
elements to aStream, but excluding anObject. |
|
2666 |
The next read operation will return the element after anObject. |
|
2667 |
(i.e. anObject is considered a separator, which is skipped) |
|
2668 |
Similar to #through:, but the matching object is not included in the returned collection. |
|
2669 |
If anObject is not encountered, all elements up to the end are read and returned. |
|
2670 |
Compare this with #through: which also reads up to some object |
|
2671 |
and also positions behind it, but DOES include it in the returned value." |
|
2672 |
||
2673 |
|element| |
|
2674 |
||
2675 |
[ |
|
2676 |
element := self nextOrNil. |
|
2677 |
((element isNil and:[self atEnd]) or:[element = anObject]) ifTrue:[ |
|
2678 |
true |
|
2679 |
] ifFalse:[ |
|
2680 |
aStream nextPut:element. |
|
2681 |
false |
|
2682 |
]. |
|
2683 |
] whileFalse. |
|
2684 |
! |
|
2685 |
||
3586 | 2686 |
upToAllExcluding:aCollection |
2687 |
"read a collection of all objects up-to a element which is contained in |
|
2688 |
aCollection and return these elements, but excluding the matching one. |
|
2689 |
The next read operation will return the element after aCollection. |
|
2690 |
If no such element is encountered, all elements up to the end are read |
|
2691 |
and returned. |
|
6494 | 2692 |
See also #throughAll: which also reads up to some object |
3586 | 2693 |
and also positions behind it, but DOES include it in the returned |
6494 | 2694 |
value. |
2695 |
See also #upToAll:, which returns the same, but leaves the |
|
2696 |
read pointer before the matched subcollection." |
|
3586 | 2697 |
|
16197 | 2698 |
|answerStream element last| |
3586 | 2699 |
|
2700 |
last := aCollection last. |
|
16197 | 2701 |
answerStream := ReadWriteStream on:(self contentsSpecies new). |
2702 |
[(element := self nextOrNil) notNil] whileTrue:[ |
|
6494 | 2703 |
answerStream nextPut:element. |
2704 |
element == last ifTrue:[ |
|
16306 | 2705 |
(answerStream contents endsWith:aCollection) ifTrue:[ |
16197 | 2706 |
|pos| |
2707 |
pos := answerStream position. |
|
2708 |
answerStream resetPosition. |
|
2709 |
^ answerStream next:pos-aCollection size. |
|
6494 | 2710 |
] |
2711 |
]. |
|
3586 | 2712 |
]. |
2713 |
^ answerStream contents |
|
2714 |
||
2715 |
" |
|
2716 |
|s| |
|
2717 |
s := ReadStream on:'hello world world'. |
|
2718 |
Transcript show:'<'; show:(s upToAllExcluding:'wo'); showCR:'>'. |
|
2719 |
Transcript show:'<'; show:(s upToAllExcluding:'wo'); showCR:'>'. |
|
2720 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
|
2721 |
" |
|
2722 |
||
2723 |
"Created: / 15.6.1998 / 19:11:31 / cg" |
|
2724 |
! |
|
2725 |
||
2894 | 2726 |
upToAny:aCollectionOfObjects |
2420 | 2727 |
"read a collection of all objects up-to a element which is contained in |
2728 |
aCollectionOfObjects and return these elements, but excluding the matching one. |
|
2729 |
The next read operation will return the element after anObject. |
|
2730 |
If no such element is encountered, all elements up to the end are read |
|
2731 |
and returned. |
|
2732 |
Compare this with #throughAll: which also reads up to some object |
|
2733 |
and also positions behind it, but DOES include it in the returned |
|
2734 |
value." |
|
2735 |
||
12527 | 2736 |
|result| |
2737 |
||
2738 |
result := self upToBeforeAny:aCollectionOfObjects. |
|
2739 |
self atEnd ifFalse:[ |
|
2740 |
self next. |
|
2420 | 2741 |
]. |
12527 | 2742 |
^ result |
2420 | 2743 |
|
2744 |
" |
|
2745 |
|s| |
|
2746 |
s := ReadStream on:'hello world'. |
|
3154 | 2747 |
Transcript showCR:(s upToAny:(Array with:Character space)). |
2420 | 2748 |
Transcript showCR:(s upToEnd) |
2749 |
||
3154 | 2750 |
'Makefile' asFilename readStream upToAny:($A to:$Z) |
2751 |
" |
|
2420 | 2752 |
|
3154 | 2753 |
"Created: / 30.8.1997 / 03:02:05 / cg" |
2754 |
"Modified: / 11.1.1998 / 15:19:18 / cg" |
|
2420 | 2755 |
! |
2756 |
||
12527 | 2757 |
upToBeforeAny:aCollectionOfObjects |
2758 |
"read a collection of all objects up-to a element which is contained in |
|
2759 |
aCollectionOfObjects and return these elements, but excluding the matching one. |
|
2760 |
The next read operation will return the matching element. |
|
2761 |
If no such element is encountered, all elements up to the end are read |
|
2762 |
and returned. |
|
16816 | 2763 |
This returns the exact same as upToAny: would, but leaves the stream's position so that |
12527 | 2764 |
the next read returns the matching delimiter instead of skipping it. |
2765 |
Caveat: this is the one which should have been called upTo: in the first place; |
|
2766 |
however, it seems now too late for a change." |
|
2767 |
||
2768 |
|answerStream element| |
|
2769 |
||
2770 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2771 |
[self atEnd] whileFalse:[ |
|
2772 |
element := self peek. |
|
2773 |
(aCollectionOfObjects includes:element) ifTrue: [ |
|
2774 |
^ answerStream contents |
|
2775 |
]. |
|
2776 |
answerStream nextPut:element. |
|
2777 |
self next. |
|
2778 |
]. |
|
2779 |
^ answerStream contents |
|
2780 |
||
2781 |
" |
|
2782 |
|s| |
|
2783 |
s := ReadStream on:'hello world'. |
|
2784 |
Transcript showCR:(s upToBeforeAny:(Array with:Character space)). |
|
2785 |
Transcript showCR:(s upToEnd) |
|
2786 |
||
2787 |
'Make.proto' asFilename readStream upToBeforeAny:($A to:$Z) |
|
2788 |
" |
|
2789 |
||
2790 |
"Created: / 30.8.1997 / 03:02:05 / cg" |
|
2791 |
"Modified: / 11.1.1998 / 15:19:18 / cg" |
|
2792 |
! |
|
2793 |
||
15639 | 2794 |
upToElementForWhich:aBlock |
2795 |
"read elements until aBlock returns true for an element. |
|
2796 |
Return the collected elements excluding that element. |
|
16608 | 2797 |
Leave the stream positioned for the next read to return that element. |
2798 |
If no element matches, all elements up to the end are returned" |
|
15639 | 2799 |
|
2800 |
|answerStream next| |
|
2801 |
||
2802 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2803 |
||
2804 |
[ |
|
2805 |
self atEnd |
|
2806 |
or:[ (aBlock value: (next := self peek)) ] |
|
2807 |
] whileFalse:[ |
|
2808 |
answerStream nextPut:next. |
|
2809 |
self next. |
|
2810 |
]. |
|
2811 |
^ answerStream contents |
|
2812 |
||
2813 |
" |
|
2814 |
#(1 2 3 4 5 6 7 8 9 10) readStream |
|
2815 |
upToElementForWhich:[:el | el > 5] |
|
2816 |
" |
|
2817 |
! |
|
2818 |
||
77 | 2819 |
upToEnd |
2820 |
"return a collection of the elements up-to the end. |
|
1403 | 2821 |
Return an empty collection, if the stream-end is already at the end." |
77 | 2822 |
|
2823 |
|answerStream| |
|
2824 |
||
2825 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
2826 |
[self atEnd] whileFalse:[ |
|
2332 | 2827 |
answerStream nextPut:(self next) |
77 | 2828 |
]. |
2829 |
^ answerStream contents |
|
2830 |
||
275 | 2831 |
" |
2832 |
(ReadStream on:'1234567890') upToEnd |
|
2833 |
('123456' readStream) next; next; upToEnd |
|
427 | 2834 |
('1 23456' readStream) upTo:Character space; upToEnd |
1403 | 2835 |
('12' readStream) next; next; upToEnd |
275 | 2836 |
" |
1403 | 2837 |
|
2838 |
"Modified: 15.5.1996 / 18:00:39 / cg" |
|
16608 | 2839 |
! |
2840 |
||
2841 |
upToMatching:aBlock |
|
2842 |
"Return the next elements up to but not including the next element |
|
2843 |
for which aBlock returns true. |
|
2844 |
The next read will return that matching element. |
|
2845 |
If none matches, the remaining elements up to the end are returned." |
|
2846 |
||
2847 |
^ self upToElementForWhich:aBlock |
|
2848 |
"/ |answerStream element| |
|
2849 |
"/ |
|
2850 |
"/ answerStream := WriteStream on:(self contentsSpecies new). |
|
2851 |
"/ [self atEnd] whileFalse: [ |
|
2852 |
"/ element := self peek. |
|
2853 |
"/ (aBlock value:element) ifTrue: [^ answerStream contents]. |
|
2854 |
"/ answerStream nextPut:element. |
|
2855 |
"/ self next. |
|
2856 |
"/ ]. |
|
2857 |
"/ ^ answerStream contents |
|
2858 |
||
2859 |
" |
|
2860 |
'hello world' readStream upToMatching:[:c | c isSeparator]. |
|
2861 |
" |
|
2862 |
" |
|
2863 |
'helloworld' readStream upToMatching:[:c | c isSeparator]. |
|
2864 |
" |
|
2865 |
" |
|
2866 |
|s| |
|
2867 |
||
2868 |
s := 'hello world' readStream. |
|
2869 |
s upToMatching:[:c | c isSeparator]. |
|
2870 |
s upToEnd |
|
2871 |
" |
|
2872 |
||
2873 |
"Modified: 26.2.1997 / 12:20:57 / cg" |
|
2874 |
! |
|
2875 |
||
2876 |
upToSeparator |
|
2877 |
"Return the next elements up to but not including the next separator. |
|
2878 |
The next read will return the separator. |
|
2879 |
If no separator is encountered, the contents up to the end is returned. |
|
2880 |
The elements are supposed to understand #isSeparator |
|
2881 |
(i.e. the receiver is supposed to be a character-stream)." |
|
2882 |
||
2883 |
^ self upToElementForWhich:[:ch | ch isSeparator] |
|
2884 |
||
2885 |
" |
|
2886 |
'hello world' readStream upToSeparator |
|
2887 |
'helloworld' readStream upToSeparator |
|
2888 |
'helloworld' readStream upToSeparator |
|
2889 |
'' readStream upToSeparator |
|
2890 |
||
2891 |
|s| |
|
2892 |
s := 'hello world' readStream. |
|
2893 |
s upToSeparator. |
|
2894 |
s upToEnd |
|
2895 |
" |
|
2896 |
||
2897 |
"Modified: 4.1.1997 / 23:38:05 / cg" |
|
611 | 2898 |
! ! |
77 | 2899 |
|
6857 | 2900 |
!Stream methodsFor:'reading-strings'! |
3084 | 2901 |
|
2902 |
nextLine |
|
2903 |
"return the characters upTo (but excluding) the next cr (carriage return) |
|
2904 |
character (i.e. read a single line of text). |
|
13329 | 2905 |
If the previous-to-last character is a cr, this is also removed, |
2906 |
so its possible to read alien (i.e. ms-dos) text as well. |
|
3084 | 2907 |
Added for protocol compatibility with externalStreams." |
2908 |
||
13329 | 2909 |
|answerStream| |
2910 |
||
3462 | 2911 |
self atEnd ifTrue:[ |
8614 | 2912 |
^ self pastEndRead |
3462 | 2913 |
]. |
13329 | 2914 |
answerStream := WriteStream on:(self contentsSpecies new). |
2915 |
self upTo:Character cr into:answerStream. |
|
13330 | 2916 |
(answerStream size > 0 and:[answerStream last = Character return]) ifTrue:[ |
13329 | 2917 |
answerStream backStep. |
2918 |
]. |
|
2919 |
^ answerStream contents |
|
2920 |
||
3084 | 2921 |
|
3462 | 2922 |
"Modified: / 19.5.1998 / 17:26:25 / cg" |
3084 | 2923 |
! ! |
2924 |
||
12623 | 2925 |
|
611 | 2926 |
!Stream methodsFor:'testing'! |
77 | 2927 |
|
611 | 2928 |
atEnd |
2929 |
"return true if the end of the stream has been reached; |
|
2930 |
- we do not know here how to do it, it must be redefined in subclass" |
|
77 | 2931 |
|
611 | 2932 |
^ self subclassResponsibility |
9294 | 2933 |
! |
2934 |
||
2935 |
isEmpty |
|
2936 |
"return true, if the contents of the stream is empty" |
|
2937 |
||
2938 |
^ self subclassResponsibility |
|
2939 |
! |
|
2940 |
||
14092 | 2941 |
isEmptyOrNil |
2942 |
"return true, if the contents of the stream is empty |
|
2943 |
(we already know, that we are not nil)" |
|
2944 |
||
2945 |
^ self isEmpty |
|
2946 |
! |
|
2947 |
||
15048 | 2948 |
isEncodedStream |
18394 | 2949 |
"true, iff this is an encoder/decoder stream" |
2950 |
||
15048 | 2951 |
^ false |
2952 |
! |
|
2953 |
||
16085 | 2954 |
isLineNumberReadStream |
18394 | 2955 |
"true, iff this is a lineNumbering stream" |
2956 |
||
16085 | 2957 |
^ false |
2958 |
! |
|
2959 |
||
15048 | 2960 |
isPositionable |
2961 |
"return true, if the stream supports positioning (some do not). |
|
2962 |
Since this is an abstract class, false is returned here - just to make certain." |
|
2963 |
||
2964 |
^ false |
|
2965 |
||
2966 |
"Modified: 15.5.1996 / 17:54:16 / cg" |
|
2967 |
! |
|
2968 |
||
2969 |
isPrinterStream |
|
2970 |
"return true, if this is a printerStream. |
|
2971 |
Since this is an abstract class, false is returned here." |
|
2972 |
||
2973 |
^ false |
|
2974 |
||
2975 |
"Modified: 15.5.1996 / 17:54:16 / cg" |
|
2976 |
"Created: 3.6.1996 / 12:05:35 / cg" |
|
2977 |
! |
|
2978 |
||
2979 |
isStream |
|
2980 |
"return true, if the receiver is some kind of Stream. Always return true here." |
|
2981 |
||
2982 |
^ true |
|
2983 |
||
2984 |
"Modified: 15.5.1996 / 17:54:48 / cg" |
|
2985 |
! |
|
2986 |
||
2987 |
isTerminalStream |
|
18394 | 2988 |
"true, iff this is a terminal emulator stream" |
2989 |
||
15048 | 2990 |
^ false |
2991 |
! |
|
2992 |
||
15719 | 2993 |
isTextCollector |
18394 | 2994 |
"true, iff this is a text collector emulating a stream" |
2995 |
||
15719 | 2996 |
^ false |
2997 |
||
2998 |
" |
|
2999 |
Transcript isTextCollector |
|
3000 |
" |
|
3001 |
||
3002 |
"Created: / 29-08-2013 / 11:33:10 / cg" |
|
3003 |
! |
|
3004 |
||
9294 | 3005 |
notEmpty |
3006 |
"return true, if the contents of the stream is not empty" |
|
3007 |
||
3008 |
^ self isEmpty not |
|
14092 | 3009 |
! |
3010 |
||
3011 |
notEmptyOrNil |
|
3012 |
"return true, if the contents of the stream is empty |
|
3013 |
(we already know, that we are not nil)" |
|
3014 |
||
3015 |
^ self isEmpty not |
|
1 | 3016 |
! ! |
3017 |
||
11750 | 3018 |
!Stream methodsFor:'visiting'! |
3019 |
||
3020 |
acceptVisitor:aVisitor with:aParameter |
|
16720 | 3021 |
"dispatch for visitor pattern; send #visitStream:with: to aVisitor." |
3022 |
||
11750 | 3023 |
^ aVisitor visitStream:self with:aParameter |
3024 |
! ! |
|
3025 |
||
12399 | 3026 |
!Stream methodsFor:'waiting for I/O'! |
3027 |
||
3028 |
readWait |
|
3029 |
"suspend the current process, until the receiver |
|
3030 |
becomes ready for reading. If data is already available, |
|
3031 |
return immediate. |
|
3032 |
The other threads are not affected by the wait." |
|
3033 |
||
3034 |
^ self readWaitWithTimeoutMs:nil |
|
3035 |
! |
|
3036 |
||
12401 | 3037 |
readWaitTimeoutMs:timeout |
3038 |
"ST-80 compatibility" |
|
3039 |
^ self readWaitWithTimeoutMs:timeout |
|
3040 |
! |
|
3041 |
||
18328 | 3042 |
readWaitWithTimeout:secondsOrTimeDurationOrNil |
12399 | 3043 |
"suspend the current process, until the receiver |
3044 |
becomes ready for reading or a timeout (in seconds) expired. |
|
3045 |
If data is already available, return immediate. |
|
3046 |
With nil seconds, wait forever. |
|
3047 |
Return true if a timeout occured (i.e. false, if data is available). |
|
3048 |
The other threads are not affected by the wait." |
|
3049 |
||
3050 |
|ms| |
|
3051 |
||
18328 | 3052 |
secondsOrTimeDurationOrNil notNil ifTrue:[ |
3053 |
secondsOrTimeDurationOrNil isNumber ifTrue:[ |
|
3054 |
ms := secondsOrTimeDurationOrNil * 1000. |
|
16402 | 3055 |
] ifFalse:[ |
18328 | 3056 |
ms := secondsOrTimeDurationOrNil getMilliseconds. |
16402 | 3057 |
] |
12399 | 3058 |
]. |
3059 |
^ self readWaitWithTimeoutMs:ms |
|
3060 |
! |
|
3061 |
||
3062 |
readWaitWithTimeoutMs:millis |
|
3063 |
"suspend the current process, until the receiver |
|
3064 |
becomes ready for reading or a timeout (in milliseconds) expired. |
|
3065 |
If data is already available, return immediate. |
|
3066 |
With nil millis, wait forever. |
|
3067 |
Return true if a timeout occured (i.e. false, if data is available). |
|
3068 |
The other threads are not affected by the wait." |
|
3069 |
||
3070 |
^ false "/ never have to wait |
|
3071 |
! |
|
3072 |
||
12401 | 3073 |
readWriteWait |
3074 |
"suspend the current process, until the receiver |
|
3075 |
becomes ready for writing or reading. |
|
3076 |
Return immediate if the receiver is already ready. |
|
3077 |
The other threads are not affected by the wait." |
|
3078 |
||
3079 |
self readWriteWaitWithTimeoutMs:nil |
|
3080 |
! |
|
3081 |
||
3082 |
readWriteWaitWithTimeoutMs:millis |
|
3083 |
^ false "/ never have to wait |
|
3084 |
! |
|
3085 |
||
12399 | 3086 |
writeWait |
12401 | 3087 |
"suspend the current process, until the receiver |
3088 |
becomes ready for writing. |
|
3089 |
Return immediate if the receiver is already ready. |
|
3090 |
The other threads are not affected by the wait." |
|
3091 |
||
3092 |
self writeWaitWithTimeoutMs:nil |
|
3093 |
! |
|
3094 |
||
3095 |
writeWaitTimeoutMs:timeout |
|
3096 |
"ST-80 compatibility" |
|
3097 |
^ self writeWaitWithTimeoutMs:timeout |
|
3098 |
! |
|
3099 |
||
16402 | 3100 |
writeWaitWithTimeout:secondsOrTimeDuration |
12401 | 3101 |
"suspend the current process, until the receiver |
3102 |
becomes ready for writing or a timeout (in seconds) expired. |
|
3103 |
Return true if a timeout occured (i.e. false, if data is available). |
|
3104 |
Return immediate if the receiver is already ready. |
|
3105 |
The other threads are not affected by the wait." |
|
3106 |
||
3107 |
|ms| |
|
3108 |
||
16402 | 3109 |
secondsOrTimeDuration notNil ifTrue:[ |
3110 |
secondsOrTimeDuration isNumber ifTrue:[ |
|
3111 |
ms := secondsOrTimeDuration * 1000. |
|
3112 |
] ifFalse:[ |
|
3113 |
ms := secondsOrTimeDuration getMilliseconds. |
|
3114 |
] |
|
12401 | 3115 |
]. |
3116 |
^ self writeWaitWithTimeoutMs:ms |
|
12399 | 3117 |
! |
3118 |
||
3119 |
writeWaitWithTimeoutMs:millis |
|
3120 |
^ false "/ never have to wait |
|
3121 |
! ! |
|
3122 |
||
62 | 3123 |
!Stream methodsFor:'writing'! |
1 | 3124 |
|
339 | 3125 |
commit |
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3126 |
"alias for flush -- ST80 compatibility" |
339 | 3127 |
|
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3128 |
^ self flush |
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3129 |
|
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3130 |
"Modified: 7.5.1996 / 23:55:39 / stefan" |
339 | 3131 |
! |
3132 |
||
611 | 3133 |
cr |
1403 | 3134 |
"append a carriage-return to the stream. |
3135 |
This is only allowed, if the receiver supports writing." |
|
611 | 3136 |
|
3137 |
self nextPut:(Character cr) |
|
1403 | 3138 |
|
3139 |
"Modified: 15.5.1996 / 18:01:21 / cg" |
|
611 | 3140 |
! |
3141 |
||
3142 |
crTab |
|
3143 |
"append a carriage-return followed by a tab to the stream. |
|
1403 | 3144 |
Same as crtab for ST/X backward compatibility. |
3145 |
This is only allowed, if the receiver supports writing." |
|
611 | 3146 |
|
5873 | 3147 |
<resource:#obsolete> |
3148 |
||
9061 | 3149 |
self obsoleteMethodWarning:'use #crtab'. |
611 | 3150 |
self crtab |
1403 | 3151 |
|
3152 |
"Modified: 15.5.1996 / 18:01:28 / cg" |
|
611 | 3153 |
! |
3154 |
||
9001 | 3155 |
crlf |
3156 |
"append a CR LF to the stream. |
|
3157 |
This is only allowed, if the receiver supports writing." |
|
3158 |
||
3159 |
self nextPut:(Character return); |
|
3160 |
nextPut:(Character lf). |
|
3161 |
! |
|
3162 |
||
611 | 3163 |
crtab |
1403 | 3164 |
"append a carriage-return followed by a tab to the stream. |
3165 |
This is only allowed, if the receiver supports writing." |
|
1 | 3166 |
|
611 | 3167 |
self crtab:1 |
1403 | 3168 |
|
3169 |
"Modified: 15.5.1996 / 18:01:35 / cg" |
|
611 | 3170 |
! |
3171 |
||
3172 |
crtab:n |
|
1403 | 3173 |
"append a carriage-return followed by n tabs to the stream. |
3174 |
This is only allowed, if the receiver supports writing." |
|
611 | 3175 |
|
3176 |
self nextPut:(Character cr). |
|
3177 |
self next:n put:(Character tab) |
|
1403 | 3178 |
|
3179 |
"Modified: 15.5.1996 / 18:01:39 / cg" |
|
611 | 3180 |
! |
3181 |
||
3182 |
endEntry |
|
3183 |
"ignored here - for compatibility with Transcript" |
|
3184 |
||
3185 |
^ self |
|
3186 |
! |
|
3187 |
||
3188 |
ff |
|
1403 | 3189 |
"append a form-feed (new-pagee) to the receiver-stream. |
3190 |
This is only allowed, if the receiver supports writing." |
|
611 | 3191 |
|
3192 |
self nextPut:(Character ff) |
|
1403 | 3193 |
|
3194 |
"Modified: 15.5.1996 / 18:01:47 / cg" |
|
1 | 3195 |
! |
3196 |
||
701 | 3197 |
flush |
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3198 |
"write out all unbuffered data - ignored here, but added |
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3199 |
to make internalStreams protocol compatible with externalStreams" |
701 | 3200 |
|
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
3201 |
"Modified: 7.5.1996 / 23:54:53 / stefan" |
701 | 3202 |
! |
3203 |
||
16453 | 3204 |
format:formatSpec with:args |
3205 |
"convenient formatted printing: |
|
3206 |
%1..%9 - positional parameters from args-collection |
|
3207 |
%(name) - named parameter from args-dictionary |
|
3208 |
%% - escape for % |
|
3209 |
%<cr> - cr (also tab, nl)" |
|
3210 |
||
3211 |
formatSpec expandPlaceholders:$% with:args on:self |
|
3212 |
||
3213 |
" |
|
3214 |
1 to: 10 do:[:i | |
|
3215 |
Transcript |
|
3216 |
format:'[%1] Hello %2 World - this is %3%<cr>' |
|
3217 |
with:{i . 'my' . 'nice'} |
|
3218 |
]. |
|
3219 |
" |
|
3220 |
! |
|
3221 |
||
1 | 3222 |
next:count put:anObject |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3223 |
"put the argument, anObject count times onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3224 |
This is only allowed, if the receiver supports writing." |
1 | 3225 |
|
345 | 3226 |
|n "{ Class: SmallInteger }"| |
3227 |
||
3228 |
n := count. |
|
3229 |
n timesRepeat:[self nextPut:anObject]. |
|
12132 | 3230 |
"/ ^ anObject -- return self |
62 | 3231 |
|
3232 |
" |
|
3233 |
|s| |
|
3234 |
||
3235 |
s := WriteStream on:#(). |
|
3236 |
s nextPut:1. |
|
3237 |
s next:5 put:2. |
|
3238 |
s nextPut:3. |
|
3239 |
s contents |
|
3240 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3241 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3242 |
"Modified: 11.7.1996 / 10:00:13 / cg" |
1 | 3243 |
! |
3244 |
||
14792 | 3245 |
next:count putAll:aCollection |
3246 |
"put all elements from the argument, aCollection count times onto the receiver. |
|
3247 |
This is only allowed, if the receiver supports writing." |
|
3248 |
||
3249 |
|n "{ Class: SmallInteger }"| |
|
3250 |
||
3251 |
n := count. |
|
3252 |
n timesRepeat:[self nextPutAll:aCollection]. |
|
3253 |
"/ ^ anObject -- return self |
|
3254 |
||
3255 |
" |
|
3256 |
|s| |
|
3257 |
||
3258 |
s := WriteStream on:(String new). |
|
3259 |
s next:5 putAll:'Hello'. |
|
3260 |
s contents |
|
3261 |
" |
|
3262 |
! |
|
3263 |
||
611 | 3264 |
nextPut:anObject |
3265 |
"put the argument, anObject onto the receiver |
|
3266 |
- we do not know here how to do it, it must be redefined in subclass" |
|
3267 |
||
3268 |
^ self subclassResponsibility |
|
3269 |
! |
|
3270 |
||
1 | 3271 |
nextPutAll:aCollection |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3272 |
"put all elements of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3273 |
This is only allowed, if the receiver supports writing." |
1 | 3274 |
|
17330 | 3275 |
self nextPutAll:aCollection startingAt:1 to:aCollection size |
62 | 3276 |
|
3277 |
" |
|
3278 |
|s| |
|
3279 |
||
3280 |
s := WriteStream on:#(). |
|
3281 |
s nextPutAll:(1 to:5). |
|
3282 |
s nextPutAll:#('one' 'two' 'three'). |
|
3283 |
s contents |
|
3284 |
" |
|
3285 |
" |
|
3286 |
|s| |
|
3287 |
||
3288 |
s := WriteStream on:(String new). |
|
3289 |
s nextPutAll:($a to:$f). |
|
3290 |
s nextPutAll:'one '; |
|
3291 |
nextPutAll:'two '; |
|
3292 |
nextPutAll:'three'. |
|
3293 |
s contents |
|
3294 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3295 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3296 |
"Modified: 11.7.1996 / 10:00:21 / cg" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3297 |
! |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3298 |
|
17615 | 3299 |
nextPutAll:count from:aCollection startingAt:initialIndex |
3300 |
"append count elements with index starting at initialIndex |
|
3301 |
of the argument, aCollection onto the receiver. |
|
3302 |
This is only allowed, if the receiver supports writing. |
|
17616 | 3303 |
Answer the number of elements that were appended. |
3304 |
This is for compatibility with ExternalStream, where less then |
|
3305 |
count elements may be written. Dolphin defines this as well." |
|
3306 |
||
3307 |
self nextPutAll:aCollection startingAt:initialIndex to:initialIndex+count-1. |
|
17615 | 3308 |
^ count |
3309 |
||
3310 |
" |
|
3311 |
|s| |
|
3312 |
||
3313 |
s := WriteStream on:#(). |
|
3314 |
s nextPutAll:4 from:#('one' 'two' 'three' 'four' 'five') startingAt:2. |
|
3315 |
s contents |
|
3316 |
" |
|
3317 |
||
3318 |
"Modified: 11.7.1996 / 10:00:32 / cg" |
|
3319 |
! |
|
3320 |
||
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3321 |
nextPutAll:aCollection startingAt:first |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3322 |
"append the elements starting with index to the end |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3323 |
of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3324 |
This is only allowed, if the receiver supports writing." |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3325 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3326 |
self nextPutAll:aCollection startingAt:first to:(aCollection size). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3327 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3328 |
" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3329 |
|s| |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3330 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3331 |
s := WriteStream on:#(). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3332 |
s nextPutAll:#('one' 'two' 'three' 'four' 'five') startingAt:2. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3333 |
s contents |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3334 |
" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3335 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3336 |
"Modified: 11.7.1996 / 10:00:28 / cg" |
1 | 3337 |
! |
3338 |
||
3339 |
nextPutAll:aCollection startingAt:first to:last |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3340 |
"append the elements with index from first to last |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3341 |
of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3342 |
This is only allowed, if the receiver supports writing." |
1 | 3343 |
|
3344 |
aCollection from:first to:last do:[:element | |
|
2332 | 3345 |
self nextPut:element |
1 | 3346 |
]. |
3347 |
^ aCollection |
|
62 | 3348 |
|
3349 |
" |
|
3350 |
|s| |
|
3351 |
||
3352 |
s := WriteStream on:#(). |
|
3353 |
s nextPutAll:#('one' 'two' 'three' 'four' 'five') startingAt:2 to:4. |
|
3354 |
s contents |
|
3355 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3356 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3357 |
"Modified: 11.7.1996 / 10:00:32 / cg" |
1 | 3358 |
! |
3359 |
||
14263 | 3360 |
nextPutAllLines:aCollectionOfStrings |
3361 |
"put all elements of the argument, aCollection as individual lines |
|
3362 |
onto the receiver, append a cr (carriage return) after each. |
|
3363 |
This is only useful with character streams in textMode, |
|
3364 |
and only allowed, if the receiver supports writing." |
|
3365 |
||
3366 |
aCollectionOfStrings do:[:eachLine | |
|
3367 |
self nextPutLine:eachLine. |
|
3368 |
]. |
|
3369 |
||
3370 |
"Modified: / 08-11-1996 / 23:53:41 / cg" |
|
3371 |
"Created: / 27-07-2012 / 09:26:09 / cg" |
|
3372 |
! |
|
3373 |
||
11322 | 3374 |
nextPutAllText:aText |
3375 |
"normal streams can not handle text/emphasis, so convert aText to the string" |
|
3376 |
||
3377 |
aText string printOn:self. |
|
3378 |
! |
|
3379 |
||
3380 |
nextPutAllUnicode:aString |
|
3381 |
"normal streams can not handle multi-byte characters, so convert them to utf8" |
|
3382 |
||
3383 |
aString do:[:eachCharacter| |
|
3384 |
self nextPutUtf8:eachCharacter. |
|
3385 |
]. |
|
3386 |
! |
|
3387 |
||
5628
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3388 |
nextPutAllUntranslated:aCollection |
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3389 |
"for compatibility with printStreams (putAll - as-is without escapes)" |
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3390 |
|
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3391 |
self nextPutAll:aCollection |
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3392 |
! |
1dc85c4c4b7c
added #nextPutAllUntranslated: (for printStream compatibility)
Claus Gittinger <cg@exept.de>
parents:
5395
diff
changeset
|
3393 |
|
743 | 3394 |
nextPutLine:aCollection |
3395 |
"put all elements of the argument, aCollection onto the receiver, |
|
16454 | 3396 |
and append a cr (carriage return). aCollection should contain characters. |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3397 |
This is only useful with character streams in textMode, |
1949 | 3398 |
and only allowed, if the receiver supports writing." |
743 | 3399 |
|
3400 |
self nextPutAll:aCollection. |
|
3401 |
self cr. |
|
3402 |
||
3403 |
"Created: 13.12.1995 / 10:49:17 / cg" |
|
1949 | 3404 |
"Modified: 8.11.1996 / 23:53:41 / cg" |
743 | 3405 |
! |
3406 |
||
11322 | 3407 |
nextPutUnicode:aCharacter |
3408 |
"normal streams can not handle multi-byte characters, so convert them to utf8" |
|
3409 |
||
3410 |
self nextPutUtf8:aCharacter. |
|
3411 |
! |
|
3412 |
||
611 | 3413 |
print:anObject |
3414 |
"append a printed representation of anObject to the receiver. |
|
1403 | 3415 |
Same as 'anObject printOn:self'; Added for ST-80 compatibility." |
2 | 3416 |
|
611 | 3417 |
anObject printOn:self |
1403 | 3418 |
|
3419 |
" |
|
3420 |
|s| |
|
3421 |
||
3422 |
s := WriteStream on:''. |
|
3423 |
s nextPutAll:'one '; |
|
3424 |
print:1; |
|
3425 |
nextPutAll:' two '; |
|
3426 |
print:2. |
|
3427 |
||
3428 |
s contents |
|
3429 |
" |
|
3430 |
||
3431 |
"Modified: 15.5.1996 / 18:06:06 / cg" |
|
2 | 3432 |
! |
3433 |
||
14360 | 3434 |
printCR:anObject |
3435 |
"append a printed representation of anObject to the receiver, |
|
3436 |
followed by a newline character." |
|
3437 |
||
3438 |
self print:anObject. |
|
3439 |
self cr. |
|
3440 |
||
3441 |
"Created: / 26-09-2012 / 18:21:06 / cg" |
|
3442 |
! |
|
3443 |
||
16864 | 3444 |
println |
3445 |
"for those used to Java/Javascript, a compatibility message. |
|
3446 |
Most useful inside expecco" |
|
3447 |
||
3448 |
self cr |
|
3449 |
! |
|
3450 |
||
3451 |
println:anObject |
|
3452 |
"for those used to Java/Javascript, a compatibility message. |
|
3453 |
Most useful inside expecco" |
|
3454 |
||
3455 |
self showCR:anObject |
|
3456 |
! |
|
3457 |
||
1403 | 3458 |
show:something |
3459 |
"append a printed representation of the argument to the stream. |
|
3460 |
This makes streams somewhat compatible to TextCollectors and |
|
3461 |
allows you to say: |
|
10920 | 3462 |
Smalltalk at:#Transcript put:Stdout |
1422 | 3463 |
or to use #show:/#showCR: with internal or external streams." |
1 | 3464 |
|
10920 | 3465 |
something printOn:self |
1 | 3466 |
! |
3467 |
||
11863 | 3468 |
show:something with:arg |
11949 | 3469 |
"append a printed representation of the argument to the stream, expanding |
3470 |
the placeHolder %1 with the printString of arg. |
|
3471 |
This makes streams somewhat compatible to TextCollectors and |
|
3472 |
allows you to say: |
|
3473 |
Smalltalk at:#Transcript put:Stdout |
|
3474 |
or to use #show:/#showCR: with internal or external streams." |
|
3475 |
||
13027 | 3476 |
self show:(something bindWith:arg) |
3477 |
||
3478 |
"Modified: / 19-08-2010 / 15:42:00 / cg" |
|
11863 | 3479 |
! |
3480 |
||
3481 |
show:something with:arg1 with:arg2 |
|
11949 | 3482 |
"append a printed representation of the argument to the stream, expanding |
3483 |
the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
|
3484 |
This makes streams somewhat compatible to TextCollectors and |
|
3485 |
allows you to say: |
|
3486 |
Smalltalk at:#Transcript put:Stdout |
|
3487 |
or to use #show:/#showCR: with internal or external streams." |
|
3488 |
||
13027 | 3489 |
self show:(something bindWith:arg1 with:arg2) |
3490 |
||
3491 |
"Modified: / 19-08-2010 / 15:42:09 / cg" |
|
11863 | 3492 |
! |
3493 |
||
3494 |
show:something with:arg1 with:arg2 with:arg3 |
|
11949 | 3495 |
"append a printed representation of the argument to the stream, expanding |
3496 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3497 |
This makes streams somewhat compatible to TextCollectors and |
|
3498 |
allows you to say: |
|
3499 |
Smalltalk at:#Transcript put:Stdout |
|
3500 |
or to use #show:/#showCR: with internal or external streams." |
|
3501 |
||
13027 | 3502 |
self show:(something bindWith:arg1 with:arg2 with:arg3) |
3503 |
||
3504 |
"Modified: / 19-08-2010 / 15:42:17 / cg" |
|
3505 |
! |
|
3506 |
||
3507 |
show:something with:arg1 with:arg2 with:arg3 with:arg4 |
|
3508 |
"append a printed representation of the argument to the stream, expanding |
|
3509 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3510 |
This makes streams somewhat compatible to TextCollectors and |
|
3511 |
allows you to say: |
|
3512 |
Smalltalk at:#Transcript put:Stdout |
|
3513 |
or to use #show:/#showCR: with internal or external streams." |
|
3514 |
||
3515 |
self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
|
3516 |
||
3517 |
"Created: / 19-08-2010 / 15:42:25 / cg" |
|
11863 | 3518 |
! |
3519 |
||
16794 | 3520 |
show:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
3521 |
"append a printed representation of the argument to the stream, expanding |
|
3522 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3523 |
This makes streams somewhat compatible to TextCollectors and |
|
3524 |
allows you to say: |
|
3525 |
Smalltalk at:#Transcript put:Stdout |
|
3526 |
or to use #show:/#showCR: with internal or external streams." |
|
3527 |
||
3528 |
self show:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
3529 |
||
3530 |
"Created: / 19-08-2010 / 15:42:25 / cg" |
|
3531 |
! |
|
3532 |
||
15711 | 3533 |
show:something withArguments:args |
3534 |
"append a printed representation of the argument to the stream, expanding |
|
3535 |
the placeHolders %1,%2 and %3 with the printStrings of argi. |
|
3536 |
This makes streams somewhat compatible to TextCollectors and |
|
3537 |
allows you to say: |
|
3538 |
Smalltalk at:#Transcript put:Stdout |
|
3539 |
or to use #show:/#showCR: with internal or external streams." |
|
3540 |
||
3541 |
self show:(something bindWithArguments:args) |
|
3542 |
! |
|
3543 |
||
1414 | 3544 |
showCR:aString |
1403 | 3545 |
"append a printed representation of the argument to the stream |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3546 |
and append a newline character. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3547 |
This makes streams somewhat compatible to TextCollectors and |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3548 |
allows you to say: |
2332 | 3549 |
Smalltalk at:#Transcript put:Stdout |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3550 |
or to use #show:/#showCR: with internal or external streams." |
1 | 3551 |
|
3552 |
self show:aString. |
|
3553 |
self cr |
|
1403 | 3554 |
|
1414 | 3555 |
"Created: 18.5.1996 / 15:34:17 / cg" |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3556 |
"Modified: 11.7.1996 / 10:01:27 / cg" |
1414 | 3557 |
! |
3558 |
||
13027 | 3559 |
showCR:something with:arg |
3560 |
"append a printed representation of the argument to the stream, expanding |
|
3561 |
the placeHolder %1 with the printString of arg. |
|
3562 |
This makes streams somewhat compatible to TextCollectors and |
|
3563 |
allows you to say: |
|
3564 |
Smalltalk at:#Transcript put:Stdout |
|
3565 |
or to use #show:/#showCR: with internal or external streams." |
|
3566 |
||
3567 |
self showCR:(something bindWith:arg) |
|
3568 |
||
3569 |
"Created: / 19-08-2010 / 15:41:46 / cg" |
|
3570 |
! |
|
3571 |
||
3572 |
showCR:something with:arg1 with:arg2 |
|
3573 |
"append a printed representation of the argument to the stream, expanding |
|
3574 |
the placeHolders %1 and %2 with the printStrings of arg1 and arg2. |
|
3575 |
This makes streams somewhat compatible to TextCollectors and |
|
3576 |
allows you to say: |
|
3577 |
Smalltalk at:#Transcript put:Stdout |
|
3578 |
or to use #show:/#showCR: with internal or external streams." |
|
3579 |
||
3580 |
self showCR:(something bindWith:arg1 with:arg2) |
|
3581 |
||
3582 |
"Created: / 19-08-2010 / 15:42:37 / cg" |
|
3583 |
! |
|
3584 |
||
3585 |
showCR:something with:arg1 with:arg2 with:arg3 |
|
3586 |
"append a printed representation of the argument to the stream, expanding |
|
3587 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3588 |
This makes streams somewhat compatible to TextCollectors and |
|
3589 |
allows you to say: |
|
3590 |
Smalltalk at:#Transcript put:Stdout |
|
3591 |
or to use #show:/#showCR: with internal or external streams." |
|
3592 |
||
3593 |
self showCR:(something bindWith:arg1 with:arg2 with:arg3) |
|
3594 |
||
3595 |
"Created: / 19-08-2010 / 15:42:43 / cg" |
|
3596 |
! |
|
3597 |
||
3598 |
showCR:something with:arg1 with:arg2 with:arg3 with:arg4 |
|
3599 |
"append a printed representation of the argument to the stream, expanding |
|
3600 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3601 |
This makes streams somewhat compatible to TextCollectors and |
|
3602 |
allows you to say: |
|
3603 |
Smalltalk at:#Transcript put:Stdout |
|
3604 |
or to use #show:/#showCR: with internal or external streams." |
|
3605 |
||
3606 |
self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4) |
|
3607 |
||
3608 |
"Created: / 19-08-2010 / 15:42:50 / cg" |
|
3609 |
! |
|
3610 |
||
16794 | 3611 |
showCR:something with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
3612 |
"append a printed representation of the argument to the stream, expanding |
|
3613 |
the placeHolders %1,%2 and %3 with the printStrings of arg1, arg2 and arg3. |
|
3614 |
This makes streams somewhat compatible to TextCollectors and |
|
3615 |
allows you to say: |
|
3616 |
Smalltalk at:#Transcript put:Stdout |
|
3617 |
or to use #show:/#showCR: with internal or external streams." |
|
3618 |
||
3619 |
self showCR:(something bindWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
3620 |
||
3621 |
"Created: / 19-08-2010 / 15:42:50 / cg" |
|
3622 |
! |
|
3623 |
||
15711 | 3624 |
showCR:something withArguments:args |
3625 |
"append a printed representation of the argument to the stream, expanding |
|
3626 |
the placeHolders %1,%2 and %3 with the printStrings of argi. |
|
3627 |
This makes streams somewhat compatible to TextCollectors and |
|
3628 |
allows you to say: |
|
3629 |
Smalltalk at:#Transcript put:Stdout |
|
3630 |
or to use #show:/#showCR: with internal or external streams." |
|
3631 |
||
3632 |
self showCR:(something bindWithArguments:args) |
|
3633 |
! |
|
3634 |
||
1414 | 3635 |
showCr:aString |
3636 |
"append a printed representation of the argument to the stream |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3637 |
and append a newline character. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3638 |
This is obsolete ST/X backward compatibility; use #showCR:" |
1414 | 3639 |
|
5873 | 3640 |
<resource:#obsolete> |
3641 |
||
1414 | 3642 |
self obsoleteMethodWarning:'use #showCR:'. |
3643 |
self showCR:aString. |
|
3644 |
||
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3645 |
"Modified: 11.7.1996 / 10:01:50 / cg" |
62 | 3646 |
! |
3647 |
||
3648 |
space |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3649 |
"append a space character to the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3650 |
This is only allowed, if the receiver supports writing." |
62 | 3651 |
|
3652 |
self nextPut:(Character space) |
|
1403 | 3653 |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3654 |
"Modified: 11.7.1996 / 10:02:06 / cg" |
62 | 3655 |
! |
3656 |
||
3657 |
spaces:count |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3658 |
"append count space-characters to the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3659 |
This is only allowed, if the receiver supports writing." |
62 | 3660 |
|
3661 |
self next:count put:(Character space) |
|
1403 | 3662 |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3663 |
"Modified: 11.7.1996 / 10:02:10 / cg" |
62 | 3664 |
! |
3665 |
||
611 | 3666 |
store:anObject |
3667 |
"append a printed representation of anObject to the receiver, |
|
1403 | 3668 |
from which the receiver can be reconstructed (i.e. its storeString). |
3669 |
Same as 'anObject storeOn:self'; Added for ST-80 compatibility." |
|
77 | 3670 |
|
611 | 3671 |
anObject storeOn:self |
1403 | 3672 |
|
3673 |
"Modified: 15.5.1996 / 18:05:55 / cg" |
|
77 | 3674 |
! |
3675 |
||
8645 | 3676 |
sync |
3677 |
"write out all unbuffered data - ignored here, but added |
|
3678 |
to make internalStreams protocol compatible with externalStreams" |
|
3679 |
! |
|
3680 |
||
11649 | 3681 |
syncData |
3682 |
"write out all unbuffered data - ignored here, but added |
|
3683 |
to make internalStreams protocol compatible with externalStreams" |
|
3684 |
! |
|
3685 |
||
611 | 3686 |
tab |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3687 |
"append a tab-character to the stream. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3688 |
This is only allowed, if the receiver supports writing." |
77 | 3689 |
|
611 | 3690 |
self nextPut:(Character tab) |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3691 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
3692 |
"Modified: 11.7.1996 / 10:02:20 / cg" |
2443 | 3693 |
! |
3694 |
||
3695 |
tab:count |
|
3696 |
"append count tab-characters to the receiver. |
|
3697 |
This is only allowed, if the receiver supports writing." |
|
3698 |
||
3699 |
self next:count put:(Character tab) |
|
3700 |
||
3701 |
"Modified: 11.7.1996 / 10:02:10 / cg" |
|
77 | 3702 |
! ! |
3703 |
||
8054
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3704 |
!Stream methodsFor:'writing-chunks'! |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3705 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3706 |
nextChunkPut:aString |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3707 |
"put aString as a chunk onto the receiver; |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3708 |
double all exclamation marks except within primitives and append a |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3709 |
single delimiting exclamation mark at the end. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3710 |
This modification of the chunk format (not doubling exclas in primitive code) |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3711 |
was done to have primitive code more readable and easier be edited in the fileBrowser |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3712 |
or other editors. |
15086 | 3713 |
It's no incompatibility, since inline primitives are an ST/X special |
8054
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3714 |
and code containing ST/X primitives cannot be loaded into other smalltalks anyway." |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3715 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3716 |
self nextPutAllAsChunk:aString. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3717 |
self nextPut:(self class chunkSeparator) |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3718 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3719 |
"Modified: 9.12.1995 / 15:56:54 / cg" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3720 |
! |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3721 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3722 |
nextPutAllAsChunk:aString |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3723 |
"put aString as a chunk onto the receiver; |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3724 |
double all exclamation marks except within primitives. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3725 |
This modification of the chunk format (not doubling exclas in primitive code) |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3726 |
was done to have primitive code more readable and easier be edited in the fileBrowser |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3727 |
or other editors. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3728 |
Its no incompatibility, since inline primitives are an ST/X special |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3729 |
and code containing ST/X primitives cannot be loaded into other smalltalks anyway." |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3730 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3731 |
|sep stopChars inPrimitive character |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3732 |
index "{ Class:SmallInteger }" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3733 |
endIndex "{ Class:SmallInteger }" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3734 |
stop "{ Class:SmallInteger }" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3735 |
next "{ Class:SmallInteger }"| |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3736 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3737 |
endIndex := aString size. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3738 |
endIndex == 0 ifTrue:[^ self]. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3739 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3740 |
sep := self class chunkSeparator. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3741 |
stopChars := '{}' copyWith:sep. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3742 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3743 |
inPrimitive := false. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3744 |
index := 1. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3745 |
stop := endIndex + 1. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3746 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3747 |
[index <= endIndex] whileTrue:[ |
16870 | 3748 |
" |
3749 |
find position of next interesting character; |
|
3750 |
output stuff up to that one in one piece |
|
3751 |
" |
|
3752 |
next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop. |
|
3753 |
||
3754 |
((index == 1) and:[next == stop]) ifTrue:[ |
|
3755 |
self nextPutAll:aString |
|
3756 |
] ifFalse:[ |
|
3757 |
self nextPutAll:aString startingAt:index to:(next - 1) |
|
3758 |
]. |
|
3759 |
||
3760 |
index := next. |
|
3761 |
(index <= endIndex) ifTrue:[ |
|
3762 |
character := aString at:index. |
|
3763 |
||
3764 |
(character == ${ ) ifTrue:[ |
|
3765 |
"/ starts a primitive |
|
3766 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
|
3767 |
inPrimitive := true |
|
3768 |
] |
|
3769 |
] ifFalse:[ |
|
3770 |
"/ ends a primitive |
|
3771 |
(character == $} ) ifTrue:[ |
|
3772 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
|
3773 |
inPrimitive := false |
|
3774 |
] |
|
3775 |
] ifFalse:[ |
|
3776 |
"/ |
|
3777 |
"/ exclas have to be doubled - except if within a primitive |
|
3778 |
"/ |
|
3779 |
inPrimitive ifFalse:[ |
|
3780 |
(character == sep) ifTrue:[ |
|
3781 |
self nextPut:sep |
|
3782 |
] |
|
3783 |
] |
|
3784 |
] |
|
3785 |
]. |
|
3786 |
||
3787 |
self nextPut:character. |
|
3788 |
index := index + 1. |
|
3789 |
]. |
|
8054
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3790 |
]. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3791 |
(aString endsWith:Character cr) ifFalse:[ |
16870 | 3792 |
self cr. |
8054
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3793 |
]. |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3794 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3795 |
"Modified: / 21.4.1998 / 17:22:47 / cg" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3796 |
! |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3797 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3798 |
nextPutChunkSeparator |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3799 |
"append a chunk separator character" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3800 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3801 |
self nextPut:(self class chunkSeparator) |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3802 |
|
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3803 |
"Created: 13.9.1995 / 17:39:26 / claus" |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3804 |
! ! |
7f31b0651027
chunk stuff moved from positionable stream (did not need positioning)
Claus Gittinger <cg@exept.de>
parents:
7687
diff
changeset
|
3805 |
|
1949 | 3806 |
!Stream class methodsFor:'documentation'! |
701 | 3807 |
|
3808 |
version |
|
18394 | 3809 |
^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.245 2015-05-23 13:09:26 cg Exp $' |
12093 | 3810 |
! |
3811 |
||
3812 |
version_CVS |
|
18394 | 3813 |
^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.245 2015-05-23 13:09:26 cg Exp $' |
701 | 3814 |
! ! |
6857 | 3815 |
|
14792 | 3816 |
|
611 | 3817 |
Stream initialize! |