#import <BufferingInStream.h>
Inheritance diagram for OLBufferingInStream:
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. |
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.
- (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 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.
underStream | the stream from which this stream gets its data |
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.
underStream | the stream from which this stream gets its data | |
size | the size of the buffer |
- (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.
OLInputOutputException | if there is an error reading from the stream | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if there is an error reading from the stream |
dest | the address to which the bytes should be read | |
max | the maximum number bytes that should 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.
underStream | the stream from which this stream gets its data |
- (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.
|