ObjectiveLib  1.0.0
Public Member Functions
OLOutStream Class Reference

Base class for writing data. More...

#import <ObjectiveLib/OutStream.h>

Inheritance diagram for OLOutStream:
Inheritance graph
[legend]

List of all members.

Public Member Functions

(void) - close
 Close the stream.
(void) - flush
 Flush the stream.
(void) - writeBool:
 Write a boolean value to the stream.
(void) - writeByte:
 Write a byte to the stream.
(unsigned) - writeBytes:count:
 Write a sequence of bytes to the stream.
(void) - writeDouble:
 Write a double value to the stream.
(void) - writeFloat:
 Write a float value to the stream.
(void) - writeInt16:
 Write a 16-bite integer value to the stream.
(void) - writeInt32:
 Write a 32-bit integer value to the stream.
(void) - writeInt64:
 Write a 64-bit integer value to the stream.
(void) - writeInt:
 Write a integer value to the stream.
(void) - writeSelector:
 Write a selector to the stream.
NSCoder Support

Support the streaming of objects that adopt the NSCoding protocol

(BOOL) - allowsKeyedCoding
 Return whether the stream supports keyed coding.
(void) - encodeBytes:length:
 Encode a buffer of data.
(void) - encodeDataObject:
 Encode a data object.
(void) - encodeObject:
 Encode an object.
(void) - encodeValueOfObjCType:at:
 Encode a value of a specified Objective-C type.

Detailed Description

Base class for writing data.

OLOutStream provides the basic stream services which include writing 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 write themselves through an instance of OLObjectOutStream. The lower-level methods provided by OLOutStream 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 written using OLOutStream. An instance of OLObjectOutStream must be used instead. The NSCoder support provided in OLOutStream is merely a byproduct of the class hierarchy imposed by NSCoder.

Member Function Documentation

Return 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 longer be available for writing.

Exceptions:
OLInputOutputExceptionif there is an error closing the stream

Reimplemented in OLZlibOutStream, OLBzlibOutStream, OLGzipOutStream, OLFileOutStream, and OLLayeredOutStream.

- (void) encodeBytes: (const void *)  address
length: (unsigned)  numBytes 

Encode 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 writeBytes:count:. There is nothing to be gained by choosing to call this method explicitly over the preferred method writeBytes:count:.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
addressthe address of the data to write
numBytesthe number of bytes to write

Reimplemented in OLObjectOutStream.

- (void) encodeDataObject: (NSData *)  data

Encode a data object.

This method is included solely to support objects that already support the NSCoding protocol, and relies on the lower-level message writeBytes:count:. There is nothing to be gained by choosing to call this method explicitly over the preferred method writeBytes:count:.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
datathe data object to write

Reimplemented in OLObjectOutStream.

- (void) encodeObject: (id)  object

Encode an object.

This method is not implemented in OLOutStream. In order to write object instances to a stream one must use the layered stream class OLObjectOutStream.

Parameters:
objectthe object that this class should fail to write

Reimplemented in OLObjectOutStream.

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

Encode a value of a specified Objective-C type.

Write a value of an arbitrary type to the stream. Note that in order to preserve platform-independence in the resulting stream, constraints are placed on how the data are written. Types that otherwise have indeterminate sizes will always be normalized to sizes chosen by ObjectiveLib. The sizes written are as follows:

TypeSize
char1
short2
int4
long4
long long8
Note:
Object instances and classes cannot be written using OLOutStream's implementation of this method. OLObjectOutStream must be used.
Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valueTypethe type of the value at address
addressthe location of the value

Reimplemented in OLObjectOutStream.

- (void) flush

Flush the stream.

Any data that is pending or buffered will be written and the stream will be restored to a pristine state.

Exceptions:
OLInputOutputExceptionif there is an error flushing the stream

Reimplemented in OLFileOutStream, OLBufferingOutStream, and OLLayeredOutStream.

- (void) writeBool: (BOOL)  value

Write a boolean value to the stream.

The value is written in a platform-independent way and can be read using readBool (OLInStream). Specifically, the value is written as a single byte with a value of 1 if value is YES (or non-zero), and as a single byte with a value of 0 if value is NO (or zero).

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe boolean value to write

Reimplemented in OLObjectOutStream.

- (void) writeByte: (uint8_t)  byte

Write a byte to the stream.

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

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
bytethe byte to write

Reimplemented in OLBufferingOutStream.

- (unsigned) writeBytes: (const uint8_t *)  bytes
count: (unsigned)  count 

Write a sequence of bytes to the stream.

This is the fundamental method for writing to a stream, and subclasses must override this method.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
bytesthe bytes to write
countthe number of bytes to write
Returns:
the number of bytes written

Reimplemented in OLGzipOutStream, OLZlibOutStream, OLBzlibOutStream, OLFileOutStream, OLDataOutStream, OLBufferingOutStream, and OLLayeredOutStream.

- (void) writeDouble: (double)  value

Write a double value to the stream.

The double is written in a platform-independent way and can be read using readDouble (OLInStream). Specifically, the value is written as an 8-byte array in network byte order.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe double value to write

Reimplemented in OLObjectOutStream.

- (void) writeFloat: (float)  value

Write a float value to the stream.

The float is written in a platform-independent way and can be read using readFloat (OLInStream). Specifically, the value is written as a 4-byte array in network byte order.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe float value to write

Reimplemented in OLObjectOutStream.

- (void) writeInt16: (uint16_t)  value

Write a 16-bite integer value to the stream.

The integer is written in a platform-independent way and can be read using readInt16 (OLInStream). Specifically, the value is written as a 2-byte array in network byte order.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe integer value to write

Reimplemented in OLObjectOutStream.

- (void) writeInt32: (uint32_t)  value

Write a 32-bit integer value to the stream.

The integer is written in a platform-independent way and can be read using readInt32 (OLInStream). Specifically, the value is written as a 4-byte array in network byte order.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe integer value to write

Reimplemented in OLObjectOutStream.

- (void) writeInt64: (uint64_t)  value

Write a 64-bit integer value to the stream.

The integer is written in a platform-independent way and can be read using readInt64 (OLInStream). Specifically, the value is written as an 8-byte array in network byte order.

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe integer value to write

Reimplemented in OLObjectOutStream.

- (void) writeInt: (unsigned)  value

Write a integer value to the stream.

The integer is written in a platform-independent way and can be read using readInt (OLInStream). Specifically, the value is written as a 4-byte array in network byte order.

Note:
Regardless of the size of the type int on the platform being used, the value written will always be exactly four bytes long.
Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
valuethe integer value to write

Reimplemented in OLObjectOutStream.

- (void) writeSelector: (SEL)  sel

Write a selector to the stream.

The selector can later be read from an OLInStream using the method readSelector (OLInStream).

Exceptions:
OLInputOutputExceptionif there is an error writing to the stream
Parameters:
selthe selector to write

The documentation for this class was generated from the following file:

ObjectiveLibGenerated Sat Feb 15 2014 07:45:35, © 2004-2007 Will Mason