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.14 date: 2019/12/13 20:35:43
user: cg
file: MultiReadStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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:]

copyright

COPYRIGHT (c) 2018 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  on: aReadStream


Instance protocol:

accessing
o  readStream

obsolete positioning
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) **

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

queries
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  position
that's debatable !

reading
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

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:29:12 GMT