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