OLObjectOutStream Class Reference
[Streams]

A stream that is capable of writing objects and classes. More...

#import <ObjectiveLib/ObjectOutStream.h>

Inheritance diagram for OLObjectOutStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - replaceObject:withObject:
 Replace all instances of an object.
(void) - writeBool:
 Write a boolean value to the stream.
(void) - writeClass:
 Write a class.
(void) - writeDouble:
 Write a double value to the stream.
(void) - writeFloat:
 Write a float value to the stream.
(void) - writeHeader
 Write the object stream header.
(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) - writeObject:
 Write an object.
Initializers and Deallocators
(void) - dealloc
 Finalize the stream and deallocate any allocated memory.
(id) - initWithOutStream:
 Initialize the stream.
NSCoder Support
Support the streaming of objects that adopt the NSCoding protocol

(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.
(unsigned) - systemVersion
 Return the current system version.
(unsigned) - versionForClassName:
 Return the current version of a class.

Static Public Member Functions

(id) + streamWithOutStream:
 Create and return a new stream.

Protected Attributes

OLPointerRefTable * pointerMap
 The map of pointers to object, selectors and classes that assoicates them with handles.
OLObjectReplaceTable * replacementMap
 The map of objects and their replacements.

Detailed Description

A stream that is capable of writing objects and classes.

In addition to having the ability to write objects and classes, OLObjectOutStream tags every type written to the stream, which is then verified when OLObjectInStream reads the value. If a certain type is expected but another type is found, an exception is raised to indicate the inconsistency. Also, objects and classes are tracked as they are written, and when an object or class is written that already appears in the stream, a handle is written that refers to the instance already written. This improves performance and reduces the size of the resulting data.

See also:
OLObjectInStream


Member Function Documentation

- (void) dealloc  

Finalize the stream and deallocate any allocated memory.

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

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
address the address of the data to write
numBytes the number of bytes to write

Reimplemented from OLOutStream.

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

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
data the data object to write

Reimplemented from OLOutStream.

- (void) encodeObject: (id)  object  

Encode an object.

The object will be written unless this object has already been written to the stream, in which case a reference to it will be written. This method forwards object to writeObject:, so there is nothing to be gained by using this method instead of that one.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
object the object to write

Reimplemented from OLOutStream.

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

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
valueType the type of the value at address
address the location of the value

Reimplemented from OLOutStream.

- (id) initWithOutStream: (OLOutStream *)  underStream  

Initialize the stream.

underStream becomes the next lower stream in the stream stack.

Parameters:
underStream the stream under the new one in the stream stack
Returns:
a reference to this stream

Reimplemented from OLLayeredOutStream.

- (void) replaceObject: (id)  obj
withObject: (id)  rep 

Replace all instances of an object.

After receiving this message the stream will always replace any occurrence of obj with rep.

Parameters:
obj the object to replace
rep the replacement object

+ (id) streamWithOutStream: (OLOutStream *)  underStream  

Create and return a new stream.

The underStream becomes the next lower stream in the stream stack.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
underStream the stream under the new one in the stream stack
Returns:
a reference to the newly created stream

- (unsigned) systemVersion  

Return the current system version.

The version refers to the version of the ObjectiveLib streaming system.

Returns:
the system version

- (unsigned) versionForClassName: (NSString *)  className  

Return the current version of a class.

The name of the class is used to look up its version in the Objective-C runtime system. This version is returned.

Note:
If no class by the given name can be found in the runtime, then the value NSNotFound is returned.
Parameters:
className the name of the class
Returns:
the version of the class

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the boolean value to write

Reimplemented from OLOutStream.

- (void) writeClass: (Class)  cls  

Write a class.

The class will be written unless this class has already been written to the stream, in which case a reference to it will be written.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
cls the class to write

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the double value to write

Reimplemented from OLOutStream.

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the float value to write

Reimplemented from OLOutStream.

- (void) writeHeader  

Write the object stream header.

This method can be overridden to write a custom header to the object stream. It will be called in due course, so it is never necessary to call this method.

Note:
Subclasses that override this method should call the superclass' method before writing any additional data.
Exceptions:
OLInputOutputException if there is an error writing to the stream

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the integer value to write

Reimplemented from OLOutStream.

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the integer value to write

Reimplemented from OLOutStream.

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the integer value to write

Reimplemented from OLOutStream.

- (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:
OLInputOutputException if there is an error writing to the stream
Parameters:
value the integer value to write

Reimplemented from OLOutStream.

- (void) writeObject: (id)  object  

Write an object.

The object will be written unless this object has already been written to the stream, in which case a reference to it will be written.

Precondition:
object must support either the OLStreamable protocol or the NSCoding protocol. If both protocols are found, then preference is given to the methods from OLStreamable.
Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
object the object to write


Member Data Documentation

- (OLPointerRefTable*) pointerMap [protected]

The map of pointers to object, selectors and classes that assoicates them with handles.

- (OLObjectReplaceTable*) replacementMap [protected]

The map of objects and their replacements.


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