|
Class: CollectingReadStream
Object
|
+--Stream
|
+--PeekableStream
|
+--CollectingReadStream
- Package:
- stx:libbasic2
- Category:
- Streams-Misc
- Version:
- rev:
1.8
date: 2019/05/25 23:31:28
- user: cg
- file: CollectingReadStream.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
- Author:
- Claus Gittinger
A stream which evaluates collectBlock for every element
read from an underlying stream, providing the result from
the evaluation as read-elements.
Useful to process a readStream, for tracing or diverting to another
processing stage.
instance creation
-
diverting: aStream to: anotherStream
-
|s|
s := CollectingReadStream
diverting:#(1 2 3 4 5 6 7 8) readStream
to:Transcript.
s upToEnd
-
on: aStream collecting: aBlock
-
|s|
s := CollectingReadStream
on:#(1 2 3 4 5 6 7 8) readStream
collecting:[:each | each squared].
s upToEnd
instance creation
-
on: aStream collecting: aBlock
-
queries
-
atEnd
-
-
contents
-
-
contentsSpecies
-
return a class of which instances will be returned, when
parts of the collection are asked for.
(see upTo-kind of methods in Stream)
stream protocol
-
next
-
-
nextOrNil
-
(comment from inherited method)
like #next, this returns the next element, if available.
If nothing is available, this does never raise a read-beyond end signal.
Instead, nil is returned immediately.
-
nextPeek
-
(comment from inherited method)
advance to next element and return the peeked element
-
peek
-
(comment from inherited method)
return the next element of the stream without advancing (i.e.
the following send of next will return this element again.)
- we do not know here how to do it, it must be redefined in subclass
-
peekOrNil
-
(comment from inherited method)
like #peek, this returns the next readAhead element, if available.
However, unlike #peek, this does not raise an atEnd-query signal - even
if handled. Instead, nil is returned immediately.
-
position
-
-
position0Based
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
position1Based
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
position: newPos
-
-
readStream
-
|s|
s := CollectingReadStream
on:#(1 2 3 4 5 6 7 8) readStream
collecting:[:each | each squared].
s upToEnd
|
|s|
s := (#(1 2 3 4 5 6 7 8) readStream
selecting:[:n | n odd])
collecting:[:n | n squared].
s upToEnd
|
|