class: PositionableStream
authorClaus Gittinger <cg@exept.de>
Sat, 01 Mar 2014 23:33:23 +0100
changeset 16189 d7b9978c07bb
parent 16188 4df8b9b15db4
child 16190 05ae6b8316b7
class: PositionableStream added: #upToAll_positionBefore: changed: #upToAll:
PositionableStream.st
--- a/PositionableStream.st	Sat Mar 01 23:21:38 2014 +0100
+++ b/PositionableStream.st	Sat Mar 01 23:33:23 2014 +0100
@@ -600,6 +600,53 @@
            which position after the found item. We implement the method
            this way for the sake of ST80-compatibility."
 
+    "/ in the future, this wil have the Squeak semantics, which is upToAllExcluding:
+
+    ^ self upToAll_positionBefore:aCollection
+
+    "
+     |s|
+     s := ReadStream on:'hello world'.
+     Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. 
+     Transcript showCR:s atEnd.
+     Transcript show:'<'; show:(s upToEnd); showCR:'>'. 
+    "
+    "
+     |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:'>'. 
+    "
+
+    "Modified: / 12.1.1998 / 22:06:42 / cg"
+    "Created: / 12.1.1998 / 22:07:01 / cg"
+!
+
+upToAll_positionBefore:aCollection
+    "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.
+     If no such subcollection is encountered, all elements up to the end 
+     are read and returned.
+     See also #throughAll: which also reads up to some objects
+     but positions behind it and DOES include it in the returned
+     collection.
+     See also #upToAllExcluding:, which returns the same, but leaves the
+     read pointer after the matched subcollection.
+
+     Note: this behavior is inconsistent with the other upTo.. methods,
+           which position after the found item. We implement the method
+           this way for the sake of ST80-compatibility."
+
     |answerStream element last rslt|
 
     last := aCollection last.
@@ -673,11 +720,11 @@
 !PositionableStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.163 2014-03-01 22:21:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.164 2014-03-01 22:33:23 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.163 2014-03-01 22:21:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.164 2014-03-01 22:33:23 cg Exp $'
 ! !