eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ReadWriteStream':

Home

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

Class: ReadWriteStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PeekableStream
         |
         +--PositionableStream
            |
            +--WriteStream
               |
               +--ReadWriteStream
                  |
                  +--ExternalStream
                  |
                  +--RWBinaryOrTextStream

Package:
stx:libbasic
Category:
Streams
Version:
rev: 1.51 date: 2021/11/27 13:50:39
user: cg
file: ReadWriteStream.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


ReadWriteStreams allow both read- and write-access to some collection.
To allow this, they reenable some methods blocked in WriteStream.
(being one of the seldom places, where multiple inheritance could be
 of good use in smalltalk).

[caveat:]
    Basing capabilities like readability/writability/positionability/peekability on inheritance makes
    the class hierarchy ugly and leads to strange and hard to teach redefinitions (aka. NonPositionableStream
    below PositionableStream or ExternalReadStream under WriteStream)

Claus:
    I personally find the ReadStream - WriteStream - ReadWriteStream
    organization brain-damaged. It would be better to have an attribute
    (such as readOnly / writeOnly / readWrite) in an InternalStream subclass 
    of Stream ...

copyright

COPYRIGHT (c) 1989 by Claus Gittinger 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.

Instance protocol:

accessing
o  clear
re-initialize the stream to write to the beginning and
to not read any data.

o  contents
return the contents as written so far;
redefined to prevent confusion resulting due to
my superclasses optimization. (see WriteStream contents).
ST80 users of ReadWriteStream may expect the contents array to remain
unchanged, which we do not guarantee.

o  reset
set the read position to the beginning of the collection.
Because I am a read/write stream, the readLimit is set to the current write position.
Thus, the just written data can be read back.

o  resetPosition
set the read position to the beginning of the collection.
Because I am a read/write stream, the readLimit is set to the current write position.
Thus, the just written data can be read back.
Obsolete - use #reset.

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

converting
o  readStream
return the receiver as a readStream - that's myself

o  readStreamOrNil
return a readStream from the receiver. Since this is already
a readStream, return self.

This method has been defined for protocol copmatibility with Filename

initialization
o  with: initialCollection
redefined from WriteStream, to position to the beginning of the stream

queries
o  collectionSize
return the overall number of elements in the streamed collection
(both already read and to be read).

o  remainingSize
return the number of remaining elements to read in the streamed collection.

o  size
return the number of elements in the streamed collection.

reading
o  next
return the next element; advance read position.
If there are no more elements, nil is returned.

o  next: count
return the next count elements of the stream as aCollection,
which depends on the stream's type - (see #contentsSpecies).

o  peek
return the element to be read next without advancing read position.
If there are no more elements, nil is returned.

testing
o  isEmpty
redefinde from WriteStream

o  isReadable
return true if the receiver supports reading - that's true


Examples:


|s|

s := ReadWriteStream with:'abcd'.
s reset.
s nextPut:$A.
s contents       


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 12:41:18 GMT