--- a/Stream.st Wed Jan 14 15:12:50 1998 +0100
+++ b/Stream.st Fri Jan 16 00:29:30 1998 +0100
@@ -1423,7 +1423,7 @@
elements, but excluding anObject.
The next read operation will return the element after anObject.
(i.e. anObject is considered a separator, which is skipped)
- Similar to through, but the matching object is not included in the
+ Similar to #through:, but the matching object is not included in the
returned collection.
If anObject is not encountered, all elements up to the end are read
and returned.
@@ -1478,6 +1478,55 @@
"
"Modified: / 12.1.1998 / 21:58:38 / cg"
+ "Modified: / 15.1.1998 / 23:28:47 / stefan"
+!
+
+upToAll:aCollection
+ "read until a subcollection consisisting of the elements in aCollection
+ is encountered.
+ Return everything read excluding the elements in aCollection.
+ The next read operation will return the element after aCollection.
+ (i.e. aCollection is considered a separator, which is skipped)
+ Similar to #throughAll:, but the matching object is not included in the
+ returned collection.
+ If no such subcollection is encountered, all elements up to the end
+ are read and returned.
+ Compare this with #throughAll: which also reads up to aCollection
+ but positions behind it and DOES include it in the returned
+ collection."
+
+ |answerStream element last rslt|
+
+ last := aCollection last.
+ answerStream := WriteStream on:(self contentsSpecies new).
+ [self atEnd] whileFalse:[
+ element := self next.
+ answerStream nextPut:element.
+ element == last ifTrue:[
+ ((rslt := answerStream contents) endsWith:aCollection) ifTrue:[
+ ^ rslt copyWithoutLast:aCollection size
+ ]
+ ].
+ ].
+ ^ answerStream contents
+
+ "
+ |s|
+ s := ReadStream on:'hello world'.
+ Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'.
+ Transcript show:'<'; show:(s upToEnd); 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: / 15.1.1998 / 23:28:20 / stefan"
+ "Modified: / 15.1.1998 / 23:29:26 / stefan"
!
upToAny:aCollectionOfObjects
@@ -1906,6 +1955,6 @@
!Stream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.68 1998-01-12 21:08:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Stream.st,v 1.69 1998-01-15 23:29:30 stefan Exp $'
! !
Stream initialize!