PackageDescription: StreamWrappers


Stream Wrappers

Last published: February 13, 2008 by 'antony'

Defines 26 Classes
Extends 35 Classes


This package provides an enhancement to the standard Smalltalk Streaming protocols defined in ANSI Smalltalk and Smalltalk-80 by adding a hierarchy of classes that wrap up other streams with buffering and non-buffering variants for ReadStreams and WriteStreams.

The basic services provided are:
ReadStream wrapping, buffered and unbuffered
WriteStream wrapping, buffered and unbuffered
UnionReadStream which combines two ReadStream sources in to one
String to ByteArray to String reading and writing, unbuffered for converting between strings and bytes and back again
SplitReadStream which writes out what it reads to the you and another writeStream you specify - useful for injecting logging in to a stream system
ReadLimitedStream which allows you to read a subset of the wrapped stream up to a limit.
ReadWritePairStream which combines a readStream and a writeStream and acts like a ReadWriteStream

You can generally call myWrappedStream := StreamWrapperClass on: myOtherStream.
We have also added convenience methods for bytes -> strings conversion with #asStringStream to convert a byteArray read or write stream in to the equivalent string version.