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

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

(uint8_t) - readByte
 Read a byte from the stream.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
Initializers and Deallocators
(id) - initWithDataObject:
 Initialize the stream.
(id) - initWithBytes:count:
 Initialize the stream.
(void) - dealloc

Static Public Member Functions

(id) + streamWithBytes:count:
 Create and return a new stream.
(id) + streamWithDataObject:
 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

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

Initialize the stream.

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

Parameters:
bufferthe bytes from which the stream should read
lengththe number of bytes
Returns:
a reference to this stream
- (id) initWithDataObject: (NSData *)  data

Initialize the stream.

The stream copies the data from the given data object.

Parameters:
datathe data object used to initialize the stream
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:
OLEndOfStreamExceptionif 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:
bufferthe 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 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:
bufferthe bytes to use as the data source
lengththe number of bytes
Returns:
a reference to the newly created stream
+ (id) streamWithDataObject: (NSData *)  data

Create and return a new stream.

The given data object is used to initialize the stream. The returned stream is autoreleased before being returned.

Parameters:
datathe data from which the stream will read
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 Sat Feb 15 2014 07:45:34, © 2004-2007 Will Mason