Streams

Streams provide a means of channeling information to or from an application. More...

Classes

class  OLBufferingInStream
 A layered in stream that filters its data through a buffer. More...
class  OLBufferingOutStream
 A layered out stream that filters its data through a buffer. More...
class  OLBzlibInStream
 A stream for bzlib decompression. More...
class  OLBzlibOutStream
 A stream for bzlib compression. More...
class  OLConnectedInStream
 An in stream that is connected to something outside of ObjectiveLib. More...
class  OLConnectedOutStream
 An out stream that is connected to something outside of ObjectiveLib. More...
class  OLDataInStream
 An in stream that is connected to a memory buffer. More...
class  OLDataOutStream
 An out stream connected to a memory buffer. More...
class  OLFileInStream
 A connected stream that reads its data from a file. More...
class  OLFileOutStream
 A connected stream that sends its data to a file. More...
class  OLGzipInStream
 A stream for zlib decompression that reads data in gzip format. More...
class  OLGzipOutStream
 A stream for zlib compression that writes data in the gzip format. More...
class  OLInStream
 Base class for reading data. More...
class  OLLayeredInStream
 An in stream that is layered over another in stream. More...
class  OLLayeredOutStream
 An out stream that is layered over another out stream. More...
class  OLObjectInStream
 A stream that can read objects and classes. More...
class  OLObjectOutStream
 A stream that is capable of writing objects and classes. More...
class  OLOutStream
 Base class for writing data. More...
class  OLReferenceCountedStream
 A base class for maintaining reference counts of streams. More...
protocol  < OLStreamable >
 A protocol for writing to streams. More...
class  OLZlibInStream
 A stream for zlib decompression. More...
class  OLZlibOutStream
 A stream for zlib compression. More...

Detailed Description

Streams provide a means of channeling information to or from an application.

All stream classes are derived either from OLInStream or OLOutStream. There are two branches of inheritance from the base stream classes: connected streams and layered streams. Connected streams (subclasses of OLConnectedOutStream and OLConnectedInStream) communicate with entities outside of the ObjectiveLib streaming subsystem, like files and sockets, while layered streams (subclasses of OLLayeredOutStream and OLLayeredInStream) are only capable of communicating with other ObjectiveLib streams.

StreamLayers.dot

Stream Layering

Connected streams can be used without any layered streams, but generally the services provided by layered streams will be advantageous. Layered streams act as filters for the data and can include services such as buffering and compression. For example, to write some data to a file that is compatible with the command-line tool gzip, one constructs a set of streams as follows.

 OLGzipOutStream* gzstream = [OLGzipOutStream streamWithOutStream:
     [OLFileOutStream streamWithPath: "mydata.gz"]];
 [gzstream writeInt: 6];
 [gzstream close];

The layers in the previous sample are stacked as follows, where the OLFileOutStream is the connected stream and the OLGzipOutStream is the layered stream.

FileGzipLayers.dot

Of course, in the real world you would probably put an OLBufferingOutStream in between the OLFileOutStream and the OLGzipOutStream, since you'd probably be writing a lot of data. Additionally, if you wanted to write objects to the file, you would have to put an OLObjectOutStream on the top of the stream stack. Something like this.

 OLObjectOutStream* ostream = [OLObjectOutStream streamWithOutStream:
     [OLGzipOutStream streamWithOutStream:
         [OLBufferingOutStream streamWithOutStream:
             [OLFileOutStream streamWithPath: "mydata.gz"]]]];
 [ostream writeObject: objectWithLotsOfDataToWrite];
 [ostream close];

And the layers would map like this.

FileBufferingGzipObjectLayers.dot

ObjectiveLibGenerated Sun Apr 22 15:18:06 2007, © 2004-2007 Will Mason
SourceForge.net Logo