class: PositionableStream
comment/format in: #upToAll:
changed: #skipThroughAll: to avoid the need for redefinition
in non-positionable subclasses.
--- a/PositionableStream.st Sat Mar 01 22:06:43 2014 +0100
+++ b/PositionableStream.st Sat Mar 01 23:09:26 2014 +0100
@@ -116,6 +116,7 @@
"Modified: / 13-07-2006 / 20:36:54 / cg"
! !
+
!PositionableStream methodsFor:'Compatibility-Dolphin'!
endChunk
@@ -353,6 +354,11 @@
|buffer len first idx|
+ self isPositionable ifFalse:[
+ "/ for non-positionable subclasses
+ ^ super skipThroughAll:aCollection
+ ].
+
len := aCollection size.
first := aCollection at:1.
[self atEnd] whileFalse:[
@@ -550,8 +556,7 @@
!
upToAll:aCollection
- "read until a subcollection consisisting of the elements in aCollection
- is encountered.
+ "read until a subcollection consisisting of the elements in aCollection is encountered.
Return everything read excluding the elements in aCollection.
The position is left before the collection; i.e. the next
read operations will return those elements.
@@ -593,6 +598,13 @@
"
|s|
s := ReadStream on:'hello world'.
+ Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'.
+ Transcript showCR:s atEnd.
+ Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'.
+ "
+ "
+ |s|
+ s := ReadStream on:'hello world'.
Transcript show:'<'; show:(s upToAll:'xx'); showCR:'>'.
Transcript showCR:s atEnd.
Transcript show:'<'; show:(s upToEnd); showCR:'>'.
@@ -633,11 +645,11 @@
!PositionableStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.161 2013-08-18 10:56:02 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.162 2014-03-01 22:09:26 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.161 2013-08-18 10:56:02 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.162 2014-03-01 22:09:26 cg Exp $'
! !