OLBufferingOutStream Class Reference
[Streams]

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

#import <BufferingOutStream.h>

Inheritance diagram for OLBufferingOutStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - flush
 Flush the stream.
(void) - freeStreamResources
 Free the stream's resources.
(void) - writeByte:
 Write a byte.
(unsigned) - writeBytes:count:
 Write a sequence of bytes to the stream.
Initializers and Deallocators
(id) - initWithOutStream:
 Initialize the stream.
(id) - initWithOutStream:bufferSize:
 Initialize the stream.

Static Public Member Functions

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

Protected Attributes

uint8_t * buffer
 The buffer that temporarily holds data written to the stream.
unsigned capacity
 The capacity of the buffer.
unsigned count
 The number of bytes currently in the buffer.

Detailed Description

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

This concrete class channels all written 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. The buffer will be cleared on any call to flush (OLBufferingOutStream) or close (OLLayeredOutStream).

See also:
OLBufferingInStream


Member Function Documentation

- (void) flush  

Flush the stream.

Any data that is pending or buffered will be written and the stream will be restored to a pristine state.

Exceptions:
OLInputOutputException if there is an error flushing the stream

Reimplemented from OLLayeredOutStream.

- (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 OLLayeredOutStream.

- (id) initWithOutStream: (OLOutStream *)  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 to which this stream ultimately forwards its data
Returns:
a reference to this stream

Reimplemented from OLLayeredOutStream.

- (id) initWithOutStream: (OLOutStream *)  underStream
bufferSize: (unsigned)  size 

Initialize the stream.

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

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

+ (id) streamWithOutStream: (OLOutStream *)  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 to which this stream ultimately forwards its data
Returns:
a reference to the newly created stream

- (void) writeByte: (uint8_t)  byte  

Write a byte.

This is an optimized version of writing a byte that is very fast if the buffer is not full.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
byte the byte to write

Reimplemented from OLOutStream.

- (unsigned) writeBytes: (const uint8_t *)  bytes
count: (unsigned)  num 

Write a sequence of bytes to the stream.

Bytes are copied into the buffer, which is flushed as needed. For cases where num is larger than the size of the buffer, the buffer is flushed and then ignored, thus eliminating the needless overhead of using it.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
bytes the bytes to write
num the number of bytes to write
Returns:
the number of bytes written

Reimplemented from OLLayeredOutStream.


Member Data Documentation

- (uint8_t*) buffer [protected]

The buffer that temporarily holds data written to the stream.

- (unsigned) capacity [protected]

The capacity of the buffer.

- (unsigned) count [protected]

The number of bytes currently in the buffer.


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