#import <ObjectiveLib/InStream.h>
Inheritance diagram for OLInStream:
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. |
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.
- (BOOL) allowsKeyedCoding |
Returns whether the stream supports keyed coding.
No stream classes in ObjectiveLib support keyed coding, so this method will always return NO.
- (void) close |
Close the stream.
After receiving this message the stream will no long be available for reading.
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.
OLInputOutputException | if there is an error reading from the stream | |
OLEndOfStreamException | if the end of the stream has been reached |
numBytes | the number of 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.
OLInputOutputException | if there is an error reading from the stream | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
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:
Type | Size |
char | 1 |
short | 2 |
int | 4 |
long | 4 |
long long | 8 |
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.
OLInputOutputException | if there is an error reading from the stream | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if there is an error reading from the stream | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if there is an error reading from the stream |
buffer | the address to which the bytes should be read | |
max | the maximum number bytes that should 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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
int
on the platform being used, the value read will always be exactly four bytes long and returned as an unsigned
value.OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
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.
OLInputOutputException | if the value could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
Reimplemented in OLObjectInStream.
- (SEL) readSelector |
Read a selector from the stream.
The value is read as if it had been written by writeSelector: (OLOutStream).
OLInputOutputException | if the selector could not be read | |
OLEndOfStreamException | if the end of the stream has been reached |
|