#import <ObjectiveLib/ObjectOutStream.h>
Inheritance diagram for OLObjectOutStream:
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. |
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.
- (void) dealloc |
- (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).
OLInputOutputException | if there is an error writing to the stream |
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).
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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:
Type | Size |
char | 1 |
short | 2 |
int | 4 |
long | 4 |
long long | 8 |
OLInputOutputException | if there is an error writing to the stream |
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.
underStream | the stream under the new one in the stream stack |
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.
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.
underStream | the stream under the new one in the stream stack |
- (unsigned) systemVersion |
Return the current system version.
The version refers to the version of the ObjectiveLib streaming system.
- (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.
className | the name 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).
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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.
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.
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
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.
int
on the platform being used, the value written will always be exactly four bytes long.OLInputOutputException | if there is an error writing to the stream |
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.
OLInputOutputException | if there is an error writing to the stream |
object | the object to write |
- (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.
|