#import <BufferingOutStream.h>
Inheritance diagram for OLBufferingOutStream:
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. |
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).
- (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.
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.
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.
underStream | the stream to which this stream ultimately forwards its data |
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.
underStream | the stream to which this stream ultimately forwards its data | |
size | the size of the buffer |
+ (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.
underStream | the stream to which this stream ultimately forwards its data |
- (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.
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
bytes | the bytes to write | |
num | the number of bytes to write |
Reimplemented from OLLayeredOutStream.
- (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.
|