ObjectiveLib  1.0.0
Public Member Functions | Static Public Member Functions | Protected Attributes
OLBufferingInStream Class Reference

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

(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.
(void) - dealloc
 Finalize the stream and deallocate any allocated memory.

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) dealloc

Finalize the stream and deallocate any allocated memory.

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:
underStreamthe 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:
underStreamthe stream from which this stream gets its data
sizethe 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:
OLInputOutputExceptionif there is an error reading from the stream
OLEndOfStreamExceptionif 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:
OLInputOutputExceptionif there is an error reading from the stream
Parameters:
destthe address to which the bytes should be read
maxthe 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:
underStreamthe 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 Sat Feb 15 2014 07:45:34, © 2004-2007 Will Mason