class: ReadWriteStream
authorStefan Vogel <sv@exept.de>
Tue, 04 Mar 2014 13:37:08 +0100
changeset 16196 296f724dcdb2
parent 16195 2bed37c6f731
child 16197 9e2f05c2fd42
class: ReadWriteStream added: #next:
ReadWriteStream.st
--- a/ReadWriteStream.st	Tue Mar 04 13:36:39 2014 +0100
+++ b/ReadWriteStream.st	Tue Mar 04 13:37:08 2014 +0100
@@ -79,6 +79,22 @@
     "Modified: 5.2.1996 / 21:57:40 / stefan"
 !
 
+next:count
+    "return the next count elements of the stream as aCollection,
+     which depends on the streams type - (see #contentsSpecies)."
+
+    |answer|
+
+    self contentsSpecies == collection class ifTrue:[
+        ((position + count) > readLimit) ifFalse:[
+            answer := collection copyFrom:position+1 to:position+count.
+            position := position+count.
+            ^ answer
+        ].
+    ].
+    ^ super next:count
+!
+
 nextByte
     "return the next element; advance read pointer.
      return nil, if there is no next element"
@@ -164,10 +180,10 @@
 !ReadWriteStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.32 2013-06-03 18:39:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.33 2014-03-04 12:37:08 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.32 2013-06-03 18:39:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.33 2014-03-04 12:37:08 stefan Exp $'
 ! !