author | Claus Gittinger <cg@exept.de> |
Sun, 02 Nov 1997 20:14:50 +0100 | |
changeset 3089 | 0823aa17ac4d |
parent 3084 | bf7811414895 |
child 3104 | 4b817b05cde0 |
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 |
" |
|
12 |
||
13 |
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
|
14 |
instanceVariableNames:'signalAtEnd' |
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
15 |
classVariableNames:'StreamErrorSignal PositionErrorSignal ReadErrorSignal |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
16 |
WriteErrorSignal EndOfStreamSignal' |
743 | 17 |
poolDictionaries:'' |
18 |
category:'Streams' |
|
1 | 19 |
! |
20 |
||
1949 | 21 |
!Stream class methodsFor:'documentation'! |
88 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
216 | 26 |
All Rights Reserved |
88 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
An abstract class defining common behavior for all stream-like objects. |
|
40 |
See concrete subclasses for more detail. |
|
345 | 41 |
|
1404 | 42 |
The protocol as implemented here is often only provided as a fallBack |
43 |
for very uncommon cases. Much of it is redefined for performance. |
|
44 |
(In streams which know more about their internal representation ...) |
|
45 |
||
46 |
||
345 | 47 |
Subclasses should (at least) implement: |
2332 | 48 |
#next (if readable) |
49 |
#nextPut: (if writable) |
|
50 |
#contents |
|
51 |
#atEnd |
|
52 |
#isReadable |
|
53 |
#isWritable |
|
1295 | 54 |
|
1404 | 55 |
Peekable & Positionable streams should (at least) implement: |
2332 | 56 |
#peek |
57 |
#position |
|
58 |
#position: |
|
1404 | 59 |
|
60 |
||
1295 | 61 |
[Class variables:] |
2332 | 62 |
StreamErrorSignal <Signal> parent of all stream errors |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
63 |
|
2332 | 64 |
PositionErrorSignal <Signal> position attemted on a stream |
65 |
which does not support positioning |
|
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
66 |
|
2332 | 67 |
ReadErrorSignal <Signal> raised on read errors |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
68 |
|
2332 | 69 |
WriteErrorSignal <Signal> raised on write errors |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
70 |
|
2332 | 71 |
EndOfStreamSignal <Signal> raised at end of stream |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
72 |
|
1295 | 73 |
[author:] |
2332 | 74 |
Claus Gittinger |
88 | 75 |
" |
76 |
! ! |
|
1 | 77 |
|
1949 | 78 |
!Stream class methodsFor:'initialization'! |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
79 |
|
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
80 |
initialize |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
81 |
StreamErrorSignal isNil ifTrue:[ |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
82 |
StreamErrorSignal := ErrorSignal newSignalMayProceed:false. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
83 |
StreamErrorSignal nameClass:self message:#streamErrorSignal. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
84 |
StreamErrorSignal notifierString:'Stream error'. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
85 |
|
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
86 |
PositionErrorSignal := StreamErrorSignal newSignalMayProceed:true. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
87 |
PositionErrorSignal nameClass:self message:#positionErrorSignal. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
88 |
PositionErrorSignal notifierString:'stream as no concept of a position'. |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
89 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
90 |
ReadErrorSignal := StreamErrorSignal newSignalMayProceed:false. |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
91 |
ReadErrorSignal nameClass:self message:#readErrorSignal. |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
92 |
ReadErrorSignal notifierString:'read error'. |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
93 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
94 |
WriteErrorSignal := StreamErrorSignal newSignalMayProceed:false. |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
95 |
WriteErrorSignal nameClass:self message:#writeErrorSignal. |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
96 |
WriteErrorSignal notifierString:'write error'. |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
97 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
98 |
EndOfStreamSignal := StreamErrorSignal newSignalMayProceed:false. |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
99 |
EndOfStreamSignal nameClass:self message:#endOfStreamSignal. |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
100 |
EndOfStreamSignal notifierString:'end of stream'. |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
101 |
] |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
102 |
! ! |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
103 |
|
1949 | 104 |
!Stream class methodsFor:'instance creation'! |
611 | 105 |
|
106 |
new |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1117
diff
changeset
|
107 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1117
diff
changeset
|
108 |
|
611 | 109 |
"report an error - Streams are created using on:-messages" |
110 |
||
111 |
^ self error:'Streams cannot be created with new' |
|
112 |
! ! |
|
113 |
||
1949 | 114 |
!Stream class methodsFor:'Signal constants'! |
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
115 |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
116 |
endOfStreamSignal |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
117 |
"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
|
118 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
119 |
^ EndOfStreamSignal |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
120 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
121 |
|
611 | 122 |
positionErrorSignal |
123 |
"return the signal raised if positioning is requested for |
|
124 |
a stream which does not support that kind of operation" |
|
125 |
||
126 |
^ PositionErrorSignal |
|
127 |
! |
|
128 |
||
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
129 |
readErrorSignal |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
130 |
"return the signal raised on read errors" |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
131 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
132 |
^ ReadErrorSignal |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
133 |
! |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
134 |
|
593
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
135 |
streamErrorSignal |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
136 |
"return the parent of all stream errors; |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
137 |
handling this one also handles all other errors. |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
138 |
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
|
139 |
operations, such as failed ioctls in externalStream etc." |
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
140 |
|
19d568779cf7
moved StreamErrorSignal into Stream;
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
141 |
^ StreamErrorSignal |
820
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
142 |
! |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
143 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
144 |
writeErrorSignal |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
145 |
"return the signal raised on write errors" |
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
146 |
|
6d934f5d6cbc
moved readErrorSignal / writeErrorSignal up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
743
diff
changeset
|
147 |
^ WriteErrorSignal |
1 | 148 |
! ! |
149 |
||
150 |
!Stream methodsFor:'accessing'! |
|
151 |
||
152 |
contents |
|
62 | 153 |
"return the entire contents of the stream |
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
154 |
- we do not know here how to do it, it must be redefined in subclasses." |
1 | 155 |
|
156 |
^ self subclassResponsibility |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
157 |
|
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
158 |
"Modified: 15.5.1996 / 17:36:29 / cg" |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
159 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
160 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
161 |
signalAtEnd |
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
162 |
"return 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
|
163 |
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
|
164 |
raised and nil is returned from all reading messages. |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
165 |
The default is (currently) to NOT raise a signal." |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
166 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
167 |
^ signalAtEnd |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
168 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
169 |
"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
|
170 |
"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
|
171 |
! |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
172 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
173 |
signalAtEnd:aBoolean |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
174 |
"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
|
175 |
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
|
176 |
raised and nil is returned from all reading messages. |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
177 |
The default is (currently) to NOT raise a signal." |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
178 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
179 |
signalAtEnd := aBoolean. |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
180 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
846
diff
changeset
|
181 |
"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
|
182 |
"Modified: 15.5.1996 / 17:36:12 / cg" |
1 | 183 |
! ! |
184 |
||
611 | 185 |
!Stream methodsFor:'closing'! |
186 |
||
187 |
close |
|
188 |
"close the stream - nothing done here. |
|
189 |
Added for compatibility with external streams." |
|
190 |
||
191 |
^ self |
|
192 |
! ! |
|
193 |
||
1401 | 194 |
!Stream methodsFor:'emphasis'! |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
195 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
196 |
bold |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
197 |
"set emphasis to #bold. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
198 |
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
|
199 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
200 |
self emphasis:#bold. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
201 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
202 |
"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
|
203 |
"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
|
204 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
205 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
206 |
boldItalic |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
207 |
"set emphasis to #boldItalic |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
208 |
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
|
209 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
210 |
self emphasis:#(bold italic). |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
211 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
212 |
"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
|
213 |
"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
|
214 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
215 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
216 |
emphasis |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
217 |
"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
|
218 |
text streams" |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
219 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
220 |
^ nil |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
221 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
222 |
"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
|
223 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
224 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
225 |
emphasis:anEmphasis |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
226 |
"ignored here. |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
227 |
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
|
228 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
229 |
^ self |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
230 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
231 |
"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
|
232 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
233 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
234 |
italic |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
235 |
"set emphasis to #italic. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
236 |
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
|
237 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
238 |
self emphasis:#italic. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
239 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
240 |
"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
|
241 |
"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
|
242 |
! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
243 |
|
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
244 |
normal |
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
245 |
"set emphasis to #normal. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
246 |
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
|
247 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
248 |
self emphasis:nil |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
249 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
250 |
"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
|
251 |
"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
|
252 |
! |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
253 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
254 |
strikeout |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
255 |
"set emphasis to #strikeout. |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
256 |
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
|
257 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
258 |
self emphasis:#strikeout. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
259 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
260 |
"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
|
261 |
"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
|
262 |
! |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
263 |
|
1448
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
264 |
underline |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
265 |
"set emphasis to #underline. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
266 |
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
|
267 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
268 |
self emphasis:#underline. |
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
269 |
|
0d59ce5c4915
reduce all emphasis change messages to single #emphasis:
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
270 |
"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
|
271 |
"Modified: 3.6.1996 / 17:15:38 / cg" |
1398
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
272 |
! ! |
6c594289c589
emphasis stuff moved up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
273 |
|
1401 | 274 |
!Stream methodsFor:'enumerating'! |
275 |
||
276 |
do:aBlock |
|
277 |
"evaluate the argument, aBlock for all remaining elements, |
|
278 |
up to the end of the stream" |
|
279 |
||
280 |
[self atEnd] whileFalse:[ |
|
281 |
aBlock value:(self next) |
|
282 |
] |
|
283 |
||
284 |
" |
|
285 |
|s| |
|
286 |
s := ReadStream on:#(1 2 3 4 5 6 7 8 9). |
|
287 |
s next. |
|
288 |
s next. |
|
1422 | 289 |
s do:[:element | Transcript showCR:element] |
1401 | 290 |
" |
291 |
! ! |
|
292 |
||
293 |
!Stream methodsFor:'error handling'! |
|
294 |
||
295 |
pastEnd |
|
296 |
"someone tried to read after the end of the stream. |
|
297 |
if signalAtEnd == true, raise a signal. |
|
298 |
Otherwise return nil." |
|
299 |
||
300 |
signalAtEnd == true ifTrue:[ |
|
2332 | 301 |
^ EndOfStreamSignal raiseIn:thisContext sender |
1401 | 302 |
]. |
303 |
^ nil |
|
304 |
||
305 |
"Created: 5.2.1996 / 21:56:08 / stefan" |
|
306 |
! ! |
|
307 |
||
611 | 308 |
!Stream methodsFor:'misc'! |
309 |
||
310 |
binary |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
311 |
"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
|
312 |
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
|
313 |
byte-valued integers respectively. |
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
314 |
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
|
315 |
with externalStreams." |
611 | 316 |
|
1402
82462d153a7d
added #nextAlphaNumericWord (completing the protocol); added comments
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
317 |
"Modified: 15.5.1996 / 17:38:36 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
318 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
319 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
320 |
text |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
321 |
"switch to text mode. |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
322 |
Ignored here, but added to make internalStreams protocol compatible |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
323 |
with externalStreams." |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
324 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
325 |
"Modified: 15.5.1996 / 17:38:36 / cg" |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
326 |
"Created: 13.9.1996 / 18:33:26 / cg" |
611 | 327 |
! ! |
328 |
||
329 |
!Stream methodsFor:'non homogenous reading'! |
|
330 |
||
2714 | 331 |
nextBytes:count |
332 |
"read the next count bytes and return it either as a byteArray (binary mode) |
|
333 |
or as a string (text mode). |
|
334 |
If EOF is encountered while reading, a truncated byteArry or short string |
|
335 |
is returned. If EOF is already reached before the first byte can be read, |
|
336 |
nil is returned." |
|
337 |
||
338 |
|data n| |
|
339 |
||
340 |
self binary ifTrue:[ |
|
341 |
data := ByteArray new:count |
|
342 |
] ifFalse:[ |
|
343 |
data := String new:count |
|
344 |
]. |
|
345 |
n := self nextBytes:count into:data startingAt:1. |
|
346 |
n ~~ count ifTrue:[ |
|
347 |
n == 0 ifTrue:[ |
|
348 |
^ nil |
|
349 |
]. |
|
350 |
data := data copyTo:n |
|
351 |
]. |
|
352 |
||
353 |
^ data |
|
354 |
||
355 |
"Created: 21.6.1997 / 11:18:57 / cg" |
|
356 |
! |
|
357 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
358 |
nextBytes:count into:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
359 |
"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
|
360 |
bytes read. On EOF, 0 is returned. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
361 |
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
|
362 |
is raised if the connection is broken. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
363 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
364 |
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
|
365 |
a ByteArray, String, Float- or DoubleArray). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
366 |
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
|
367 |
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
|
368 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
369 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
370 |
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
|
371 |
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
|
372 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
373 |
^ self nextBytes:count into:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
374 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
375 |
"Modified: 22.4.1997 / 10:41:39 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
376 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
377 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
378 |
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
|
379 |
"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
|
380 |
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
|
381 |
collection. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
382 |
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
|
383 |
The receiver must support reading of binary bytes. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
384 |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
385 |
Notice: this method is privided here for protocol completeness |
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
386 |
with externalStreams - it is normally not used with other |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
387 |
streams." |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
388 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
389 |
|n "{Class: SmallInteger }" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
390 |
dstIndex| |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
391 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
392 |
dstIndex := initialIndex. |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
393 |
n := 0. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
394 |
[self atEnd] whileFalse:[ |
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
395 |
n == numBytes ifTrue:[ |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
396 |
^ n |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
397 |
]. |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
398 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
399 |
aCollection byteAt:dstIndex put:(self nextByte). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
400 |
dstIndex := dstIndex + 1. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
401 |
n := n + 1. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
402 |
]. |
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
403 |
^ n |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
404 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
405 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
406 |
|s n buffer| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
407 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
408 |
buffer := ByteArray new:10. |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
409 |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
410 |
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
|
411 |
s next:3. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
412 |
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
|
413 |
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
|
414 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
415 |
|
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
416 |
"Modified: 22.4.1997 / 10:43:08 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
417 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
418 |
|
2587 | 419 |
nextBytes:numBytes into:aCollection startingAt:initialIndex blockSize:blockSize |
420 |
"like nextBytes:into:startingAt:, but read in blocks of the given size. |
|
421 |
This leads to better beahvior when reading large chunks from a slow device, |
|
422 |
such as a cdrom drive (since a single unix-read is not interruptable)." |
|
423 |
||
424 |
|nR oR n| |
|
425 |
||
426 |
nR := numBytes. |
|
427 |
oR := initialIndex. |
|
428 |
[nR > 0] whileTrue:[ |
|
429 |
n := nR. |
|
430 |
n > blockSize ifTrue:[n := blockSize]. |
|
431 |
n := self nextBytes:n into:aCollection startingAt:oR. |
|
432 |
n == 0 ifTrue:[ |
|
433 |
^ numBytes - nR |
|
434 |
]. |
|
435 |
oR := oR + n. |
|
436 |
nR := nR - n |
|
437 |
]. |
|
438 |
^ numBytes |
|
439 |
||
440 |
"Created: 24.4.1997 / 21:09:34 / cg" |
|
441 |
"Modified: 24.4.1997 / 21:19:50 / cg" |
|
442 |
! |
|
443 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
444 |
nextBytesInto:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
445 |
"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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
is raised if the connection is broken. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
450 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
451 |
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
|
452 |
(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
|
453 |
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
|
454 |
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
|
455 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
456 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
457 |
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
|
458 |
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
|
459 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
460 |
^ self nextBytes:(anObject byteSize) into:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
461 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
462 |
" to read 100 bytes from a stream: |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
463 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
464 |
|b aStream| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
465 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
466 |
aStream := 'smalltalk.rc' asFilename readStream. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
467 |
b := ByteArray new:100. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
468 |
aStream nextBytesInto:b. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
469 |
aStream close. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
470 |
b inspect |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
471 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
472 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
473 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
474 |
|s aStream| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
475 |
aStream := 'smalltalk.rc' asFilename readStream. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
476 |
s := String new:100. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
477 |
aStream nextBytesInto:s. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
478 |
aStream close. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
479 |
s inspect |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
480 |
" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
481 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
482 |
"Modified: 22.4.1997 / 10:42:02 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
483 |
"Created: 22.4.1997 / 10:42:26 / cg" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
484 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
485 |
|
611 | 486 |
nextLongMSB:msbFlag |
487 |
"return a signed long (4 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
488 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
489 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
490 |
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
|
491 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
492 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
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
|
496 |
network byte order." |
611 | 497 |
|
498 |
|high uval "{ Class: SmallInteger }"| |
|
499 |
||
500 |
msbFlag ifTrue:[ |
|
2332 | 501 |
"most significant first" |
502 |
high := self next. |
|
503 |
uval := self next bitShift:16. |
|
504 |
uval := uval bitOr:(self next bitShift:8). |
|
505 |
uval := uval bitOr:(self next). |
|
506 |
uval := uval bitOr:(high bitShift:24). |
|
611 | 507 |
] ifFalse:[ |
2332 | 508 |
"least significant first" |
509 |
uval := self next. |
|
510 |
uval := uval bitOr:(self next bitShift:8). |
|
511 |
uval := uval bitOr:(self next bitShift:16). |
|
512 |
uval := uval bitOr:(self next bitShift:24). |
|
611 | 513 |
]. |
514 |
"change from unsigned 0..FFFFFFFF to signed -80000000..7FFFFFFF" |
|
515 |
||
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
516 |
"/ sorry- for now (2.7), stc cannot compile LargeInteger constants |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
517 |
"/ uval >= 16r80000000 ifTrue:[ |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
518 |
"/ ^ uval - 16r100000000 |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
519 |
"/ ]. |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
520 |
"/ the following kludges around this |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
521 |
"/ well, new (2.8) can ... |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
522 |
|
611 | 523 |
(uval bitShift:-16) >= 16r8000 ifTrue:[ |
2332 | 524 |
^ uval - (16r10000000 bitShift:8) |
611 | 525 |
]. |
526 |
^ uval |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
527 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
528 |
"Modified: 11.7.1996 / 10:06:52 / cg" |
611 | 529 |
! |
530 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
531 |
nextLongNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
532 |
"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
|
533 |
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
|
534 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
535 |
^ self nextLongMSB:(Socket networkLongOrderIsMSB) |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
536 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
537 |
"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
|
538 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
539 |
|
611 | 540 |
nextNumber:n |
541 |
"Return the next n bytes as a positive Integer; bytes are taken msb-first." |
|
542 |
||
543 |
|s |
|
544 |
val "{ Class: SmallInteger }" |
|
545 |
rep "{ Class: SmallInteger }"| |
|
546 |
||
547 |
"claus: this method is central in binaryStorage - |
|
548 |
therefore it has been tuned a bit (and needs even more tuning)" |
|
549 |
||
550 |
n == 1 ifTrue:[ |
|
551 |
^ self next |
|
552 |
]. |
|
553 |
n == 2 ifTrue:[ |
|
554 |
val := self next. |
|
555 |
val := (val bitShift:8) + self next. |
|
556 |
^ val |
|
557 |
]. |
|
558 |
n == 3 ifTrue:[ |
|
559 |
val := self next. |
|
560 |
val := (val bitShift:8) + self next. |
|
561 |
val := (val bitShift:8) + self next. |
|
562 |
^ val |
|
563 |
]. |
|
564 |
n == 4 ifTrue:[ |
|
565 |
val := self next. |
|
566 |
val <= 16r3F ifTrue:[ |
|
567 |
val := (val bitShift:8) + self next. |
|
568 |
val := (val bitShift:8) + self next. |
|
569 |
val := (val bitShift:8) + self next. |
|
570 |
^ val |
|
571 |
]. |
|
572 |
"sorry, but need a largeInteger" |
|
573 |
s := (val bitShift:8) + self next. |
|
574 |
s := (s bitShift:8) + self next. |
|
575 |
s := (s * 256) + self next. |
|
576 |
^ s |
|
577 |
]. |
|
578 |
||
579 |
" |
|
580 |
arbitrary long |
|
581 |
" |
|
582 |
s := 0. |
|
583 |
rep := n. |
|
584 |
rep timesRepeat:[ |
|
585 |
s := s * 256 + self next |
|
586 |
]. |
|
587 |
^ s truncated |
|
588 |
! |
|
589 |
||
590 |
nextShortMSB:msbFlag |
|
591 |
"return a signed short (2 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
592 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
593 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
594 |
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
|
595 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
596 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
597 |
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
|
598 |
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
|
599 |
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
|
600 |
network byte order." |
611 | 601 |
|
602 |
|uval "{ Class: SmallInteger }"| |
|
603 |
||
604 |
msbFlag ifTrue:[ |
|
2332 | 605 |
"most significant first" |
606 |
uval := self next bitShift:8. |
|
607 |
uval := uval bitOr:(self next). |
|
611 | 608 |
] ifFalse:[ |
2332 | 609 |
"least significant first" |
610 |
uval := self next. |
|
611 |
uval := uval bitOr:(self next bitShift:8). |
|
611 | 612 |
]. |
613 |
"change from unsigned 0..FFFF to signed -8000..7FFF" |
|
614 |
uval >= 16r8000 ifTrue:[ |
|
2332 | 615 |
^ uval - 16r10000 |
611 | 616 |
]. |
617 |
^ uval |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
618 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
619 |
"Modified: 11.7.1996 / 10:07:04 / cg" |
611 | 620 |
! |
621 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
622 |
nextShortNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
623 |
"return a signed short (2 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
|
624 |
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
|
625 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
626 |
^ self nextShortMSB:(Socket networkShortOrderIsMSB) |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
627 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
628 |
"Modified: 10.1.1996 / 19:48:50 / cg" |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
629 |
"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
|
630 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
631 |
|
611 | 632 |
nextUnsignedLongMSB:msbFlag |
633 |
"return an unsigned long (4 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
634 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
635 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
636 |
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
|
637 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
638 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
639 |
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
|
640 |
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
|
641 |
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
|
642 |
network byte order." |
611 | 643 |
|
644 |
|val| |
|
645 |
||
646 |
msbFlag ifTrue:[ |
|
2332 | 647 |
val := self next. |
648 |
val := (val bitShift:8) bitOr:(self next). |
|
649 |
val := (val bitShift:8) bitOr:(self next). |
|
650 |
val := (val * 256) + (self next). |
|
651 |
^ val |
|
611 | 652 |
]. |
653 |
val := self next. |
|
654 |
^ (val bitShift:24) |
|
655 |
+ (self next bitShift:16) |
|
656 |
+ (self next bitShift:8) |
|
657 |
+ self next |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
658 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
659 |
"Modified: 11.7.1996 / 10:07:13 / cg" |
611 | 660 |
! |
661 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
662 |
nextUnsignedLongNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
663 |
"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
|
664 |
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
|
665 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
666 |
^ self nextUnsignedLongMSB:(Socket networkLongOrderIsMSB) |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
667 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
668 |
"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
|
669 |
"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
|
670 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
671 |
|
611 | 672 |
nextUnsignedShortMSB:msbFlag |
673 |
"return an unsigned short (2 bytes) from the stream. |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
674 |
The receiver must support reading of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
675 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
676 |
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
|
677 |
most-significant-byte-first (true) or least-first (false). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
678 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
network byte order." |
611 | 683 |
|
684 |
msbFlag ifTrue:[ |
|
2332 | 685 |
^ (self next bitShift:8) bitOr:(self next) |
611 | 686 |
]. |
687 |
^ (self next) bitOr:(self next bitShift:8) |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
688 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
689 |
"Modified: 11.7.1996 / 10:07:20 / cg" |
611 | 690 |
! |
691 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
692 |
nextUnsignedShortNet |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
693 |
"return an unsigned short (2 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
|
694 |
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
|
695 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
696 |
^ self nextUnsignedShortMSB:(Socket networkShortOrderIsMSB) |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
697 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
698 |
"Created: 10.1.1996 / 19:50:02 / cg" |
611 | 699 |
! ! |
700 |
||
701 |
!Stream methodsFor:'non homogenous writing'! |
|
702 |
||
703 |
nextLongPut:aNumber |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
704 |
"for ST-80 compatibility: |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
705 |
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
|
706 |
The most significant byte is sent first." |
611 | 707 |
|
708 |
^ self nextPutLong:aNumber MSB:true |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
709 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
710 |
"Modified: 10.1.1996 / 19:38:54 / cg" |
611 | 711 |
! |
712 |
||
713 |
nextNumber:n put:v |
|
714 |
"Append to the receiver the argument, v, which is a positive Integer, |
|
715 |
as the next n bytes. Bytes are written msb first. |
|
716 |
Possibly pad with leading zeros. |
|
717 |
The receiver must support writing of binary bytes." |
|
718 |
||
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
719 |
|vlen "{ Class: SmallInteger }" |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
720 |
i "{ Class: SmallInteger }"| |
611 | 721 |
|
722 |
"claus: this method is central in binaryStorage - |
|
723 |
therefore it has been tuned a bit (and needs even more tuning)" |
|
724 |
||
725 |
v class == SmallInteger ifTrue:[ "- this is a hint to stc" |
|
726 |
n == 1 ifTrue:[ |
|
727 |
(v between:0 and:16rFF) ifTrue:[ |
|
728 |
self nextPut:v. |
|
729 |
^ self |
|
730 |
]. |
|
731 |
]. |
|
732 |
n == 2 ifTrue:[ |
|
733 |
(v between:0 and:16rFFFF) ifTrue:[ |
|
2332 | 734 |
self nextPut:(v bitShift:-8); nextPut:(v bitAnd:16rFF). |
611 | 735 |
^ self |
736 |
]. |
|
737 |
]. |
|
738 |
n == 3 ifTrue:[ |
|
739 |
(v between:0 and:16rFFFFFF) ifTrue:[ |
|
740 |
self nextPut:((v bitShift:-16) bitAnd:16rFF). |
|
741 |
self nextPut:((v bitShift:-8) bitAnd:16rFF). |
|
742 |
self nextPut:(v bitAnd:16rFF). |
|
743 |
^ self |
|
744 |
]. |
|
745 |
]. |
|
746 |
n == 4 ifTrue:[ |
|
747 |
(v >= 0) ifTrue:[ |
|
748 |
self nextPut:((v bitShift:-24) bitAnd:16rFF). |
|
749 |
self nextPut:((v bitShift:-16) bitAnd:16rFF). |
|
750 |
self nextPut:((v bitShift:-8) bitAnd:16rFF). |
|
751 |
self nextPut:(v bitAnd:16rFF). |
|
752 |
^ self |
|
753 |
]. |
|
754 |
]. |
|
755 |
]. |
|
756 |
||
757 |
" |
|
758 |
arbitrary long |
|
759 |
" |
|
760 |
n < (vlen := v digitLength) ifTrue: [ |
|
761 |
" |
|
762 |
the number is too big to be repesented in n bytes |
|
763 |
" |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
764 |
self error:'number too big' |
611 | 765 |
]. |
766 |
||
767 |
"pad with leading zeros" |
|
768 |
i := n. |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
769 |
[i > vlen] whileTrue:[ |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
770 |
self nextPut:0. |
611 | 771 |
i := i - 1 |
772 |
]. |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
773 |
|
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
774 |
i == 1 ifTrue:[ |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
775 |
^ self nextPut:v |
611 | 776 |
]. |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
777 |
|
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
778 |
[i > 0] whileTrue:[ |
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
779 |
self nextPut:(v digitAt:i). |
611 | 780 |
i := i - 1 |
781 |
] |
|
782 |
! |
|
783 |
||
2576
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
784 |
nextPutByte:aByteValue |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
785 |
"write a byte. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
786 |
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
|
787 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
788 |
self nextPut:aByteValue |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
789 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
790 |
"Modified: 22.4.1997 / 09:05:26 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
791 |
"Created: 22.4.1997 / 10:43:55 / cg" |
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 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
794 |
nextPutBytes:count from:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
795 |
"write count bytes from an object. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
796 |
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
|
797 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
798 |
(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
|
799 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
800 |
Warning: in general, you cannot use this method to pass data to other |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
801 |
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
|
802 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
803 |
^ self nextPutBytes:count from:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
804 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
805 |
"Created: 22.4.1997 / 10:43:59 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
806 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
807 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
808 |
nextPutBytes:count from:anObject startingAt:start |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
809 |
"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
|
810 |
Return the number of bytes written. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
811 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
812 |
(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
|
813 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
814 |
This is provided for compatibility with externalStream; |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
815 |
to support binary storage" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
816 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
817 |
|idx| |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
818 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
819 |
idx := start. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
820 |
1 to:count do:[:i | |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
821 |
self nextPutByte:(anObject byteAt:idx). |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
822 |
idx := idx + 1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
823 |
]. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
824 |
^ count |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
825 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
826 |
"Created: 22.4.1997 / 10:44:09 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
827 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
828 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
829 |
nextPutBytesFrom:anObject |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
830 |
"write bytes from an object; the number of bytes is defined by |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
831 |
the objects size. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
832 |
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
|
833 |
The object must have non-pointer indexed instvars |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
834 |
(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
|
835 |
Use with care - non object oriented i/o. |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
836 |
Warning: in general, you cannot use this method to pass data to other |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
837 |
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
|
838 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
839 |
^ self nextPutBytes:(anObject size) from:anObject startingAt:1 |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
840 |
|
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
841 |
"Created: 22.4.1997 / 10:44:18 / cg" |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
842 |
! |
9985af974304
added non-homogenous read/write stuff;
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
843 |
|
611 | 844 |
nextPutLong:aNumber MSB:msbFlag |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
845 |
"Write the argument, aNumber as a long (four bytes). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
846 |
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
|
847 |
otherwise least first. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
848 |
Returns the receiver on ok, nil on error. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
849 |
The receiver must support writing of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
850 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
851 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
network byte order." |
611 | 856 |
|
2332 | 857 |
|hi lo w1 w2| |
858 |
||
859 |
hi := (aNumber // 16r10000). |
|
860 |
lo := (aNumber \\ 16r10000). |
|
861 |
||
611 | 862 |
msbFlag ifTrue:[ |
3084 | 863 |
"high word first" |
864 |
w1 := hi. |
|
865 |
w2 := lo. |
|
2332 | 866 |
] ifFalse:[ |
3084 | 867 |
"low word first" |
868 |
w1 := lo. |
|
869 |
w2 := hi. |
|
611 | 870 |
]. |
3084 | 871 |
self nextPutShort:w1 MSB:false; nextPutShort:w2 MSB:false. |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
872 |
|
3084 | 873 |
"Modified: / 1.11.1997 / 18:30:52 / cg" |
611 | 874 |
! |
875 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
876 |
nextPutLongNet:aNumber |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
877 |
"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
|
878 |
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
|
879 |
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
|
880 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
881 |
^ self nextPutLong:aNumber MSB:(Socket networkLongOrderIsMSB). |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
882 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
883 |
"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
|
884 |
"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
|
885 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
886 |
|
611 | 887 |
nextPutShort:aNumber MSB:msbFlag |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
888 |
"Write the argument, aNumber as a short (two bytes). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
889 |
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
|
890 |
otherwise least first. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
891 |
Returns the receiver on ok, nil on error. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
892 |
The receiver must support writing of binary bytes. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
893 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
894 |
This interface is provided to allow talking to external programs, |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
895 |
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
|
896 |
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
|
897 |
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
|
898 |
network byte order." |
611 | 899 |
|
2332 | 900 |
|iNum "{ Class: SmallInteger }" hi lo b1 b2| |
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
901 |
|
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
902 |
iNum := aNumber. |
2332 | 903 |
hi := (iNum bitShift:-8). |
904 |
lo := (iNum bitAnd:16rFF). |
|
1117
f64e35e18e65
typed variable in nextPutNumber
Claus Gittinger <cg@exept.de>
parents:
970
diff
changeset
|
905 |
|
611 | 906 |
msbFlag ifTrue:[ |
2332 | 907 |
"high byte first" |
908 |
b1 := hi. |
|
909 |
b2 := lo. |
|
910 |
] ifFalse:[ |
|
911 |
"low byte first" |
|
912 |
b1 := lo. |
|
913 |
b2 := hi. |
|
611 | 914 |
]. |
2332 | 915 |
self nextPut:b1. self nextPut:b2. |
611 | 916 |
! |
917 |
||
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
918 |
nextPutShortNet:aNumber |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
919 |
"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
|
920 |
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
|
921 |
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
|
922 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
923 |
^ self nextPutLong:aNumber MSB:(Socket networkShortOrderIsMSB). |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
924 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
925 |
"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
|
926 |
! |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
927 |
|
611 | 928 |
nextPutWord:aNumber |
929 |
"write the argument, aNumber as a signed short (two bytes); |
|
930 |
write msb-first for compatibility with other smalltalks. |
|
931 |
The receiver must support writing of binary bytes. |
|
932 |
I dont know if it should be named nextPutWord: or nextWordPut:; |
|
933 |
one of them will vanish ..." |
|
934 |
||
935 |
^ self nextPutShort:aNumber MSB:true |
|
936 |
! |
|
937 |
||
938 |
nextShortPut:aNumber MSB:msbFlag |
|
3084 | 939 |
"for backward compatibility - this will vanish" |
611 | 940 |
|
941 |
^ self nextPutShort:aNumber MSB:msbFlag |
|
3084 | 942 |
|
943 |
"Modified: / 1.11.1997 / 18:31:05 / cg" |
|
611 | 944 |
! |
945 |
||
946 |
nextWordPut:aNumber |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
947 |
"for ST-80 compatibility: |
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
948 |
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
|
949 |
The most significant byte is sent first." |
611 | 950 |
|
951 |
^ self nextPutShort:aNumber MSB:true |
|
846
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
952 |
|
4117b296633d
network byte order read/write methods added
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
953 |
"Modified: 10.1.1996 / 19:39:19 / cg" |
611 | 954 |
! ! |
955 |
||
956 |
!Stream methodsFor:'private'! |
|
957 |
||
958 |
contentsSpecies |
|
959 |
"this should return the class of which an instance is |
|
1403 | 960 |
returned by the #contents method. Here, Array is returned, |
961 |
since the abstract Stream-class has no idea of the underlying |
|
962 |
collection class. |
|
963 |
It is redefined in some subclasses - for example, to return String." |
|
611 | 964 |
|
965 |
^ Array |
|
1403 | 966 |
|
967 |
"Modified: 15.5.1996 / 17:53:31 / cg" |
|
611 | 968 |
! ! |
969 |
||
970 |
!Stream methodsFor:'queries'! |
|
971 |
||
972 |
isBinary |
|
1403 | 973 |
"return true, if in binary mode. Always returns false here, |
974 |
to make internalStreams protocol compatible with externalStreams." |
|
611 | 975 |
|
976 |
^ false |
|
1403 | 977 |
|
978 |
"Modified: 15.5.1996 / 17:53:51 / cg" |
|
611 | 979 |
! |
980 |
||
981 |
isPositionable |
|
1403 | 982 |
"return true, if the stream supports positioning (some do not). |
983 |
Since this is an abstract class, false is returned here - just to make certain." |
|
611 | 984 |
|
985 |
^ false |
|
1403 | 986 |
|
987 |
"Modified: 15.5.1996 / 17:54:16 / cg" |
|
611 | 988 |
! |
989 |
||
1447 | 990 |
isPrinterStream |
991 |
"return true, if this is a printerStream. |
|
992 |
Since this is an abstract class, false is returned here." |
|
993 |
||
994 |
^ false |
|
995 |
||
996 |
"Modified: 15.5.1996 / 17:54:16 / cg" |
|
997 |
"Created: 3.6.1996 / 12:05:35 / cg" |
|
998 |
! |
|
999 |
||
611 | 1000 |
isReadable |
1001 |
"return true, if reading is supported by the recevier. |
|
1403 | 1002 |
This has to be redefined in concrete subclasses." |
611 | 1003 |
|
1004 |
^ self subclassResponsibility |
|
1403 | 1005 |
|
1006 |
"Modified: 15.5.1996 / 17:54:31 / cg" |
|
611 | 1007 |
! |
1008 |
||
1009 |
isStream |
|
1403 | 1010 |
"return true, if the receiver is some kind of Stream. Always return true here." |
611 | 1011 |
|
1012 |
^ true |
|
1403 | 1013 |
|
1014 |
"Modified: 15.5.1996 / 17:54:48 / cg" |
|
611 | 1015 |
! |
1016 |
||
1017 |
isWritable |
|
1018 |
"return true, if writing is supported by the recevier. |
|
1403 | 1019 |
This has to be redefined in concrete subclasses." |
611 | 1020 |
|
1021 |
^ self subclassResponsibility |
|
1403 | 1022 |
|
1023 |
"Modified: 15.5.1996 / 17:54:54 / cg" |
|
611 | 1024 |
! |
1025 |
||
1026 |
lineLength |
|
1403 | 1027 |
"return the lineLength which `looks good' when pretty printed |
1028 |
text is sent to this stream. |
|
1029 |
This has NO meaning whatsoever to regular streams; |
|
1030 |
however, it may be used as a layout hint for prettyprinting functions |
|
1031 |
- for compatibility with TextCollectors, which returns its views actual |
|
1032 |
line length, and allows the prettyprinter to wrap at that position." |
|
611 | 1033 |
|
1034 |
^ 80 |
|
1403 | 1035 |
|
1036 |
"Modified: 15.5.1996 / 17:57:01 / cg" |
|
611 | 1037 |
! ! |
1038 |
||
62 | 1039 |
!Stream methodsFor:'reading'! |
1 | 1040 |
|
1041 |
next |
|
1042 |
"return the next element of the stream |
|
1043 |
- we do not know here how to do it, it must be redefined in subclass" |
|
1044 |
||
1045 |
^ self subclassResponsibility |
|
1046 |
! |
|
1047 |
||
1048 |
next:count |
|
1403 | 1049 |
"return the next count elements of the stream as aCollection, |
1050 |
which depends on the streams type - (see #contentsSpecies)." |
|
1 | 1051 |
|
329 | 1052 |
|answerStream |
285 | 1053 |
cnt "{ Class: SmallInteger }" | |
1 | 1054 |
|
329 | 1055 |
answerStream := WriteStream on:(self contentsSpecies new). |
285 | 1056 |
cnt := count. |
1057 |
1 to:cnt do:[:index | |
|
2332 | 1058 |
answerStream nextPut:(self next) |
1 | 1059 |
]. |
329 | 1060 |
^ answerStream contents |
1 | 1061 |
|
275 | 1062 |
" |
1063 |
(ReadStream on:#(1 2 3 4 5)) next:3 |
|
1064 |
(ReadStream on:'hello') next:3 |
|
1065 |
" |
|
1403 | 1066 |
|
1067 |
"Modified: 15.5.1996 / 17:57:58 / cg" |
|
1 | 1068 |
! |
1069 |
||
285 | 1070 |
nextAvailable:count |
1403 | 1071 |
"return the next count elements of the stream as aCollection. |
285 | 1072 |
If the stream reaches the end before count elements have been read, |
1403 | 1073 |
return what is available. (i.e. a shorter collection). |
1074 |
The type of collection is speciefied in #contentsSpecies." |
|
285 | 1075 |
|
345 | 1076 |
|answerStream |
285 | 1077 |
cnt "{ Class: SmallInteger }"| |
1078 |
||
329 | 1079 |
answerStream := WriteStream on:(self contentsSpecies new). |
285 | 1080 |
cnt := count. |
1081 |
1 to:cnt do:[:index | |
|
2332 | 1082 |
self atEnd ifTrue:[ |
1083 |
^ answerStream contents |
|
1084 |
]. |
|
1085 |
answerStream nextPut:(self next) |
|
285 | 1086 |
]. |
329 | 1087 |
^ answerStream contents |
285 | 1088 |
|
1089 |
" |
|
1090 |
(ReadStream on:#(1 2 3 4 5)) nextAvailable:3 |
|
1091 |
(ReadStream on:#(1 2 3 4 5)) nextAvailable:10 |
|
1092 |
(ReadStream on:'hello') nextAvailable:3 |
|
1093 |
(ReadStream on:'hello') nextAvailable:10 |
|
1094 |
" |
|
1403 | 1095 |
|
1096 |
"Modified: 15.5.1996 / 17:58:42 / cg" |
|
285 | 1097 |
! |
1098 |
||
1 | 1099 |
nextMatchFor:anObject |
62 | 1100 |
"read an element from the receiver, return true if it was equal to |
1403 | 1101 |
the argument, anObject; false otherwise." |
62 | 1102 |
|
1103 |
^ (self next = anObject) |
|
1104 |
||
1105 |
" |
|
1106 |
|s| |
|
1107 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1108 |
s nextMatchFor:2 |
|
1109 |
" |
|
1110 |
" |
|
1111 |
|s| |
|
1112 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1113 |
s nextMatchFor:2. |
|
1114 |
s nextMatchFor:2 |
|
1115 |
" |
|
1403 | 1116 |
|
1117 |
"Modified: 15.5.1996 / 17:58:57 / cg" |
|
62 | 1118 |
! |
1119 |
||
2253
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1120 |
nextUpTo:anObject |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1121 |
"read a collection of all objects up-to anObject and return these |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1122 |
elements, but excluding anObject. |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1123 |
The next read operation will return anObject. |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1124 |
If anObject is not encountered, all elements up to the end are read |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1125 |
and returned, and the stream is positioned at the end. |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1126 |
Compare this with #upTo: which positions behind anObject" |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1127 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1128 |
|answerStream element| |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1129 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1130 |
answerStream := WriteStream on:(self contentsSpecies new). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1131 |
[self atEnd] whileFalse:[ |
2332 | 1132 |
element := self peek. |
1133 |
(element = anObject) ifTrue: [ |
|
1134 |
^ answerStream contents |
|
1135 |
]. |
|
1136 |
answerStream nextPut:element. |
|
1137 |
self next. |
|
2253
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1138 |
]. |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1139 |
^ answerStream contents |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1140 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1141 |
" |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1142 |
|s| |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1143 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1144 |
Transcript showCR:(s nextUpTo:4). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1145 |
Transcript showCR:s next |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1146 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1147 |
|s| |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1148 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1149 |
Transcript showCR:(s upTo:4). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1150 |
Transcript showCR:s next |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1151 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1152 |
|s| |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1153 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1154 |
Transcript showCR:(s nextUpTo:9). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1155 |
Transcript showCR:s next |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1156 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1157 |
|s| |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1158 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1159 |
Transcript showCR:(s upTo:9). |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1160 |
Transcript showCR:s next |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1161 |
" |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1162 |
|
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1163 |
"Created: 24.1.1997 / 14:08:35 / cg" |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1164 |
"Modified: 24.1.1997 / 14:09:49 / cg" |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1165 |
! |
2ba9ca59f25d
added #nextUpTo: - occasionally, you want to read the separator
Claus Gittinger <cg@exept.de>
parents:
2152
diff
changeset
|
1166 |
|
62 | 1167 |
skip:count |
1168 |
"skip count objects, return the receiver" |
|
1169 |
||
345 | 1170 |
|n "{ Class: SmallInteger }"| |
1171 |
||
1172 |
n := count. |
|
1173 |
||
62 | 1174 |
"dont know how to unread ..." |
345 | 1175 |
n < 0 ifTrue:[ |
2332 | 1176 |
self error:'stream is not positionable'. |
1177 |
^ self |
|
62 | 1178 |
]. |
345 | 1179 |
n timesRepeat:self next |
62 | 1180 |
|
1181 |
" |
|
1182 |
|s| |
|
1183 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1184 |
s skip:4. |
|
1185 |
s next |
|
1186 |
" |
|
1187 |
! |
|
1188 |
||
1189 |
skipFor:anObject |
|
1403 | 1190 |
"skip all objects up-to and including anObject; |
1191 |
return the element after anObject." |
|
62 | 1192 |
|
1193 |
(self skipThrough:anObject) notNil ifTrue:[ |
|
2332 | 1194 |
^ self next |
62 | 1195 |
]. |
1196 |
^ nil |
|
1197 |
||
1198 |
" |
|
1199 |
|s| |
|
1200 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1201 |
s skipFor:4. |
|
1202 |
" |
|
1403 | 1203 |
|
1204 |
"Modified: 15.5.1996 / 17:59:23 / cg" |
|
62 | 1205 |
! |
1206 |
||
1207 |
skipThrough:anObject |
|
77 | 1208 |
"skip all objects up-to and including anObject. Return the receiver if |
671 | 1209 |
skip was successful, otherwise (i.e. if not found) return nil. |
62 | 1210 |
The next read operation will return the element after anObject." |
1 | 1211 |
|
1212 |
|nextElement| |
|
1213 |
||
1214 |
[self atEnd] whileFalse:[ |
|
216 | 1215 |
nextElement := self next. |
1216 |
(nextElement = anObject) ifTrue: [ ^ self ] |
|
1 | 1217 |
]. |
1218 |
^ nil |
|
2 | 1219 |
|
62 | 1220 |
" |
1221 |
|s| |
|
1222 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1223 |
s skipThrough:4. |
|
1224 |
s next |
|
1225 |
" |
|
77 | 1226 |
! |
1227 |
||
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1228 |
skipThroughAll:aCollection |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1229 |
"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
|
1230 |
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
|
1231 |
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
|
1232 |
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
|
1233 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1234 |
|buffer l first idx| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1235 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1236 |
l := aCollection size. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1237 |
first := aCollection at:1. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1238 |
[self atEnd] whileFalse:[ |
2332 | 1239 |
buffer isNil ifTrue:[ |
1240 |
buffer := self nextAvailable:l. |
|
1241 |
]. |
|
1242 |
buffer = aCollection ifTrue:[ |
|
1243 |
^ self |
|
1244 |
]. |
|
1245 |
idx := buffer indexOf:first startingAt:2. |
|
1246 |
idx == 0 ifTrue:[ |
|
1247 |
buffer := nil |
|
1248 |
] ifFalse:[ |
|
1249 |
buffer := (buffer copyFrom:idx) , (self nextAvailable:(idx - 1)) |
|
1250 |
] |
|
2152
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1251 |
]. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1252 |
^ nil |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1253 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1254 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1255 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1256 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1257 |
s skipThroughAll:'901'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1258 |
s upToEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1259 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1260 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1261 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1262 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1263 |
s skipThroughAll:'1234'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1264 |
s upToEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1265 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1266 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1267 |
|s| |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1268 |
s := ReadStream on:'12345678901234567890'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1269 |
s skipThroughAll:'999'. |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1270 |
s atEnd |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1271 |
" |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1272 |
|
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1273 |
"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
|
1274 |
"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
|
1275 |
! |
6a42beaf7cc5
added a skipThroughAll:, which does not depend on being positionable.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
1276 |
|
611 | 1277 |
through:anObject |
1278 |
"read a collection of all objects up-to anObject and return these |
|
1279 |
elements, including anObject. |
|
1280 |
The next read operation will return the element after anObject. |
|
1409 | 1281 |
If anObject is not encountered, all elements up to the end are read |
1282 |
and returned. |
|
611 | 1283 |
Compare this with #upTo: which also reads up to some object |
1284 |
and also positions behind it, but does not include it in the returned |
|
1285 |
value." |
|
1286 |
||
1287 |
|answerStream element| |
|
1288 |
||
1289 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1290 |
[self atEnd] whileFalse:[ |
|
2332 | 1291 |
element := self next. |
1292 |
answerStream nextPut:element. |
|
1293 |
(element = anObject) ifTrue: [ |
|
1294 |
^ answerStream contents |
|
1295 |
] |
|
611 | 1296 |
]. |
1297 |
^ answerStream contents |
|
1298 |
||
1299 |
" |
|
1300 |
|s| |
|
1301 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 1302 |
Transcript showCR:(s through:4). |
1303 |
Transcript showCR:s next |
|
1409 | 1304 |
|
1305 |
|s| |
|
1306 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 1307 |
Transcript showCR:(s through:9). |
1308 |
Transcript showCR:s next |
|
1409 | 1309 |
|
611 | 1310 |
|s| |
1311 |
s := ReadStream on:'hello world'. |
|
1422 | 1312 |
Transcript showCR:(s through:Character space). |
1313 |
Transcript showCR:(s upToEnd) |
|
611 | 1314 |
" |
1409 | 1315 |
|
1316 |
"Modified: 17.5.1996 / 08:51:40 / cg" |
|
611 | 1317 |
! |
1318 |
||
1548 | 1319 |
throughAll:aCollection |
1320 |
"read & return a collection of all objects up-to and including |
|
1321 |
a subcollection given by aCollection. |
|
1322 |
(i.e. read until a ``substring'' is encountered.) |
|
1323 |
The next read operation will return the element after aCollection. |
|
1324 |
If aCollection is not encountered, all elements up to the end are read |
|
1325 |
and returned." |
|
1326 |
||
1327 |
|answerStream element last rslt| |
|
1328 |
||
1329 |
last := aCollection last. |
|
1330 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1331 |
[self atEnd] whileFalse:[ |
|
2332 | 1332 |
element := self next. |
1333 |
answerStream nextPut:element. |
|
1334 |
element == last ifTrue:[ |
|
1335 |
((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
|
1336 |
^ rslt |
|
1337 |
] |
|
1338 |
]. |
|
1548 | 1339 |
]. |
1340 |
^ answerStream contents |
|
1341 |
||
1342 |
" |
|
1343 |
|s| |
|
1344 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1345 |
Transcript showCR:(s throughAll:#(4 4 4)). |
|
1346 |
Transcript showCR:s next |
|
1347 |
||
1348 |
|s| |
|
1349 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1350 |
Transcript showCR:(s throughAll:#(4 5 6)). |
|
1351 |
Transcript showCR:s next |
|
1352 |
||
1353 |
|s| |
|
1354 |
s := ReadStream on:'hello world, this is some text'. |
|
1355 |
Transcript showCR:(s throughAll:'world'). |
|
1356 |
Transcript showCR:(s throughAll:'some'). |
|
1357 |
Transcript showCR:s upToEnd. |
|
1358 |
" |
|
1359 |
||
1360 |
"Modified: 15.7.1996 / 09:08:07 / cg" |
|
1361 |
! |
|
1362 |
||
427 | 1363 |
upTo:anObject |
1364 |
"read a collection of all objects up-to anObject and return these |
|
1365 |
elements, but excluding anObject. |
|
1366 |
The next read operation will return the element after anObject. |
|
1409 | 1367 |
If anObject is not encountered, all elements up to the end are read |
1368 |
and returned. |
|
427 | 1369 |
Compare this with #through: which also reads up to some object |
1370 |
and also positions behind it, but DOES include it in the returned |
|
1371 |
value." |
|
1372 |
||
1373 |
|answerStream element| |
|
1374 |
||
1375 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1376 |
[self atEnd] whileFalse:[ |
|
2332 | 1377 |
element := self next. |
1378 |
(element = anObject) ifTrue: [ |
|
1379 |
^ answerStream contents |
|
1380 |
]. |
|
1381 |
answerStream nextPut:element. |
|
427 | 1382 |
]. |
1383 |
^ answerStream contents |
|
1384 |
||
1385 |
" |
|
1386 |
|s| |
|
1387 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
|
1422 | 1388 |
Transcript showCR:(s upTo:4). |
1389 |
Transcript showCR:s next |
|
427 | 1390 |
|
1391 |
|s| |
|
1409 | 1392 |
s := ReadStream on:#(1 2 3 4 5 6 7 8). |
1422 | 1393 |
Transcript showCR:(s upTo:9). |
1394 |
Transcript showCR:s next |
|
1409 | 1395 |
|
1396 |
|s| |
|
427 | 1397 |
s := ReadStream on:'hello world'. |
1422 | 1398 |
Transcript showCR:(s upTo:Character space). |
1399 |
Transcript showCR:(s upToEnd) |
|
427 | 1400 |
|
1401 |
(ReadStream on:'12345678905') upTo:$5; upTo:$5 |
|
1402 |
||
1403 |
(ReadStream on:'123456') upTo:$7 |
|
1404 |
||
1405 |
(ReadStream on:#(1 2 3 4 5 6)) upTo:4 |
|
1406 |
||
1407 |
(ReadStream on:'line 1 |
|
2332 | 1408 |
line 2') upTo:Character cr |
427 | 1409 |
|
1410 |
'Makefile' asFilename readStream upTo:Character cr;upTo:Character cr |
|
1411 |
" |
|
1409 | 1412 |
|
1413 |
"Modified: 17.5.1996 / 08:51:56 / cg" |
|
427 | 1414 |
! |
1415 |
||
2894 | 1416 |
upToAll:aCollection |
1417 |
"read a collection of all objects up-to a element which is contained in |
|
1418 |
aCollectionOfObjects and return these elements, but excluding the matching one. |
|
1419 |
The next read operation will return the element after anObject. |
|
1420 |
If no such element is encountered, all elements up to the end are read |
|
1421 |
and returned. |
|
1422 |
Compare this with #throughAll: which also reads up to some object |
|
1423 |
and also positions behind it, but DOES include it in the returned |
|
1424 |
value." |
|
1425 |
||
1426 |
<resource: #tobevalidated> |
|
1427 |
||
1428 |
|answerStream element last rslt| |
|
1429 |
||
1430 |
last := aCollection last. |
|
1431 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1432 |
[self atEnd] whileFalse:[ |
|
1433 |
element := self next. |
|
1434 |
answerStream nextPut:element. |
|
1435 |
element == last ifTrue:[ |
|
1436 |
((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
|
1437 |
self position:(self position - aCollection size). |
|
1438 |
^ rslt copyWithoutLast:aCollection size |
|
1439 |
] |
|
1440 |
]. |
|
1441 |
]. |
|
1442 |
^ answerStream contents |
|
1443 |
||
1444 |
" |
|
1445 |
|s| |
|
1446 |
s := ReadStream on:'hello world world'. |
|
1447 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
|
1448 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
|
1449 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
|
1450 |
" |
|
1451 |
" |
|
1452 |
|s| |
|
1453 |
s := ReadStream on:'hello world'. |
|
1454 |
Transcript show:'<'; show:(s upToAll:'xx'); showCR:'>'. |
|
1455 |
Transcript showCR:s atEnd. |
|
1456 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
|
1457 |
" |
|
1458 |
||
1459 |
"Modified: 30.8.1997 / 03:02:11 / cg" |
|
1460 |
! |
|
1461 |
||
1462 |
upToAny:aCollectionOfObjects |
|
2420 | 1463 |
"read a collection of all objects up-to a element which is contained in |
1464 |
aCollectionOfObjects and return these elements, but excluding the matching one. |
|
1465 |
The next read operation will return the element after anObject. |
|
1466 |
If no such element is encountered, all elements up to the end are read |
|
1467 |
and returned. |
|
1468 |
Compare this with #throughAll: which also reads up to some object |
|
1469 |
and also positions behind it, but DOES include it in the returned |
|
1470 |
value." |
|
1471 |
||
1472 |
|answerStream element| |
|
1473 |
||
1474 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1475 |
[self atEnd] whileFalse:[ |
|
1476 |
element := self next. |
|
1477 |
(aCollectionOfObjects includes:element) ifTrue: [ |
|
1478 |
^ answerStream contents |
|
1479 |
]. |
|
1480 |
answerStream nextPut:element. |
|
1481 |
]. |
|
1482 |
^ answerStream contents |
|
1483 |
||
1484 |
" |
|
1485 |
|s| |
|
1486 |
s := ReadStream on:'hello world'. |
|
1487 |
Transcript showCR:(s upToAll:(Array with:Character space)). |
|
1488 |
Transcript showCR:(s upToEnd) |
|
1489 |
||
1490 |
'Makefile' asFilename readStream upToAll:($A to:$Z) |
|
1491 |
" |
|
1492 |
||
1493 |
"Modified: 26.2.1997 / 12:24:09 / cg" |
|
2894 | 1494 |
"Created: 30.8.1997 / 03:02:05 / cg" |
2420 | 1495 |
! |
1496 |
||
77 | 1497 |
upToEnd |
1498 |
"return a collection of the elements up-to the end. |
|
1403 | 1499 |
Return an empty collection, if the stream-end is already at the end." |
77 | 1500 |
|
1501 |
|answerStream| |
|
1502 |
||
1503 |
answerStream := WriteStream on:(self contentsSpecies new). |
|
1504 |
[self atEnd] whileFalse:[ |
|
2332 | 1505 |
answerStream nextPut:(self next) |
77 | 1506 |
]. |
1507 |
^ answerStream contents |
|
1508 |
||
275 | 1509 |
" |
1510 |
(ReadStream on:'1234567890') upToEnd |
|
1511 |
('123456' readStream) next; next; upToEnd |
|
427 | 1512 |
('1 23456' readStream) upTo:Character space; upToEnd |
1403 | 1513 |
('12' readStream) next; next; upToEnd |
275 | 1514 |
" |
1403 | 1515 |
|
1516 |
"Modified: 15.5.1996 / 18:00:39 / cg" |
|
611 | 1517 |
! ! |
77 | 1518 |
|
3084 | 1519 |
!Stream methodsFor:'reading - strings'! |
1520 |
||
1521 |
nextAlphaNumericWord |
|
1522 |
"read the next word (i.e. up to non letter-or-digit). |
|
1523 |
Return a string containing those characters. |
|
1524 |
Any leading whitespace is skipped. |
|
1525 |
This method does not advance over any non-alphanumeric characters; |
|
1526 |
i.e. it will stick and continue to continue to return nil in this case. |
|
1527 |
Only call for it in a loop, AFTER you have checked for |
|
1528 |
the next character to really be alphanumeric (using #peek)" |
|
1529 |
||
1530 |
|s c| |
|
1531 |
||
1532 |
[self atEnd not |
|
1533 |
and:[(c := self peek) isSeparator]] whileTrue:[ |
|
1534 |
self next |
|
1535 |
]. |
|
1536 |
||
1537 |
self atEnd ifTrue:[^ nil]. |
|
1538 |
||
1539 |
s := ''. |
|
1540 |
||
1541 |
[self atEnd not |
|
1542 |
and:[(c := self peek) isLetterOrDigit]] whileTrue:[ |
|
1543 |
s := s copyWith:c. |
|
1544 |
self next |
|
1545 |
]. |
|
1546 |
||
1547 |
s size == 0 ifTrue:[^ nil]. |
|
1548 |
^ s. |
|
1549 |
||
1550 |
" |
|
1551 |
|s| |
|
1552 |
||
1553 |
s := 'hello world 1234 foo1 foo2' readStream. |
|
1554 |
[s atEnd] whileFalse:[ |
|
1555 |
Transcript showCR:(s nextAlphaNumericWord). |
|
1556 |
]. |
|
1557 |
||
1558 |
||
1559 |
notice: streams end never reached this way (sticking at the '+'-character: |
|
1560 |
|s| |
|
1561 |
||
1562 |
s := 'hello world 1234 foo1+foo2' readStream. |
|
1563 |
10 timesRepeat:[ |
|
1564 |
Transcript showCR:(s nextAlphaNumericWord). |
|
1565 |
]. |
|
1566 |
" |
|
1567 |
||
1568 |
"Modified: 15.5.1996 / 17:51:42 / cg" |
|
1569 |
! |
|
1570 |
||
1571 |
nextLine |
|
1572 |
"return the characters upTo (but excluding) the next cr (carriage return) |
|
1573 |
character (i.e. read a single line of text). |
|
1574 |
Added for protocol compatibility with externalStreams." |
|
1575 |
||
1576 |
^ self upTo:Character cr. |
|
1577 |
||
1578 |
"Modified: 11.7.1996 / 10:03:56 / cg" |
|
1579 |
! |
|
1580 |
||
1581 |
nextWord |
|
1582 |
"return the next characters which form an alphanumeric word |
|
1583 |
(i.e. everything upTo (but excluding) the next non alphanumeric |
|
1584 |
element)" |
|
1585 |
||
1586 |
^ self nextAlphaNumericWord |
|
1587 |
||
1588 |
"Modified: 15.5.1996 / 17:39:32 / cg" |
|
1589 |
! ! |
|
1590 |
||
611 | 1591 |
!Stream methodsFor:'testing'! |
77 | 1592 |
|
611 | 1593 |
atEnd |
1594 |
"return true if the end of the stream has been reached; |
|
1595 |
- we do not know here how to do it, it must be redefined in subclass" |
|
77 | 1596 |
|
611 | 1597 |
^ self subclassResponsibility |
1 | 1598 |
! ! |
1599 |
||
62 | 1600 |
!Stream methodsFor:'writing'! |
1 | 1601 |
|
339 | 1602 |
commit |
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1603 |
"alias for flush -- ST80 compatibility" |
339 | 1604 |
|
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1605 |
^ self flush |
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1606 |
|
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1607 |
"Modified: 7.5.1996 / 23:55:39 / stefan" |
339 | 1608 |
! |
1609 |
||
611 | 1610 |
cr |
1403 | 1611 |
"append a carriage-return to the stream. |
1612 |
This is only allowed, if the receiver supports writing." |
|
611 | 1613 |
|
1614 |
self nextPut:(Character cr) |
|
1403 | 1615 |
|
1616 |
"Modified: 15.5.1996 / 18:01:21 / cg" |
|
611 | 1617 |
! |
1618 |
||
1619 |
crTab |
|
1620 |
"append a carriage-return followed by a tab to the stream. |
|
1403 | 1621 |
Same as crtab for ST/X backward compatibility. |
1622 |
This is only allowed, if the receiver supports writing." |
|
611 | 1623 |
|
1624 |
self obsoleteMethodWarning:'use crTab'. |
|
1625 |
self crtab |
|
1403 | 1626 |
|
1627 |
"Modified: 15.5.1996 / 18:01:28 / cg" |
|
611 | 1628 |
! |
1629 |
||
1630 |
crtab |
|
1403 | 1631 |
"append a carriage-return followed by a tab to the stream. |
1632 |
This is only allowed, if the receiver supports writing." |
|
1 | 1633 |
|
611 | 1634 |
self crtab:1 |
1403 | 1635 |
|
1636 |
"Modified: 15.5.1996 / 18:01:35 / cg" |
|
611 | 1637 |
! |
1638 |
||
1639 |
crtab:n |
|
1403 | 1640 |
"append a carriage-return followed by n tabs to the stream. |
1641 |
This is only allowed, if the receiver supports writing." |
|
611 | 1642 |
|
1643 |
self nextPut:(Character cr). |
|
1644 |
self next:n put:(Character tab) |
|
1403 | 1645 |
|
1646 |
"Modified: 15.5.1996 / 18:01:39 / cg" |
|
611 | 1647 |
! |
1648 |
||
1649 |
endEntry |
|
1650 |
"ignored here - for compatibility with Transcript" |
|
1651 |
||
1652 |
^ self |
|
1653 |
! |
|
1654 |
||
1655 |
ff |
|
1403 | 1656 |
"append a form-feed (new-pagee) to the receiver-stream. |
1657 |
This is only allowed, if the receiver supports writing." |
|
611 | 1658 |
|
1659 |
self nextPut:(Character ff) |
|
1403 | 1660 |
|
1661 |
"Modified: 15.5.1996 / 18:01:47 / cg" |
|
1 | 1662 |
! |
1663 |
||
701 | 1664 |
flush |
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1665 |
"write out all unbuffered data - ignored here, but added |
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1666 |
to make internalStreams protocol compatible with externalStreams" |
701 | 1667 |
|
1462
7196fe152248
Cleanup #flush and #commit handling.
Stefan Vogel <sv@exept.de>
parents:
1448
diff
changeset
|
1668 |
"Modified: 7.5.1996 / 23:54:53 / stefan" |
701 | 1669 |
! |
1670 |
||
1 | 1671 |
next:count put:anObject |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1672 |
"put the argument, anObject count times onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1673 |
This is only allowed, if the receiver supports writing." |
1 | 1674 |
|
345 | 1675 |
|n "{ Class: SmallInteger }"| |
1676 |
||
1677 |
n := count. |
|
1678 |
n timesRepeat:[self nextPut:anObject]. |
|
1 | 1679 |
^ anObject |
62 | 1680 |
|
1681 |
" |
|
1682 |
|s| |
|
1683 |
||
1684 |
s := WriteStream on:#(). |
|
1685 |
s nextPut:1. |
|
1686 |
s next:5 put:2. |
|
1687 |
s nextPut:3. |
|
1688 |
s contents |
|
1689 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1690 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1691 |
"Modified: 11.7.1996 / 10:00:13 / cg" |
1 | 1692 |
! |
1693 |
||
611 | 1694 |
nextPut:anObject |
1695 |
"put the argument, anObject onto the receiver |
|
1696 |
- we do not know here how to do it, it must be redefined in subclass" |
|
1697 |
||
1698 |
^ self subclassResponsibility |
|
1699 |
! |
|
1700 |
||
1 | 1701 |
nextPutAll:aCollection |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1702 |
"put all elements of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1703 |
This is only allowed, if the receiver supports writing." |
1 | 1704 |
|
1705 |
aCollection do:[:element | |
|
2332 | 1706 |
self nextPut:element |
1 | 1707 |
]. |
1708 |
^ aCollection |
|
62 | 1709 |
|
1710 |
" |
|
1711 |
|s| |
|
1712 |
||
1713 |
s := WriteStream on:#(). |
|
1714 |
s nextPutAll:(1 to:5). |
|
1715 |
s nextPutAll:#('one' 'two' 'three'). |
|
1716 |
s contents |
|
1717 |
" |
|
1718 |
" |
|
1719 |
|s| |
|
1720 |
||
1721 |
s := WriteStream on:(String new). |
|
1722 |
s nextPutAll:($a to:$f). |
|
1723 |
s nextPutAll:'one '; |
|
1724 |
nextPutAll:'two '; |
|
1725 |
nextPutAll:'three'. |
|
1726 |
s contents |
|
1727 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1728 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1729 |
"Modified: 11.7.1996 / 10:00:21 / cg" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1730 |
! |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1731 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1732 |
nextPutAll:aCollection startingAt:first |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1733 |
"append the elements starting with index to the end |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1734 |
of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1735 |
This is only allowed, if the receiver supports writing." |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1736 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1737 |
self nextPutAll:aCollection startingAt:first to:(aCollection size). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1738 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1739 |
" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1740 |
|s| |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1741 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1742 |
s := WriteStream on:#(). |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1743 |
s nextPutAll:#('one' 'two' 'three' 'four' 'five') startingAt:2. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1744 |
s contents |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1745 |
" |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1746 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1747 |
"Modified: 11.7.1996 / 10:00:28 / cg" |
1 | 1748 |
! |
1749 |
||
1750 |
nextPutAll:aCollection startingAt:first to:last |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1751 |
"append the elements with index from first to last |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1752 |
of the argument, aCollection onto the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1753 |
This is only allowed, if the receiver supports writing." |
1 | 1754 |
|
1755 |
aCollection from:first to:last do:[:element | |
|
2332 | 1756 |
self nextPut:element |
1 | 1757 |
]. |
1758 |
^ aCollection |
|
62 | 1759 |
|
1760 |
" |
|
1761 |
|s| |
|
1762 |
||
1763 |
s := WriteStream on:#(). |
|
1764 |
s nextPutAll:#('one' 'two' 'three' 'four' 'five') startingAt:2 to:4. |
|
1765 |
s contents |
|
1766 |
" |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1767 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1768 |
"Modified: 11.7.1996 / 10:00:32 / cg" |
1 | 1769 |
! |
1770 |
||
743 | 1771 |
nextPutLine:aCollection |
1772 |
"put all elements of the argument, aCollection onto the receiver, |
|
1949 | 1773 |
and append a cr (carriage return). |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1774 |
This is only useful with character streams in textMode, |
1949 | 1775 |
and only allowed, if the receiver supports writing." |
743 | 1776 |
|
1777 |
self nextPutAll:aCollection. |
|
1778 |
self cr. |
|
1779 |
||
1780 |
"Created: 13.12.1995 / 10:49:17 / cg" |
|
1949 | 1781 |
"Modified: 8.11.1996 / 23:53:41 / cg" |
743 | 1782 |
! |
1783 |
||
611 | 1784 |
print:anObject |
1785 |
"append a printed representation of anObject to the receiver. |
|
1403 | 1786 |
Same as 'anObject printOn:self'; Added for ST-80 compatibility." |
2 | 1787 |
|
611 | 1788 |
anObject printOn:self |
1403 | 1789 |
|
1790 |
" |
|
1791 |
|s| |
|
1792 |
||
1793 |
s := WriteStream on:''. |
|
1794 |
s nextPutAll:'one '; |
|
1795 |
print:1; |
|
1796 |
nextPutAll:' two '; |
|
1797 |
print:2. |
|
1798 |
||
1799 |
s contents |
|
1800 |
" |
|
1801 |
||
1802 |
"Modified: 15.5.1996 / 18:06:06 / cg" |
|
2 | 1803 |
! |
1804 |
||
1403 | 1805 |
show:something |
1806 |
"append a printed representation of the argument to the stream. |
|
1807 |
This makes streams somewhat compatible to TextCollectors and |
|
1808 |
allows you to say: |
|
2332 | 1809 |
Smalltalk at:#Transcript put:Stdout |
1422 | 1810 |
or to use #show:/#showCR: with internal or external streams." |
1 | 1811 |
|
1403 | 1812 |
^ self nextPutAll:something printString |
1813 |
||
1814 |
"Modified: 15.5.1996 / 18:04:48 / cg" |
|
1 | 1815 |
! |
1816 |
||
1414 | 1817 |
showCR:aString |
1403 | 1818 |
"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
|
1819 |
and append a newline character. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1820 |
This makes streams somewhat compatible to TextCollectors and |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1821 |
allows you to say: |
2332 | 1822 |
Smalltalk at:#Transcript put:Stdout |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1823 |
or to use #show:/#showCR: with internal or external streams." |
1 | 1824 |
|
1825 |
self show:aString. |
|
1826 |
self cr |
|
1403 | 1827 |
|
1414 | 1828 |
"Created: 18.5.1996 / 15:34:17 / cg" |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1829 |
"Modified: 11.7.1996 / 10:01:27 / cg" |
1414 | 1830 |
! |
1831 |
||
1832 |
showCr:aString |
|
1833 |
"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
|
1834 |
and append a newline character. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1835 |
This is obsolete ST/X backward compatibility; use #showCR:" |
1414 | 1836 |
|
1837 |
self obsoleteMethodWarning:'use #showCR:'. |
|
1838 |
self showCR:aString. |
|
1839 |
||
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1840 |
"Modified: 11.7.1996 / 10:01:50 / cg" |
62 | 1841 |
! |
1842 |
||
1843 |
space |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1844 |
"append a space character to the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1845 |
This is only allowed, if the receiver supports writing." |
62 | 1846 |
|
1847 |
self nextPut:(Character space) |
|
1403 | 1848 |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1849 |
"Modified: 11.7.1996 / 10:02:06 / cg" |
62 | 1850 |
! |
1851 |
||
1852 |
spaces:count |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1853 |
"append count space-characters to the receiver. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1854 |
This is only allowed, if the receiver supports writing." |
62 | 1855 |
|
1856 |
self next:count put:(Character space) |
|
1403 | 1857 |
|
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1858 |
"Modified: 11.7.1996 / 10:02:10 / cg" |
62 | 1859 |
! |
1860 |
||
611 | 1861 |
store:anObject |
1862 |
"append a printed representation of anObject to the receiver, |
|
1403 | 1863 |
from which the receiver can be reconstructed (i.e. its storeString). |
1864 |
Same as 'anObject storeOn:self'; Added for ST-80 compatibility." |
|
77 | 1865 |
|
611 | 1866 |
anObject storeOn:self |
1403 | 1867 |
|
1868 |
"Modified: 15.5.1996 / 18:05:55 / cg" |
|
77 | 1869 |
! |
1870 |
||
611 | 1871 |
tab |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1872 |
"append a tab-character to the stream. |
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1873 |
This is only allowed, if the receiver supports writing." |
77 | 1874 |
|
611 | 1875 |
self nextPut:(Character tab) |
1538
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1876 |
|
b62f12073403
commentary; added #nextPutAll:startingAt:
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1877 |
"Modified: 11.7.1996 / 10:02:20 / cg" |
2443 | 1878 |
! |
1879 |
||
1880 |
tab:count |
|
1881 |
"append count tab-characters to the receiver. |
|
1882 |
This is only allowed, if the receiver supports writing." |
|
1883 |
||
1884 |
self next:count put:(Character tab) |
|
1885 |
||
1886 |
"Modified: 11.7.1996 / 10:02:10 / cg" |
|
77 | 1887 |
! ! |
1888 |
||
1949 | 1889 |
!Stream class methodsFor:'documentation'! |
701 | 1890 |
|
1891 |
version |
|
3084 | 1892 |
^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.62 1997-11-02 18:30:50 cg Exp $' |
701 | 1893 |
! ! |
611 | 1894 |
Stream initialize! |