author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 22 Sep 2015 16:28:42 +0100 | |
branch | jv |
changeset 18759 | c1217211909c |
parent 18260 | e55af242e134 |
child 19412 | 1e842c25e51e |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 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 |
" |
|
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
13 |
|
17559 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
57 | 16 |
PeekableStream subclass:#PositionableStream |
973 | 17 |
instanceVariableNames:'collection position readLimit writeLimit' |
8443
7bc4348c059e
fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents:
8363
diff
changeset
|
18 |
classVariableNames:'ZeroPosition InvalidPositionErrorSignal' |
973 | 19 |
poolDictionaries:'' |
20 |
category:'Streams' |
|
1 | 21 |
! |
22 |
||
1897 | 23 |
!PositionableStream class methodsFor:'documentation'! |
88 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
159 | 28 |
All Rights Reserved |
1 | 29 |
|
88 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
10 | 38 |
|
88 | 39 |
documentation |
40 |
" |
|
41 |
Instances of PositionableStream allow positioning the read pointer. |
|
42 |
The PositionableStream class also adds methods for source-chunk reading |
|
43 |
and writing, and for filing-in/out of source code. |
|
3249
8401c3e42165
checkin to force re-checkout.
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
44 |
|
88 | 45 |
This is an abstract class. |
1295 | 46 |
|
4405 | 47 |
Compatibility Notice: |
9434 | 48 |
In previous versions of ST/X, streams started with a 1-position (i.e. as in collections), |
49 |
while ST-80 has always been using 0-based postions for streams and 1-based positions for collections. |
|
4405 | 50 |
|
17559 | 51 |
THIS CERTAINLY IS BAD. |
52 |
||
53 |
Although this is confusing ST/X has been changed to now also uses 0-based stream positioning. |
|
9434 | 54 |
|
17559 | 55 |
[caveat:] |
56 |
Basing capabilities like readability/writability/positionability/peekability on inheritance makes |
|
57 |
the class hierarchy ugly and leads to strange and hard to teach redefinitions (aka. NonPositionableStream |
|
58 |
below PositionableStream or ExternalReadStream under WriteStream) |
|
4405 | 59 |
|
1295 | 60 |
[author:] |
9434 | 61 |
Claus Gittinger |
88 | 62 |
" |
63 |
! ! |
|
1 | 64 |
|
1897 | 65 |
!PositionableStream class methodsFor:'initialization'! |
1 | 66 |
|
10 | 67 |
initialize |
15353 | 68 |
ZeroPosition := 0. "/ changed with stx rel5.1; |
69 |
"/ rel6.2: no longer used (i.e. 0 has now ben hardcoded) |
|
70 |
"/ class variable to be eliminated. |
|
7363 | 71 |
|
8443
7bc4348c059e
fileIn stuff moved to peekableStream
Claus Gittinger <cg@exept.de>
parents:
8363
diff
changeset
|
72 |
InvalidPositionErrorSignal isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
73 |
InvalidPositionErrorSignal := PositionOutOfBoundsError. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
74 |
InvalidPositionErrorSignal notifierString:'position out of bounds: '. |
10 | 75 |
] |
76 |
! ! |
|
1 | 77 |
|
1897 | 78 |
!PositionableStream class methodsFor:'instance creation'! |
1 | 79 |
|
80 |
on:aCollection |
|
81 |
"return a new PositionableStream streaming on aCollection" |
|
82 |
||
83 |
^ (self basicNew) on:aCollection |
|
84 |
! |
|
85 |
||
86 |
on:aCollection from:first to:last |
|
87 |
"return a new PositionableStream streaming on aCollection |
|
88 |
from first to last" |
|
89 |
||
369 | 90 |
^ (self basicNew) on:aCollection from:first to:last |
57 | 91 |
! |
92 |
||
93 |
with:aCollection |
|
94 |
"return a new PositionableStream streaming on aCollection, |
|
95 |
the stream is positioned to the end of the collection." |
|
96 |
||
362 | 97 |
^ (self basicNew) with:aCollection |
1 | 98 |
! ! |
99 |
||
3032
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
100 |
!PositionableStream class methodsFor:'Signal constants'! |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
101 |
|
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
102 |
invalidPositionErrorSignal |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
103 |
"return the signal raised if positioning is attempted to an |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
104 |
invalid position (i.e. before the begin of the stream or after |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
105 |
the end)" |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
106 |
|
8320
229adaeaf183
Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents:
8318
diff
changeset
|
107 |
^ PositionOutOfBoundsError |
3032
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
108 |
! ! |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
109 |
|
1897 | 110 |
!PositionableStream class methodsFor:'constants'! |
1 | 111 |
|
4405 | 112 |
zeroPosition |
113 |
"return the number, which marks the initial position. |
|
114 |
Compatibility Notice: |
|
9434 | 115 |
In previous versions of ST/X, streams started with a 1-position (i.e. as in collections), |
116 |
while ST-80 has always been using 0-based postions for streams and 1-based positions for collections. |
|
4405 | 117 |
|
9434 | 118 |
Although this is confusing ST/X has been changed to now also use 0-based stream positioning. |
119 |
" |
|
4405 | 120 |
|
15353 | 121 |
^ 0 |
9434 | 122 |
|
123 |
"Modified: / 13-07-2006 / 20:36:54 / cg" |
|
360 | 124 |
! ! |
125 |
||
17606 | 126 |
|
18260
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
127 |
|
7261 | 128 |
!PositionableStream methodsFor:'Compatibility-Dolphin'! |
6413 | 129 |
|
130 |
endChunk |
|
131 |
self nextPutChunkSeparator |
|
132 |
! ! |
|
133 |
||
9284 | 134 |
!PositionableStream methodsFor:'Compatibility-ST/V'! |
135 |
||
136 |
skipTo:anElement |
|
137 |
"ST/V compatibility: |
|
138 |
skip for the element given by the argument, anElement; |
|
139 |
return nil if not found, self otherwise. |
|
140 |
On a successful match, the next read will return the element after anElement." |
|
141 |
||
142 |
^ self skipThrough:anElement |
|
143 |
||
144 |
" |
|
145 |
|s| |
|
146 |
s := ReadStream on:'12345678901234567890'. |
|
147 |
s skipTo:$5. |
|
148 |
s copyFrom:1 to:(s position). |
|
149 |
s upToEnd |
|
150 |
" |
|
151 |
! ! |
|
152 |
||
16876
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
153 |
!PositionableStream methodsFor:'Compatibility-Squeak'! |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
154 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
155 |
back |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
156 |
"Go back one element and return it." |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
157 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
158 |
self position = 0 ifTrue: [self positionError]. |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
159 |
self skip: -1. |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
160 |
^ self peek |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
161 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
162 |
"Created: / 03-10-2014 / 03:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
163 |
! |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
164 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
165 |
peekBack |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
166 |
"Return the element at the previous position, without changing position. Use indirect messages in case self is a StandardFileStream." |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
167 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
168 |
| element | |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
169 |
element := self back. |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
170 |
self skip: 1. |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
171 |
^ element |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
172 |
|
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
173 |
"Created: / 03-10-2014 / 03:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18260
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
174 |
! |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
175 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
176 |
upToAnyOf: aCollection |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
177 |
"Answer a subcollection from the current access position to the |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
178 |
occurrence (if any, but not inclusive) of any object in the collection. If |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
179 |
no matching object is found, answer the entire rest of the receiver." |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
180 |
^self upToAnyOf: aCollection do: [:matchingObject | ] |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
181 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
182 |
"Created: / 21-04-2015 / 17:25:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
183 |
! |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
184 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
185 |
upToAnyOf: subcollection do: aBlock |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
186 |
"Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of any object in the collection. |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
187 |
Evaluate aBlock with this occurence as argument. |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
188 |
If no matching object is found, don't evaluate aBlock and answer the entire rest of the receiver." |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
189 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
190 |
^self collection species new: 1000 streamContents: [ :stream | |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
191 |
| ch | |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
192 |
[ self atEnd or: [ (subcollection includes: (ch := self next)) and: [aBlock value: ch. true] ] ] |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
193 |
whileFalse: [ stream nextPut: ch ] ] |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
194 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
195 |
"Created: / 21-04-2015 / 17:26:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
16876
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
196 |
! ! |
7e3ad01ca413
Added: #back / #peekBack for Squeak compatibility.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16840
diff
changeset
|
197 |
|
1 | 198 |
!PositionableStream methodsFor:'accessing'! |
199 |
||
7686
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7619
diff
changeset
|
200 |
collection |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7619
diff
changeset
|
201 |
^ collection |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7619
diff
changeset
|
202 |
! |
290cda6075ac
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
7619
diff
changeset
|
203 |
|
1 | 204 |
contents |
205 |
"return the entire contents of the stream" |
|
206 |
||
207 |
^ collection |
|
208 |
! |
|
209 |
||
210 |
peek |
|
211 |
"look ahead for and return the next element" |
|
212 |
||
213 |
|peekObject| |
|
214 |
||
215 |
peekObject := self next. |
|
10 | 216 |
self backStep. |
1 | 217 |
^ peekObject |
218 |
! |
|
219 |
||
2432 | 220 |
peekForAll:aCollection |
221 |
"return true and advance if the next elements are the same |
|
222 |
as aCollection. |
|
223 |
otherwise stay and let the position unchanged" |
|
224 |
||
225 |
|oldPos| |
|
226 |
||
227 |
oldPos := self position. |
|
228 |
(self next:(aCollection size)) = aCollection ifTrue:[ |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
229 |
^ true |
2432 | 230 |
]. |
231 |
self position:oldPos. |
|
232 |
^ false |
|
233 |
||
234 |
"Created: 1.3.1997 / 15:11:25 / cg" |
|
235 |
! |
|
236 |
||
3905
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
237 |
readLimit |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
238 |
"return the read-limit; thats the position at which EOF is returned" |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
239 |
|
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
240 |
^ readLimit |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
241 |
|
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
242 |
"Created: / 30.10.1998 / 16:47:04 / cg" |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
243 |
! |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
244 |
|
1 | 245 |
readLimit:aNumber |
369 | 246 |
"set the read-limit; thats the position at which EOF is returned" |
1 | 247 |
|
248 |
readLimit := aNumber |
|
369 | 249 |
! |
250 |
||
14934 | 251 |
setCollection:newCollection |
252 |
collection := newCollection |
|
253 |
! |
|
254 |
||
369 | 255 |
writeLimit:aNumber |
256 |
"set the writeLimit; thats the position after which writing is prohibited" |
|
257 |
||
258 |
writeLimit := aNumber |
|
10592 | 259 |
|
260 |
" |
|
261 |
|s| |
|
262 |
s := WriteStream on:String new. |
|
263 |
s nextPutAll:'hello world'. |
|
264 |
s contents. |
|
265 |
||
266 |
|s| |
|
267 |
s := WriteStream on:String new. |
|
268 |
s writeLimit:5. |
|
269 |
s nextPutAll:'hello world'. |
|
270 |
s contents. |
|
271 |
||
272 |
" |
|
273 |
||
274 |
"Modified: / 04-06-2007 / 17:21:55 / cg" |
|
1 | 275 |
! ! |
276 |
||
17611 | 277 |
!PositionableStream methodsFor:'misc functions'! |
278 |
||
279 |
copyToEndInto:aWriteStream bufferSize:bufferSize |
|
280 |
"read from the receiver, and write all data up to the end to another stream. |
|
281 |
Return the number of bytes which have been transferred. |
|
282 |
Redefined here to avoid intermediate buffers/garbage. |
|
283 |
bufferSize does not matter here." |
|
284 |
||
285 |
|cnt| |
|
286 |
||
287 |
collection notNil ifTrue:[ |
|
288 |
aWriteStream nextPutAll:collection startingAt:position+1 to:readLimit. |
|
289 |
cnt := readLimit - position. |
|
290 |
position := readLimit. |
|
291 |
^ cnt. |
|
292 |
]. |
|
293 |
^ super copyToEndInto:aWriteStream bufferSize:bufferSize. |
|
294 |
||
295 |
" |
|
296 |
|rs ws cnt| |
|
297 |
||
298 |
ws := #() writeStream. |
|
299 |
rs := #( 1 2 3 4 a nil true) readWriteStream. |
|
300 |
rs next. |
|
301 |
cnt := rs copyToEndInto:ws bufferSize:0. |
|
302 |
Transcript show:cnt; show:' '; showCR:ws contents. |
|
303 |
" |
|
304 |
! ! |
|
305 |
||
611 | 306 |
!PositionableStream methodsFor:'positioning'! |
307 |
||
308 |
backStep |
|
309 |
"move backward read position by one" |
|
310 |
||
4405 | 311 |
self position:(self position - 1) |
611 | 312 |
! |
313 |
||
16188 | 314 |
match: subCollection |
315 |
"Set the access position of the receiver to be past the next occurrence of the subCollection. |
|
316 |
Answer whether subCollection is found. |
|
317 |
No wildcards, and case does matter." |
|
318 |
||
319 |
| pattern startMatch | |
|
320 |
||
321 |
pattern := ReadStream on: subCollection. |
|
322 |
startMatch := nil. |
|
323 |
[pattern atEnd] whileFalse: [ |
|
324 |
self atEnd ifTrue: [^ false]. |
|
325 |
(self next) = (pattern next) |
|
326 |
ifTrue: [pattern position = 1 ifTrue: [startMatch := self position]] |
|
327 |
ifFalse: [ |
|
328 |
pattern position: 0. |
|
329 |
startMatch ifNotNil: [ |
|
330 |
self position: startMatch. |
|
331 |
startMatch := nil |
|
332 |
] |
|
333 |
] |
|
334 |
]. |
|
335 |
^ true |
|
336 |
||
337 |
" |
|
338 |
'abc def ghi' readStream match:'def'; upToEnd |
|
339 |
" |
|
340 |
! |
|
341 |
||
611 | 342 |
position |
15615 | 343 |
"return the read position (0-based)" |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
344 |
|
15348 | 345 |
^ position |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
346 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
347 |
|
15615 | 348 |
position0Based |
349 |
<resource: #obsolete> |
|
350 |
"return the read position 0-based" |
|
351 |
||
352 |
^ self position |
|
353 |
! |
|
354 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
355 |
position0Based:index0Based |
15615 | 356 |
<resource: #obsolete> |
4405 | 357 |
"set the read (or write) position" |
611 | 358 |
|
15615 | 359 |
self position:index0Based |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
360 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
361 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
362 |
position1Based |
15615 | 363 |
<resource: #obsolete> |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
364 |
"return the read position 1-based" |
611 | 365 |
|
15615 | 366 |
^ self position + 1 |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
367 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
368 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
369 |
position1Based:index1Based |
15615 | 370 |
<resource: #obsolete> |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
371 |
"set the read (or write) position" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
372 |
|
15615 | 373 |
self position:(index1Based - 1) |
4405 | 374 |
|
375 |
" |
|
376 |
|s| |
|
377 |
||
378 |
s := '1234567890' readStream. |
|
379 |
s next:5. |
|
380 |
s position:1. |
|
381 |
s next:7. |
|
382 |
" |
|
383 |
||
384 |
" |
|
385 |
|s| |
|
386 |
||
387 |
s := '' writeStream. |
|
388 |
s nextPutAll:'1234567890'. |
|
389 |
s position:5. |
|
390 |
s nextPutAll:'abcdefg'. |
|
391 |
s contents |
|
392 |
" |
|
393 |
||
394 |
" |
|
395 |
|s| |
|
396 |
||
397 |
s := '' writeStream. |
|
398 |
s nextPutAll:'1234567890'. |
|
399 |
s position:0. |
|
400 |
s nextPutAll:'abcdefg'. |
|
401 |
s contents |
|
402 |
" |
|
611 | 403 |
! |
404 |
||
15615 | 405 |
position:index0Based |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
406 |
"set the read (or write) position" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
407 |
|
15615 | 408 |
((index0Based > readLimit) or:[index0Based < 0]) ifTrue: [^ self positionError:index0Based]. |
409 |
position := index0Based |
|
6626
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
410 |
! |
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
411 |
|
611 | 412 |
reset |
413 |
"set the read position to the beginning of the collection" |
|
414 |
||
5308 | 415 |
self resetPosition |
416 |
||
417 |
" |
|
418 |
|s| |
|
419 |
||
420 |
s := 'hello world' readStream. |
|
421 |
Transcript showCR:(s next:5). |
|
422 |
s reset. |
|
423 |
Transcript showCR:(s next:10). |
|
424 |
" |
|
425 |
! |
|
426 |
||
427 |
resetPosition |
|
428 |
"set the read position to the beginning of the collection" |
|
429 |
||
15348 | 430 |
position := 0 |
4405 | 431 |
|
432 |
" |
|
433 |
|s| |
|
434 |
||
435 |
s := 'hello world' readStream. |
|
436 |
Transcript showCR:(s next:5). |
|
437 |
s reset. |
|
438 |
Transcript showCR:(s next:10). |
|
439 |
" |
|
611 | 440 |
! |
441 |
||
442 |
setToEnd |
|
11433 | 443 |
"set the read position to the end of the collection. |
444 |
#next will return EOF, #nextPut: will append to the stream. |
|
445 |
(same Behavior as FileStream." |
|
611 | 446 |
|
15348 | 447 |
position := readLimit |
611 | 448 |
! |
449 |
||
450 |
skip:numberToSkip |
|
451 |
"skip the next numberToSkip elements" |
|
452 |
||
5774 | 453 |
numberToSkip ~~ 0 ifTrue:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
454 |
self position:(self position + numberToSkip) |
5774 | 455 |
] |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
456 |
! |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
457 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
458 |
skipThroughAll:aCollection |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
459 |
"skip for and through the sequence given by the argument, aCollection; |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
460 |
return nil if not found, self otherwise. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
461 |
On a successful match, the next read will return elements after aCollection; |
2153
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
462 |
if no match was found, the receiver will be positioned at the end. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
463 |
This is redefined here, to make use of positioning." |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
464 |
|
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
465 |
|buffer len first idx| |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
466 |
|
16186 | 467 |
self isPositionable ifFalse:[ |
468 |
"/ for non-positionable subclasses |
|
469 |
^ super skipThroughAll:aCollection |
|
470 |
]. |
|
471 |
||
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
472 |
len := aCollection size. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
473 |
first := aCollection at:1. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
474 |
[self atEnd] whileFalse:[ |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
475 |
buffer := self nextAvailable:len. |
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
476 |
buffer size == len ifTrue:[ |
16209 | 477 |
buffer = aCollection ifTrue:[ |
478 |
^ self |
|
479 |
]. |
|
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
480 |
"expect more input" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
481 |
idx := buffer indexOf:first startingAt:2. |
16209 | 482 |
idx ~~ 0 ifTrue:[ |
483 |
self skip:(idx - len - 1) |
|
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
484 |
]. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
485 |
]. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
486 |
]. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
487 |
^ nil |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
488 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
489 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
490 |
|s| |
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
491 |
s := ReadStream on:'12345678901234567890a'. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
492 |
s skipThroughAll:'90ab'. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
493 |
s upToEnd |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
494 |
" |
2153
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
495 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
496 |
|s| |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
497 |
s := ReadStream on:'12345678901234567890'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
498 |
s skipThroughAll:'1234'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
499 |
s upToEnd |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
500 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
501 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
502 |
|s| |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
503 |
s := ReadStream on:'12345678901234567890'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
504 |
s skipThroughAll:'999'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
505 |
s atEnd |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
506 |
" |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
507 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
508 |
"Created: 26.6.1996 / 09:35:35 / cg" |
2154
89e96599e1e2
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
509 |
"Modified: 11.1.1997 / 19:16:38 / cg" |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
510 |
! |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
511 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
512 |
skipToAll:aCollection |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
513 |
"skip for the sequence given by the argument, aCollection; |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
514 |
return nil if not found, self otherwise. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
515 |
On a successful match, the next read will return elements of aCollection." |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
516 |
|
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
517 |
|oldPos buffer len first idx| |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
518 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
519 |
oldPos := self position. |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
520 |
len := aCollection size. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
521 |
first := aCollection at:1. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
522 |
[self atEnd] whileFalse:[ |
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
523 |
buffer := self nextAvailable:len. |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
524 |
buffer = aCollection ifTrue:[ |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
525 |
self position:(self position - len). |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
526 |
^ self |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
527 |
]. |
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
528 |
buffer size == len ifTrue:[ |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
529 |
"more input can be expected" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
530 |
idx := buffer indexOf:first startingAt:2. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
531 |
idx == 0 ifFalse:[ |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
532 |
self position:(self position - len + idx - 1) |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
533 |
]. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
534 |
]. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
535 |
]. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
536 |
self position:oldPos. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
537 |
^ nil |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
538 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
539 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
540 |
|s| |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
541 |
s := ReadStream on:'12345678901234567890'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
542 |
s skipToAll:'901'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
543 |
s upToEnd |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
544 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
545 |
|
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
546 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
547 |
|s| |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
548 |
s := ReadStream on:'1234567890'. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
549 |
s skipToAll:'901'. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
550 |
s upToEnd |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
551 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
552 |
|
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
553 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
554 |
|s| |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
555 |
s := 'Makefile' asFilename readStream. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
556 |
[ |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
557 |
(s skipToAll:'EDIT') notNil ifTrue:[ |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
558 |
s next:100. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
559 |
]. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
560 |
] ensure:[ |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
561 |
s close. |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
562 |
] |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
563 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
564 |
|
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
565 |
"Modified: 26.6.1996 / 09:28:27 / cg" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
566 |
"Created: 26.6.1996 / 09:35:06 / cg" |
44 | 567 |
! ! |
611 | 568 |
|
10357
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
569 |
!PositionableStream methodsFor:'printing & storing'! |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
570 |
|
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
571 |
printOn:aStream |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
572 |
aStream nextPutAll:self className; nextPutAll:'(on:'; nextPutAll:collection classNameWithArticle; nextPut:$) |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
573 |
|
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
574 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
575 |
'' readStream printString |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
576 |
'' writeStream printString |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
577 |
" |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
578 |
! ! |
66543e405aa4
Fix #skipToAll: (partial match at end of stream
Stefan Vogel <sv@exept.de>
parents:
10001
diff
changeset
|
579 |
|
611 | 580 |
!PositionableStream methodsFor:'private'! |
581 |
||
582 |
contentsSpecies |
|
583 |
"return a class of which instances will be returned, when |
|
584 |
parts of the collection are asked for. |
|
15640 | 585 |
(see upTo-kind of methods in Stream)" |
611 | 586 |
|
587 |
^ collection species |
|
588 |
! |
|
589 |
||
590 |
on:aCollection |
|
591 |
"setup for streaming on aCollection" |
|
592 |
||
593 |
collection := aCollection. |
|
594 |
readLimit := aCollection size. |
|
13379 | 595 |
readLimit == 0 ifTrue:[ |
596 |
self assert:(aCollection isCollection) |
|
597 |
]. |
|
15348 | 598 |
position := 0 |
611 | 599 |
! |
600 |
||
601 |
on:aCollection from:first to:last |
|
602 |
"setup for streaming on aCollection from first to last" |
|
603 |
||
604 |
collection := aCollection. |
|
15348 | 605 |
position := first - 1. |
611 | 606 |
readLimit := last |
607 |
! |
|
608 |
||
609 |
positionError |
|
1998 | 610 |
"{ Pragma: +optSpace }" |
611 |
||
2966 | 612 |
"report an error when positioning past the end |
613 |
or before the beginning." |
|
611 | 614 |
|
8320
229adaeaf183
Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents:
8318
diff
changeset
|
615 |
^ PositionOutOfBoundsError raiseRequestWith:nil |
4452
3d050f505a0a
Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents:
4416
diff
changeset
|
616 |
|
3d050f505a0a
Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents:
4416
diff
changeset
|
617 |
"Modified: / 26.7.1999 / 10:59:13 / stefan" |
611 | 618 |
! |
619 |
||
6314 | 620 |
positionError:badPostition |
621 |
"{ Pragma: +optSpace }" |
|
622 |
||
623 |
"report an error when positioning past the end |
|
624 |
or before the beginning." |
|
625 |
||
8320
229adaeaf183
Use exception classes instead of class vars
Stefan Vogel <sv@exept.de>
parents:
8318
diff
changeset
|
626 |
^ PositionOutOfBoundsError raiseRequestWith:badPostition |
6314 | 627 |
! |
628 |
||
611 | 629 |
with:aCollection |
630 |
"setup for streaming to the end of aCollection" |
|
631 |
||
632 |
collection := aCollection. |
|
11434 | 633 |
readLimit := aCollection size. |
611 | 634 |
self setToEnd |
11434 | 635 |
|
636 |
" |
|
637 |
(WriteStream with:#(1 2 3 4 5)) |
|
638 |
nextPut:6; |
|
639 |
contents |
|
640 |
" |
|
611 | 641 |
! ! |
642 |
||
16195 | 643 |
!PositionableStream methodsFor:'queries'! |
644 |
||
16209 | 645 |
endsBeforePositionWith:aSequenceableCollection |
16195 | 646 |
"answer true, if the elements in aSequenceableCollection |
16209 | 647 |
are at the current end of the stream up to position." |
16195 | 648 |
|
16209 | 649 |
|sz pos| |
16195 | 650 |
|
16209 | 651 |
sz := aSequenceableCollection size. |
652 |
pos := self position. |
|
653 |
pos < sz ifTrue:[ |
|
654 |
^ false. |
|
16195 | 655 |
]. |
16209 | 656 |
self contentsSpecies == collection class ifTrue:[ |
657 |
^ collection sameContentsFrom:pos+1-sz to:pos as:aSequenceableCollection startingAt:1. |
|
658 |
]. |
|
659 |
self position:pos-sz. |
|
660 |
^ (self next:sz) = aSequenceableCollection. |
|
16195 | 661 |
|
662 |
" |
|
16209 | 663 |
('' writeStream nextPutAll:'Hello World') endsBeforePositionWith:'World' |
664 |
('' writeStream nextPutAll:'Hello World') endsBeforePositionWith:'Hello World' |
|
665 |
('' writeStream nextPutAll:'Hello World') endsBeforePositionWith:'Hello Worldx' |
|
666 |
('' writeStream nextPutAll:'Hello World') endsBeforePositionWith:'Bla' |
|
667 |
('' writeStream) endsBeforePositionWith:'Bla' |
|
668 |
('' writeStream) endsBeforePositionWith:'' |
|
16195 | 669 |
'' endsWith:'' |
670 |
" |
|
671 |
! ! |
|
672 |
||
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
673 |
!PositionableStream methodsFor:'reading'! |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
674 |
|
9003 | 675 |
nextAvailable:count |
17606 | 676 |
collection notNil ifTrue:[ |
677 |
|end result| |
|
9003 | 678 |
|
17606 | 679 |
end := position + count. |
680 |
end >= readLimit ifTrue:[ |
|
681 |
end := readLimit. |
|
682 |
]. |
|
683 |
||
684 |
result := collection copyFrom:position+1 to:end. |
|
685 |
position := end. |
|
686 |
^ result. |
|
9003 | 687 |
]. |
688 |
||
17606 | 689 |
^ super nextAvailable:count. |
9003 | 690 |
|
691 |
" |
|
692 |
'abc' readStream nextAvailable:1. |
|
693 |
'abc' readStream nextAvailable:2. |
|
694 |
'abc' readStream nextAvailable:3. |
|
695 |
'abc' readStream nextAvailable:4. |
|
696 |
||
697 |
'abc' readStream nextAvailable:2; nextAvailable:2. |
|
698 |
'abc' readStream nextAvailable:3; nextAvailable:3. |
|
699 |
" |
|
700 |
! |
|
701 |
||
17611 | 702 |
nextAvailable:count into:aCollection startingAt:initialIndex |
703 |
"return the next count objects from the stream. If the end is |
|
704 |
reached before, only that many objects are copyied into the |
|
705 |
collection. |
|
706 |
Returns the number of objects that have been actually read." |
|
707 |
||
708 |
| max | |
|
709 |
||
710 |
collection notNil ifTrue:[ |
|
711 |
max := (readLimit - position) min: count. |
|
712 |
aCollection |
|
713 |
replaceFrom: initialIndex |
|
714 |
to: initialIndex+max-1 |
|
715 |
with: collection |
|
716 |
startingAt: position+1. |
|
717 |
position := position + max. |
|
718 |
^ max. |
|
719 |
]. |
|
720 |
||
721 |
^ super nextAvailable:count into:aCollection startingAt:initialIndex. |
|
722 |
||
723 |
" |
|
724 |
|s n buffer| |
|
725 |
||
726 |
buffer := ByteArray new:10. |
|
727 |
||
728 |
s := ReadStream on:#[1 2 3 4 5 6 7 8 9]. |
|
729 |
s next:3. |
|
730 |
n := s nextBytes:9 into:buffer startingAt:1. |
|
731 |
Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer) |
|
732 |
" |
|
733 |
! |
|
734 |
||
735 |
nextBytes:numBytes into:aCollection startingAt:initialIndex |
|
736 |
"return the next numBytes from the stream. If the end is |
|
737 |
reached before, only that many bytes are copyied into the |
|
738 |
collection. |
|
739 |
Returns the number of bytes that have been actually read. |
|
740 |
The receiver must support reading of binary bytes. |
|
741 |
||
742 |
Notice: this method is provided here for protocol completeness |
|
743 |
with externalStreams - it is normally not used with other |
|
744 |
streams." |
|
745 |
||
746 |
|max| |
|
747 |
||
748 |
(collection isByteCollection |
|
749 |
and:[aCollection isByteCollection]) ifTrue:[ |
|
750 |
"do it the fast way" |
|
751 |
max := (readLimit - position) min: numBytes. |
|
752 |
aCollection |
|
753 |
replaceBytesFrom:initialIndex |
|
754 |
to:(initialIndex + max - 1) |
|
755 |
with:collection |
|
756 |
startingAt:position+1. |
|
757 |
position := position + max. |
|
758 |
^ max |
|
759 |
]. |
|
760 |
"do it the hard way" |
|
761 |
^ super nextBytes:numBytes into:aCollection startingAt:initialIndex |
|
762 |
||
763 |
" |
|
764 |
|s n buffer| |
|
765 |
||
766 |
buffer := ByteArray new:10. |
|
767 |
||
768 |
s := ReadStream on:#[1 2 3 4 5 6 7 8 9]. |
|
769 |
s next:3. |
|
770 |
n := s nextBytes:9 into:buffer startingAt:1. |
|
771 |
Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer) |
|
772 |
" |
|
773 |
! |
|
774 |
||
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
775 |
upToAll:aCollection |
16186 | 776 |
"read until a subcollection consisisting of the elements in aCollection is encountered. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
777 |
Return everything read excluding the elements in aCollection. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
778 |
The position is left before the collection; i.e. the next |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
779 |
read operations will return those elements. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
780 |
If no such subcollection is encountered, all elements up to the end |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
781 |
are read and returned. |
6494 | 782 |
See also #throughAll: which also reads up to some objects |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
783 |
but positions behind it and DOES include it in the returned |
3184
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
784 |
collection. |
6494 | 785 |
See also #upToAllExcluding:, which returns the same, but leaves the |
786 |
read pointer after the matched subcollection. |
|
3184
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
787 |
|
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
788 |
Note: this behavior is inconsistent with the other upTo.. methods, |
15159
b94bdee97afa
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14934
diff
changeset
|
789 |
which position after the found item. We implement the method |
b94bdee97afa
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14934
diff
changeset
|
790 |
this way for the sake of ST80-compatibility." |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
791 |
|
17611 | 792 |
"/ in the future, this will have the Squeak semantics, which is upToAllExcluding: |
16189 | 793 |
|
794 |
^ self upToAll_positionBefore:aCollection |
|
795 |
||
796 |
" |
|
797 |
|s| |
|
798 |
s := ReadStream on:'hello world'. |
|
799 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
|
800 |
Transcript showCR:s atEnd. |
|
801 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
|
802 |
" |
|
803 |
" |
|
804 |
|s| |
|
805 |
s := ReadStream on:'hello world'. |
|
806 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
|
807 |
Transcript showCR:s atEnd. |
|
808 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
|
809 |
" |
|
810 |
" |
|
811 |
|s| |
|
812 |
s := ReadStream on:'hello world'. |
|
813 |
Transcript show:'<'; show:(s upToAll:'xx'); showCR:'>'. |
|
814 |
Transcript showCR:s atEnd. |
|
815 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
|
816 |
" |
|
817 |
||
818 |
"Modified: / 12.1.1998 / 22:06:42 / cg" |
|
819 |
"Created: / 12.1.1998 / 22:07:01 / cg" |
|
820 |
! |
|
821 |
||
822 |
upToAll_positionBefore:aCollection |
|
823 |
"read until a subcollection consisisting of the elements in aCollection is encountered. |
|
824 |
Return everything read excluding the elements in aCollection. |
|
825 |
The position is left before the collection; i.e. the next |
|
826 |
read operations will return those elements. |
|
827 |
If no such subcollection is encountered, all elements up to the end |
|
828 |
are read and returned. |
|
829 |
See also #throughAll: which also reads up to some objects |
|
830 |
but positions behind it and DOES include it in the returned |
|
16840 | 831 |
collection." |
16189 | 832 |
|
16209 | 833 |
|answerStream element last| |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
834 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
835 |
last := aCollection last. |
16209 | 836 |
answerStream := WriteStream on:(self contentsSpecies new:100). |
837 |
[(element := self nextOrNil) notNil] whileTrue:[ |
|
15159
b94bdee97afa
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14934
diff
changeset
|
838 |
answerStream nextPut:element. |
16209 | 839 |
(element = last and:[answerStream endsBeforePositionWith:aCollection]) ifTrue:[ |
840 |
|backStep| |
|
841 |
backStep := aCollection size negated. |
|
842 |
self skip:backStep. |
|
843 |
answerStream skip:backStep. |
|
844 |
^ answerStream contents |
|
15159
b94bdee97afa
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
14934
diff
changeset
|
845 |
]. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
846 |
]. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
847 |
^ answerStream contents |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
848 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
849 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
850 |
|s| |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
851 |
s := ReadStream on:'hello world'. |
16209 | 852 |
Transcript show:'<'; show:(s upToAll_positionBefore:'wo'); showCR:'>'. |
6494 | 853 |
Transcript showCR:s atEnd. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
854 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
855 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
856 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
857 |
|s| |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
858 |
s := ReadStream on:'hello world'. |
16209 | 859 |
Transcript show:'<'; show:(s upToAll_positionBefore:'wo'); showCR:'>'. |
16186 | 860 |
Transcript showCR:s atEnd. |
16209 | 861 |
Transcript show:'<'; show:(s upToAll_positionBefore:'wo'); showCR:'>'. |
16186 | 862 |
" |
863 |
" |
|
864 |
|s| |
|
865 |
s := ReadStream on:'hello world'. |
|
16209 | 866 |
Transcript show:'<'; show:(s upToAll_positionBefore:'xx'); showCR:'>'. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
867 |
Transcript showCR:s atEnd. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
868 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
869 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
870 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
871 |
"Modified: / 12.1.1998 / 22:06:42 / cg" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
872 |
"Created: / 12.1.1998 / 22:07:01 / cg" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
873 |
! ! |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
874 |
|
611 | 875 |
!PositionableStream methodsFor:'testing'! |
876 |
||
877 |
atEnd |
|
878 |
"return true, if the read-position is at the end" |
|
879 |
||
15357 | 880 |
^ position >= readLimit |
611 | 881 |
! |
882 |
||
883 |
isEmpty |
|
884 |
"return true, if the contents of the stream is empty" |
|
885 |
||
886 |
^ readLimit == 0 |
|
9006 | 887 |
! |
888 |
||
10577 | 889 |
isInternalByteStream |
890 |
"return true, if the stream is an internal stream reading bytes" |
|
891 |
||
892 |
^ collection class isBytes |
|
893 |
||
894 |
"Created: / 30-05-2007 / 16:16:12 / cg" |
|
895 |
! |
|
896 |
||
9006 | 897 |
isPositionable |
898 |
"return true, if the stream supports positioning (this one is)" |
|
899 |
||
900 |
^ true |
|
611 | 901 |
! ! |
902 |
||
1897 | 903 |
!PositionableStream class methodsFor:'documentation'! |
701 | 904 |
|
905 |
version |
|
17611 | 906 |
^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.171 2015-03-12 19:24:30 stefan Exp $' |
13379 | 907 |
! |
908 |
||
909 |
version_CVS |
|
17611 | 910 |
^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.171 2015-03-12 19:24:30 stefan Exp $' |
18260
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
911 |
! |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
912 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
913 |
version_HG |
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
914 |
|
e55af242e134
Added Squeak compatibility methods PositionableStream>>#upToAnyOf: / #upToAnyOf:do:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
915 |
^ '$Changeset: <not expanded> $' |
701 | 916 |
! ! |
6777
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
917 |
|
14934 | 918 |
|
611 | 919 |
PositionableStream initialize! |