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.
NSCoder Support
Support the streaming of objects that adopt the NSCoding protocol

(BOOL) - allowsKeyedCoding
 Returns whether the stream supports keyed coding.
(void *) - decodeBytesWithReturnedLength:
 Decode a buffer of data.
(NSData *) - decodeDataObject
 Decode a data object.
(id) - decodeObject
 Decode an object.
(void) - decodeValueOfObjCType:at:
 Decode a value of a specified Objective-C type.

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

- (BOOL) allowsKeyedCoding  

Returns whether the stream supports keyed coding.

No stream classes in ObjectiveLib support keyed coding, so this method will always return NO.

Returns:
NO, always

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

- (void*) decodeBytesWithReturnedLength: (unsigned *)  numBytes  

Decode a buffer of data.

This method is included solely to support objects that already support the NSCoding protocol, and relies on the lower-level message readBytes:count:. This message can be used to read data written by encodeBytes:length: (OLOutStream), however there is nothing to be gained by using this pair of messages over the preferred pair writeBytes:count: (OLOutStream) and readBytes:count:.

The returned pointer will be autoreleased before being returned and the value at the address numBytes will contain the number of bytes actually read.

Exceptions:
OLInputOutputException if there is an error reading from the stream
OLEndOfStreamException if the end of the stream has been reached
Parameters:
numBytes the number of bytes read
Returns:
a pointer to the bytes read

Reimplemented in OLObjectInStream.

- (NSData*) decodeDataObject  

Decode a data object.

This method is included solely to support objects that already support the NSCoding protocol, and relies on the lower-level message readBytes:count:. This message can be used to read data written by encodeDataObject: (OLOutStream), however there is nothing to be gained by using this pair of messages over the preferred pair writeBytes:count: (OLOutStream) and readBytes:count:.

The returned data object will be autoreleased before being returned.

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

Reimplemented in OLObjectInStream.

- (id) decodeObject  

Decode an object.

This method is not implemented in OLInStream. In order to read object instances from a stream one must use the layered stream class OLObjectInStream.

Returns:
the object instance that this class failed to read

Reimplemented in OLObjectInStream.

- (void) decodeValueOfObjCType: (const char *)  valueType
at: (void *)  address 

Decode a value of a specified Objective-C type.

Read a value of an arbitrary type from the stream. Note that in order to preserve platform-independence in the resulting stream, constraints are placed on how the data are read. Types that otherwise have indeterminate sizes will always be normalized to sizes chosen by ObjectiveLib. The sizes read are as follows:
TypeSize
char1
short2
int4
long4
long long8

Additionally, the behavior of returned pointers is different if the system is running under GNUstep or under Cocoa. Under GNUstep freshly allocated pointers returned from this method will be autoreleased, while under Cocoa the caller owns the pointer and must release it. This is not my fault.

Note:
Object instances and classes cannot be read using OLInStream's implementation of this method. OLObjectInStream must be used.
Exceptions:
OLInputOutputException if there is an error reading from the stream
OLEndOfStreamException if the end of the stream has been reached
Parameters:
valueType the type of the value at address
address the location of the value to read

Reimplemented in OLObjectInStream.

- (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:13:21 2007, © 2004-2007 Will Mason
SourceForge.net Logo