OLBufferingInStream Class Reference
[Streams]

A layered in stream that filters its data through a buffer. More...

#import <BufferingInStream.h>

Inheritance diagram for OLBufferingInStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - freeStreamResources
 Free the stream's resources.
(uint8_t) - readByte
 Read a byte from the stream.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
Initializers and Deallocators
(id) - initWithInStream:
 Initialize the stream.
(id) - initWithInStream:bufferSize:
 Initialize the stream.

Static Public Member Functions

(id) + streamWithInStream:
 Create and return a new stream.

Protected Attributes

uint8_t * buffer
 The buffer.
unsigned capacity
 The capacity of the buffer.
unsigned currentCount
 The current number of bytes in the buffer.
unsigned position
 The current position from which to read in the buffer.

Detailed Description

A layered in stream that filters its data through a buffer.

This concrete class channels all read data through a buffer, which in some cases can dramatically improve performance, for example when the layer below the buffering stream performs a very time-consuming task.

See also:
OLBufferingOutStream


Member Function Documentation

- (void) freeStreamResources  

Free the stream's resources.

This secondary freeing method is necessary to allow the reference count to be properly manipulated from within the normal free (OLReferenceCountedStream) method.

Note:
All sublcasses that allocate resources must implement this method to free those resources and call [super freeStreamResources].

Reimplemented from OLLayeredInStream.

- (id) initWithInStream: (OLInStream *)  underStream  

Initialize the stream.

The new stream uses underStream as the next lower layer in the stream stack and uses the default buffer size of 32K.

Parameters:
underStream the stream from which this stream gets its data
Returns:
a reference to this stream

Reimplemented from OLLayeredInStream.

- (id) initWithInStream: (OLInStream *)  underStream
bufferSize: (unsigned)  size 

Initialize the stream.

The new stream uses underStream as the next lower layer in the stream stack and uses the buffer size of size.

Parameters:
underStream the stream from which this stream gets its data
size the size of the buffer
Returns:
a reference to this stream

- (uint8_t) readByte  

Read a byte from the stream.

This is an optimization of reading a byte that can be very fast when the buffer is not empty.

Exceptions:
OLInputOutputException if there is an error reading from the stream
OLEndOfStreamException if the end of the stream has been reached
Returns:
the byte read

Reimplemented from OLInStream.

- (unsigned) readBytes: (uint8_t *)  dest
count: (unsigned)  max 

Read a sequence of bytes from the stream.

Bytes are read from the buffer and the buffer is filled as needed. If the buffer is empty and no bytes can be read from the next lower stream in the stack, then this message returns UINT_MAX.

Exceptions:
OLInputOutputException if there is an error reading from the stream
Parameters:
dest the address to which the bytes should be read
max the maximum number bytes that should be read
Returns:
the number of bytes read or UINT_MAX if no bytes could be read

Reimplemented from OLLayeredInStream.

+ (id) streamWithInStream: (OLInStream *)  underStream  

Create and return a new stream.

The new stream uses underStream as the next lower layer in the stream stack and uses the default buffer size of 32K.

Parameters:
underStream the stream from which this stream gets its data
Returns:
a reference to the newly created stream


Member Data Documentation

- (uint8_t*) buffer [protected]

The buffer.

- (unsigned) capacity [protected]

The capacity of the buffer.

- (unsigned) currentCount [protected]

The current number of bytes in the buffer.

- (unsigned) position [protected]

The current position from which to read in the buffer.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:18:19 2007, © 2004-2007 Will Mason
SourceForge.net Logo