OLInStream Class Reference
[Streams]

Base class for reading data. More...

#import <ObjectiveLib/InStream.h>

Inheritance diagram for OLInStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - close
 Close the stream.
(BOOL) - readBool
 Read a boolean value from the stream.
(uint8_t) - readByte
 Read a byte from the stream.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
(double) - readDouble
 Read a double value from the stream.
(float) - readFloat
 Read a float value from the stream.
(unsigned) - readInt
 Read an integer value from the stream.
(uint16_t) - readInt16
 Read a 16-bit integer value from the stream.
(uint32_t) - readInt32
 Read a 32-bit integer value from the stream.
(uint64_t) - readInt64
 Read a 64-bit integer value from the stream.
(SEL) - readSelector
 Read a selector from the stream.

Detailed Description

Base class for reading data.

OLInStream provides the basic stream services which include reading primitive data types and the services of NSCoder. The NSCoder services are provided in order to allow objects which already support the NSCoding protocol to read themselves through an instance of OLObjectInStream. The lower-level methods provided by OLInStream are preferred for new code. Obviously, the NSCoder support is only available if ObjectiveLib was built with OpenStep support.

Note:
Object instances and classes cannot be read using OLInStream. An instance of OLObjectInStream must be used instead. The NSCoder support provided in OLInStream is merely a byproduct of the class hierarchy imposed by NSCoder.


Member Function Documentation

- (void) close  

Close the stream.

After receiving this message the stream will no long be available for reading.

Exceptions:
OLInputOutputException if there is an error closing the stream

Reimplemented in OLBzlibInStream, OLFileInStream, OLLayeredInStream, and OLZlibInStream.

- (BOOL) readBool  

Read a boolean value from the stream.

The value is read as if it had been written by writeBool: (OLOutStream). Specifically, one byte of data is read and YES is returned if that byte is non-zero, otherwise NO is returned.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (uint8_t) readByte  

Read a byte from the stream.

The default implementation of this method is to call readBytes:count:, so subclasses that can optimize reading one byte should do so.

Exceptions:
OLInputOutputException if there is an error reading from the stream
OLEndOfStreamException if the end of the stream has been reached
Returns:
the byte read

Reimplemented in OLBufferingInStream, and OLDataInStream.

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

Read a sequence of bytes from the stream.

This is the fundamental method for reading from a stream, and subclasses must override this method. The number of bytes read is returned except in the case where the end of the stream has been reached. Rather than raising an exception in this case, this method returns UINT_MAX.

Exceptions:
OLInputOutputException if there is an error reading from the stream
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 in OLBufferingInStream, OLBzlibInStream, OLDataInStream, OLFileInStream, OLGzipInStream, OLLayeredInStream, and OLZlibInStream.

- (double) readDouble  

Read a double value from the stream.

The value is read as if it had been written by writeDouble: (OLOutStream). Specifically, an 8-byte field of data is read and converted from network byte order to host byte order.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (float) readFloat  

Read a float value from the stream.

The value is read as if it had been written by writeFloat: (OLOutStream). Specifically, an 4-byte field of data is read and converted from network byte order to host byte order.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (unsigned) readInt  

Read an integer value from the stream.

The value is read as if it had been written by writeInt: (OLOutStream). Specifically, an 4-byte field of data is read and converted from network byte order to host byte order.

Note:
Regardless of the size of the type int on the platform being used, the value read will always be exactly four bytes long and returned as an unsigned value.
Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (uint16_t) readInt16  

Read a 16-bit integer value from the stream.

The value is read as if it had been written by writeInt16: (OLOutStream). Specifically, an 2-byte field of data is read and converted from network byte order to host byte order.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (uint32_t) readInt32  

Read a 32-bit integer value from the stream.

The value is read as if it had been written by writeInt32: (OLOutStream). Specifically, an 4-byte field of data is read and converted from network byte order to host byte order.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (uint64_t) readInt64  

Read a 64-bit integer value from the stream.

The value is read as if it had been written by writeInt64: (OLOutStream). Specifically, an 8-byte field of data is read and converted from network byte order to host byte order.

Exceptions:
OLInputOutputException if the value could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the value read

Reimplemented in OLObjectInStream.

- (SEL) readSelector  

Read a selector from the stream.

The value is read as if it had been written by writeSelector: (OLOutStream).

Exceptions:
OLInputOutputException if the selector could not be read
OLEndOfStreamException if the end of the stream has been reached
Returns:
the selector read


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