#import <ObjectiveLib/OutStream.h>
Inheritance diagram for OLOutStream:
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. |
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.
- (BOOL) allowsKeyedCoding |
Return 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 longer be available for writing.
OLInputOutputException | if there is an error closing the stream |
Reimplemented in OLBzlibOutStream, OLFileOutStream, OLGzipOutStream, OLLayeredOutStream, and OLZlibOutStream.
- (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:.
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 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:.
OLInputOutputException | if there is an error writing to the stream |
data | the 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.
object | the 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:
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 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.
OLInputOutputException | if there is an error flushing the stream |
Reimplemented in OLBufferingOutStream, OLFileOutStream, 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).
OLInputOutputException | if there is an error writing to the stream |
value | the 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.
OLInputOutputException | if there is an error writing to the stream |
byte | the 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.
OLInputOutputException | if there is an error writing to the stream |
bytes | the bytes to write | |
count | the number of bytes to write |
Reimplemented in OLBufferingOutStream, OLBzlibOutStream, OLDataOutStream, OLFileOutStream, OLGzipOutStream, OLLayeredOutStream, and OLZlibOutStream.
- (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 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.
OLInputOutputException | if there is an error writing to the stream |
value | the 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.
OLInputOutputException | if there is an error writing to the stream |
value | the 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.
OLInputOutputException | if there is an error writing to the stream |
value | the 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.
OLInputOutputException | if there is an error writing to the stream |
value | the 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.
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 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).
OLInputOutputException | if there is an error writing to the stream |
sel | the selector to write |
|