OLDataInStream Class Reference
[Streams]

An in stream that is connected to a memory buffer. More...

#import <ObjectiveLib/DataInStream.h>

Inheritance diagram for OLDataInStream:

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) - initWithBytes:count:
 Initialize the stream.

Static Public Member Functions

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

Protected Attributes

unsigned byteCount
 The number of bytes in the buffer.
uint8_t * bytes
 The memory buffer from which data is read.
unsigned position
 The current position from which to read.

Detailed Description

An in stream that is connected to a memory buffer.

This is a concrete connected stream that reads all of its data from a memory buffer.

See also:
OLDataOutStream


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 OLReferenceCountedStream.

- (id) initWithBytes: (const uint8_t *)  buffer
count: (unsigned)  length 

Initialize the stream.

The contents of buffer are copied into the stream's buffer.

Parameters:
buffer the bytes from which the stream should read
length the number of bytes
Returns:
a reference to this stream

- (uint8_t) readByte  

Read a byte from the stream.

This optimized version of reading a byte merely copies a byte from the memory buffer unless there is no more data in the buffer.

Exceptions:
OLEndOfStreamException if the end of the stream has been reached
Returns:
the byte read

Reimplemented from OLInStream.

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

Read a sequence of bytes from the stream.

Bytes are copied from the buffer unless the end of the buffer had already been reached before this message was sent. In case there is no more data in the buffer the message returns UINT_MAX.

Parameters:
buffer 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 OLInStream.

+ (id) streamWithBytes: (const uint8_t *)  buffer
count: (unsigned)  length 

Create and return a new stream.

The contents of the given buffer are copied and the data are then used as the source of this connected stream.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
buffer the bytes to use as the data source
length the number of bytes
Returns:
a reference to the newly created stream


Member Data Documentation

- (unsigned) byteCount [protected]

The number of bytes in the buffer.

- (uint8_t*) bytes [protected]

The memory buffer from which data is read.

- (unsigned) position [protected]

The current position from which to read.


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