eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MultiReadStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: MultiReadStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PeekableStream
         |
         +--MultiReadStream

Package:
stx:libbasic2
Category:
Streams-Misc
Version:
rev: 1.11 date: 2017/07/13 10:36:38
user: cg
file: MultiReadStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


Stacked streams. 

At any time, another stream can be stacked onto a stream stack. 
Making this stream's contents to be returned before the rest. 
To the stream reader, this looks like a single stream delivering the
embedded stream contents sequentially.

Useful when reading files which include each other, 
or to handle define-macro expansion in a c-parser.


[instance variables:]


Class protocol:

instance creation
o  on: aReadStream


Instance protocol:

private
o  checkCurrentStreamAtEnd
keep the last stream, so that the #position kludge will work

stream protocol
o  atEnd
(comment from inherited method)
return true if the end of the stream has been reached;
- we do not know here how to do it, it must be redefined in subclass

o  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)

o  next
(comment from inherited method)
return the next element of the stream
- we do not know here how to do it, it must be redefined in subclass

o  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

o  position
that's debatable !

o  position0Based

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  position1Based

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  readStream

stream stacking
o  popInputStream

o  pushInputStream: aReadStream


Examples:


|s| s := MultiReadStream on:('abcd' readStream). self assert:(s peek == $a). self assert:(s next == $a). s pushInputStream:('1234' readStream). self assert:(s next == $1). self assert:(s next == $2). s pushInputStream:('aa' readStream). self assert:(s next == $a). self assert:(s next == $a). self assert:(s atEnd not). self assert:(s next == $3). self assert:(s next == $4). self assert:(s next == $b). self assert:(s next == $c). self assert:(s next == $d). self assert:(s atEnd). self assert:(s peek == nil). self assert:(s next == nil).

ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sun, 22 Jul 2018 16:49:34 GMT