ROBinReaderWriter

Overview

The ROBinReaderWriter class is used to serialize and deserialize any kind of data into the bytes buffer. It provides a lot of symmetrical read/write methods for each datatype, so you can easily write and read any objects to and from NSData. This class is used by the ROBinMessage to read/write data into the binary message. In most cases you do not need to deal with this class directly.

Location

 

advancePositionBy:

Moves the current position forward or backward to the specified count of bytes. To move the position backward, you need to specify a negative value in the by parameter.

- (void) advancePositionBy:(long)by

Parameters:

  • by: Count of bytes needed to shift the current position

data

Represents an instance of NSData that holds all serialized data.

@property (readonly) NSData *data

getBytesOfSize:

Reads and returns the bytes buffer with the specified size.

- (byte *) getBytesOfSize:(int)aSize

Parameters:

  • aSize: Size of the bytes buffer to be read

initForReadingWithData:

- (InstanceType) initForReadingWithData:(NSData *)aData

Parameters:

  • aData:

initForReadingWithData:atOffset:

- (InstanceType) initForReadingWithData:(NSData *)aData atOffset:(int)aOffset

Parameters:

  • aData:
  • aOffset:

initForWriting

- (InstanceType) initForWriting

initForWritingAtOffset:

- (InstanceType) initForWritingAtOffset:(int)aOffset

Parameters:

  • aOffset:

initForWritingWithData:atOffset:

- (InstanceType) initForWritingWithData:(NSMutableData *)aData atOffset:(int)aOffset

Parameters:

  • aData:
  • aOffset:

length

Returns the length of the serialized data.

@property (readonly) int length

mutableData

represent the content of the ROBinReaderWriter

@property (readonly) NSMutableData *mutableData

position  assign

Read/Write property that represents the current position inside the bytes buffer. You can use it for writing data into the bytes buffer with a custom offset.

@property (assign) int position

readAnsiString:

- (void) readAnsiString:(NSString * *)aString

Parameters:

  • aString:

readBoolean

This method reads and returns the next Int32 value from the stream as Boolean, where 0 is NO and any other value is YES.

- (BOOL) readBoolean

readBoolean:

This method reads the next Int32 value as BOOL from the stream into the specified pointer.

- (void) readBoolean:(BOOL *)aInt

Parameters:

  • aInt: Pointer to where the BOOL value should be read

readByte

This method reads and returns the next Byte value from the stream.

- (byte) readByte

readByte:

This method reads the next Byte value from the stream into the specified pointer.

- (void) readByte:(byte *)aByte

Parameters:

  • aByte: Pointer to where the Byte value should be read

readByteBoolean

Reads a byte value from the stream and interprets it as boolean, where 0 means NO and all other values means YES.

- (BOOL) readByteBoolean

readByteBoolean:

Reads a byte value from the stream and interprets it as boolean, where 0 means NO and all other values means YES. method put the result value into the specified pointer parameter.

- (void) readByteBoolean:(BOOL *)aInt

Parameters:

  • aInt: Pointer to where the Boolean value should be read

readCurrency:

- (void) readCurrency:(NSDecimalNumber * *)aDecimal

Parameters:

  • aDecimal:

readDAGuid:

- (void) readDAGuid:(ROGuid * *)value

Parameters:

  • value:

readDateTime:

- (void) readDateTime:(NSDate * *)aDate

Parameters:

  • aDate:

readDAWideString:

- (void) readDAWideString:(NSString * *)aString

Parameters:

  • aString:

readDecimal:

- (void) readDecimal:(NSDecimalNumber * *)aDecimal

Parameters:

  • aDecimal:

readDouble:

Reads the next Double value from the binary stream into the specified pointer.

- (void) readDouble:(double *)aDouble

Parameters:

  • aDouble: Pointer to where the Double value should be read

readEnum:

- (void) readEnum:(NSUInteger *)aEnum

Parameters:

  • aEnum:

readFloat:

Reads the float value from the binary stream into the specified pointer.

- (void) readFloat:(float *)value

Parameters:

  • value: Pointer to where the float value should be read

readGuid:

- (void) readGuid:(ROGuid * *)value

Parameters:

  • value:

readInt16:

Reads the next 2 bytes from the stream as Int16 value into the specified pointer.

- (void) readInt16:(int16 *)aInt

Parameters:

  • aInt: Pointer to the Int16 value should be read

readInt32

Reads the next 4 bytes from the stream and returns them as Int32 value.

- (int32) readInt32

readInt32:

Reads the next 4 bytes from the stream as Int32 value into the specified pointer.

- (void) readInt32:(int32 *)aInt

Parameters:

  • aInt: Pointer to the Int32 value should be read

readInt64:

Reads the next 8 bytes from the stream as Int64 value into the specified pointer.

- (void) readInt64:(int64 *)aInt

Parameters:

  • aInt: Pointer to where the Int64 value should be read

readNext:to:

Reads a specified count of bytes into the specified pointer.

- (void) readNext:(long)count to:(void *)to

Parameters:

  • count: Count of bytes to read
  • to: Pointer to where the bytes should be read

readRawDataOfSize:

Reads a specified count of raw bytes and returns them as new bytes buffer.

- (NSData *) readRawDataOfSize:(int)aSize

Parameters:

  • aSize: Size of bytes to read

readUInt16:

Reads the next 2 bytes from the stream as unsigned Int16 value into the specified pointer.

- (void) readUInt16:(uint16 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int16 value should be put

readUInt32:

Reads the next 4 bytes from the stream as unsigned Int32 value into the specified pointer.

- (void) readUInt32:(uint32 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int32 value should be put

readUInt64:

Reads the next 8 bytes from the stream as unsigned Int64 value into the specified pointer.

- (void) readUInt64:(uint64 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int64 value should be put

readUtf8String

Reads and returns a Utf8 string value from the stream.

- (NSString *) readUtf8String

readUtf8String:

- (void) readUtf8String:(NSString * *)aString

Parameters:

  • aString:

readVariant:typeCode:

- (void) readVariant:(ROVariant * *)aVariant typeCode:(enum ROVariantTypeCode)aTypeCode

Parameters:

  • aVariant:
  • aTypeCode:

readWideString:

- (void) readWideString:(NSString * *)aString

Parameters:

  • aString:

remainingLength

Returns the remaining length of the bytes buffer (equals the length of the bytes buffer minus the current position inside it).

@property (readonly) int remainingLength

tryReadUtf8String

Reads a Utf8 string value from the stream into the specified pointer. In contrast to the readUtf8String: method, this method does not throw an unexpectedStringLength exception when attempting to read nonexistent data at the end of the stream.

- (NSString *) tryReadUtf8String

writeAnsiString:

Writes the given string as Ansi string into the stream.

- (void) writeAnsiString:(NSString *)aString

Parameters:

  • aString: String value to be put into the stream

writeBoolean:

Writes the given boolean value into the stream as Int32 value, where 0 is No and any other value is YES.

- (void) writeBoolean:(BOOL)aBoolean

Parameters:

  • aBoolean: Boolean value to be put into the stream

writeByte:

Writes the given Byte value into the stream.

- (void) writeByte:(byte)aByte

Parameters:

  • aByte: Byte value to be put into the stream

writeByteBoolean:

Writes the given boolean value into the stream as Byte, where 0 is No and any other value is YES.

- (void) writeByteBoolean:(BOOL)aBoolean

Parameters:

  • aBoolean: Boolean value to be put into the stream

writeBytes:length:

Writes the bytes buffer with the given length into the stream.

- (void) writeBytes:(void *)bytes length:(int)length

Parameters:

  • bytes: Bytes buffer to write
  • length: Count of bytes to be written.

writeBytes:length:toOffset:

Writes the bytes buffer with the given length into the stream at the specified offset.

- (void) writeBytes:(void *)bytes length:(int)length toOffset:(int)offset

Parameters:

  • bytes: Bytes buffer to write
  • length: Count of bytes to be written
  • offset: Position in the stream from where the writing should start

writeCurrency:

Writes a Currency value into the stream.

- (void) writeCurrency:(NSDecimalNumber *)aCurrency

Parameters:

  • aCurrency: Currency value to be put into the stream

writeDAGuid:

Writes a GUID value into the stream.

- (void) writeDAGuid:(ROGuid *)value

Parameters:

  • value: GUID value to be written into the stream.+

writeDateTime:

Writes a DateTime value into the stream.

- (void) writeDateTime:(NSDate *)aDate

Parameters:

  • aDate: DateTime value to be written into the stream

writeDAWideString:

Writes a WideString value into the stream. Each char inside the WideString occupies 2 bytes.

- (void) writeDAWideString:(NSString *)aString

Parameters:

  • aString: String to be written to the stream as WideString

writeDecimal:

Writes a Decimal value into the stream.

- (void) writeDecimal:(NSDecimalNumber *)aDecimal

Parameters:

  • aDecimal: Value to be put into the stream

writeDouble:

Writes a Double value into the stream.

- (void) writeDouble:(double)aDouble

Parameters:

  • aDouble: Double value to be put into the stream

writeEnum:

- (void) writeEnum:(NSUInteger)aEnum

Parameters:

  • aEnum:

writeFloat:

Writes given Float value into the stream.

- (void) writeFloat:(float)value

Parameters:

  • value: Float value to be put into the stream

writeGuid:

Writes a GUID value into the stream.

- (void) writeGuid:(ROGuid *)value

Parameters:

  • value: GUID value to be written into the stream

writeInt16:

Writes an Int16 value into the stream.

- (void) writeInt16:(int16)aInt

Parameters:

  • aInt: Value to be put into the stream

writeInt32:

Writes an Int32 value into the stream.

- (void) writeInt32:(int32)aInt

Parameters:

  • aInt: Value to be put into the stream

writeInt32:toOffset:

Writes an Int32 value into the stream at the specified offset.

- (void) writeInt32:(int32)value toOffset:(int)offset

Parameters:

  • value: Value to be written
  • offset: Position in the stream from where writing should be started

writeInt64:

Writes an Int64 value into the stream.

- (void) writeInt64:(int64)aInt

Parameters:

  • aInt: Value to be written

writeRawData:

Writes raw data into the stream.

- (void) writeRawData:(NSData *)aData

Parameters:

  • aData: Raw data to be written

writeUInt16:

Writes a UInt16 value into the stream.

- (void) writeUInt16:(uint16)aInt

Parameters:

  • aInt: Unsigned Int16 value to be written

writeUInt32:

Writes a UInt32 value into the stream.

- (void) writeUInt32:(uint32)aInt

Parameters:

  • aInt: Unsigned Int32 value to be written

writeUInt64:

Writes a UInt64 value into the stream.

- (void) writeUInt64:(uint64)aInt

Parameters:

  • aInt: Unsigned Int64 value to be written

writeUtf8String:

Writes a string value into the stream as UTF8 String.

- (void) writeUtf8String:(NSString *)aString

Parameters:

  • aString: String value to be written into the stream

writeWideString:

Writes a String value into the stream as WideString.

- (void) writeWideString:(NSString *)aString

Parameters:

  • aString: String value to be written into the stream

 

data

Represents an instance of NSData that holds all serialized data.

@property (readonly) NSData *data

length

Returns the length of the serialized data.

@property (readonly) int length

mutableData

represent the content of the ROBinReaderWriter

@property (readonly) NSMutableData *mutableData

position  assign

Read/Write property that represents the current position inside the bytes buffer. You can use it for writing data into the bytes buffer with a custom offset.

@property (assign) int position

remainingLength

Returns the remaining length of the bytes buffer (equals the length of the bytes buffer minus the current position inside it).

@property (readonly) int remainingLength

 

advancePositionBy:

Moves the current position forward or backward to the specified count of bytes. To move the position backward, you need to specify a negative value in the by parameter.

- (void) advancePositionBy:(long)by

Parameters:

  • by: Count of bytes needed to shift the current position

getBytesOfSize:

Reads and returns the bytes buffer with the specified size.

- (byte *) getBytesOfSize:(int)aSize

Parameters:

  • aSize: Size of the bytes buffer to be read

initForReadingWithData:

- (InstanceType) initForReadingWithData:(NSData *)aData

Parameters:

  • aData:

initForReadingWithData:atOffset:

- (InstanceType) initForReadingWithData:(NSData *)aData atOffset:(int)aOffset

Parameters:

  • aData:
  • aOffset:

initForWriting

- (InstanceType) initForWriting

initForWritingAtOffset:

- (InstanceType) initForWritingAtOffset:(int)aOffset

Parameters:

  • aOffset:

initForWritingWithData:atOffset:

- (InstanceType) initForWritingWithData:(NSMutableData *)aData atOffset:(int)aOffset

Parameters:

  • aData:
  • aOffset:

readAnsiString:

- (void) readAnsiString:(NSString * *)aString

Parameters:

  • aString:

readBoolean

This method reads and returns the next Int32 value from the stream as Boolean, where 0 is NO and any other value is YES.

- (BOOL) readBoolean

readBoolean:

This method reads the next Int32 value as BOOL from the stream into the specified pointer.

- (void) readBoolean:(BOOL *)aInt

Parameters:

  • aInt: Pointer to where the BOOL value should be read

readByte

This method reads and returns the next Byte value from the stream.

- (byte) readByte

readByte:

This method reads the next Byte value from the stream into the specified pointer.

- (void) readByte:(byte *)aByte

Parameters:

  • aByte: Pointer to where the Byte value should be read

readByteBoolean

Reads a byte value from the stream and interprets it as boolean, where 0 means NO and all other values means YES.

- (BOOL) readByteBoolean

readByteBoolean:

Reads a byte value from the stream and interprets it as boolean, where 0 means NO and all other values means YES. method put the result value into the specified pointer parameter.

- (void) readByteBoolean:(BOOL *)aInt

Parameters:

  • aInt: Pointer to where the Boolean value should be read

readCurrency:

- (void) readCurrency:(NSDecimalNumber * *)aDecimal

Parameters:

  • aDecimal:

readDAGuid:

- (void) readDAGuid:(ROGuid * *)value

Parameters:

  • value:

readDateTime:

- (void) readDateTime:(NSDate * *)aDate

Parameters:

  • aDate:

readDAWideString:

- (void) readDAWideString:(NSString * *)aString

Parameters:

  • aString:

readDecimal:

- (void) readDecimal:(NSDecimalNumber * *)aDecimal

Parameters:

  • aDecimal:

readDouble:

Reads the next Double value from the binary stream into the specified pointer.

- (void) readDouble:(double *)aDouble

Parameters:

  • aDouble: Pointer to where the Double value should be read

readEnum:

- (void) readEnum:(NSUInteger *)aEnum

Parameters:

  • aEnum:

readFloat:

Reads the float value from the binary stream into the specified pointer.

- (void) readFloat:(float *)value

Parameters:

  • value: Pointer to where the float value should be read

readGuid:

- (void) readGuid:(ROGuid * *)value

Parameters:

  • value:

readInt16:

Reads the next 2 bytes from the stream as Int16 value into the specified pointer.

- (void) readInt16:(int16 *)aInt

Parameters:

  • aInt: Pointer to the Int16 value should be read

readInt32

Reads the next 4 bytes from the stream and returns them as Int32 value.

- (int32) readInt32

readInt32:

Reads the next 4 bytes from the stream as Int32 value into the specified pointer.

- (void) readInt32:(int32 *)aInt

Parameters:

  • aInt: Pointer to the Int32 value should be read

readInt64:

Reads the next 8 bytes from the stream as Int64 value into the specified pointer.

- (void) readInt64:(int64 *)aInt

Parameters:

  • aInt: Pointer to where the Int64 value should be read

readNext:to:

Reads a specified count of bytes into the specified pointer.

- (void) readNext:(long)count to:(void *)to

Parameters:

  • count: Count of bytes to read
  • to: Pointer to where the bytes should be read

readRawDataOfSize:

Reads a specified count of raw bytes and returns them as new bytes buffer.

- (NSData *) readRawDataOfSize:(int)aSize

Parameters:

  • aSize: Size of bytes to read

readUInt16:

Reads the next 2 bytes from the stream as unsigned Int16 value into the specified pointer.

- (void) readUInt16:(uint16 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int16 value should be put

readUInt32:

Reads the next 4 bytes from the stream as unsigned Int32 value into the specified pointer.

- (void) readUInt32:(uint32 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int32 value should be put

readUInt64:

Reads the next 8 bytes from the stream as unsigned Int64 value into the specified pointer.

- (void) readUInt64:(uint64 *)aInt

Parameters:

  • aInt: Pointer to where the unsigned Int64 value should be put

readUtf8String

Reads and returns a Utf8 string value from the stream.

- (NSString *) readUtf8String

readUtf8String:

- (void) readUtf8String:(NSString * *)aString

Parameters:

  • aString:

readVariant:typeCode:

- (void) readVariant:(ROVariant * *)aVariant typeCode:(enum ROVariantTypeCode)aTypeCode

Parameters:

  • aVariant:
  • aTypeCode:

readWideString:

- (void) readWideString:(NSString * *)aString

Parameters:

  • aString:

tryReadUtf8String

Reads a Utf8 string value from the stream into the specified pointer. In contrast to the readUtf8String: method, this method does not throw an unexpectedStringLength exception when attempting to read nonexistent data at the end of the stream.

- (NSString *) tryReadUtf8String

writeAnsiString:

Writes the given string as Ansi string into the stream.

- (void) writeAnsiString:(NSString *)aString

Parameters:

  • aString: String value to be put into the stream

writeBoolean:

Writes the given boolean value into the stream as Int32 value, where 0 is No and any other value is YES.

- (void) writeBoolean:(BOOL)aBoolean

Parameters:

  • aBoolean: Boolean value to be put into the stream

writeByte:

Writes the given Byte value into the stream.

- (void) writeByte:(byte)aByte

Parameters:

  • aByte: Byte value to be put into the stream

writeByteBoolean:

Writes the given boolean value into the stream as Byte, where 0 is No and any other value is YES.

- (void) writeByteBoolean:(BOOL)aBoolean

Parameters:

  • aBoolean: Boolean value to be put into the stream

writeBytes:length:

Writes the bytes buffer with the given length into the stream.

- (void) writeBytes:(void *)bytes length:(int)length

Parameters:

  • bytes: Bytes buffer to write
  • length: Count of bytes to be written.

writeBytes:length:toOffset:

Writes the bytes buffer with the given length into the stream at the specified offset.

- (void) writeBytes:(void *)bytes length:(int)length toOffset:(int)offset

Parameters:

  • bytes: Bytes buffer to write
  • length: Count of bytes to be written
  • offset: Position in the stream from where the writing should start

writeCurrency:

Writes a Currency value into the stream.

- (void) writeCurrency:(NSDecimalNumber *)aCurrency

Parameters:

  • aCurrency: Currency value to be put into the stream

writeDAGuid:

Writes a GUID value into the stream.

- (void) writeDAGuid:(ROGuid *)value

Parameters:

  • value: GUID value to be written into the stream.+

writeDateTime:

Writes a DateTime value into the stream.

- (void) writeDateTime:(NSDate *)aDate

Parameters:

  • aDate: DateTime value to be written into the stream

writeDAWideString:

Writes a WideString value into the stream. Each char inside the WideString occupies 2 bytes.

- (void) writeDAWideString:(NSString *)aString

Parameters:

  • aString: String to be written to the stream as WideString

writeDecimal:

Writes a Decimal value into the stream.

- (void) writeDecimal:(NSDecimalNumber *)aDecimal

Parameters:

  • aDecimal: Value to be put into the stream

writeDouble:

Writes a Double value into the stream.

- (void) writeDouble:(double)aDouble

Parameters:

  • aDouble: Double value to be put into the stream

writeEnum:

- (void) writeEnum:(NSUInteger)aEnum

Parameters:

  • aEnum:

writeFloat:

Writes given Float value into the stream.

- (void) writeFloat:(float)value

Parameters:

  • value: Float value to be put into the stream

writeGuid:

Writes a GUID value into the stream.

- (void) writeGuid:(ROGuid *)value

Parameters:

  • value: GUID value to be written into the stream

writeInt16:

Writes an Int16 value into the stream.

- (void) writeInt16:(int16)aInt

Parameters:

  • aInt: Value to be put into the stream

writeInt32:

Writes an Int32 value into the stream.

- (void) writeInt32:(int32)aInt

Parameters:

  • aInt: Value to be put into the stream

writeInt32:toOffset:

Writes an Int32 value into the stream at the specified offset.

- (void) writeInt32:(int32)value toOffset:(int)offset

Parameters:

  • value: Value to be written
  • offset: Position in the stream from where writing should be started

writeInt64:

Writes an Int64 value into the stream.

- (void) writeInt64:(int64)aInt

Parameters:

  • aInt: Value to be written

writeRawData:

Writes raw data into the stream.

- (void) writeRawData:(NSData *)aData

Parameters:

  • aData: Raw data to be written

writeUInt16:

Writes a UInt16 value into the stream.

- (void) writeUInt16:(uint16)aInt

Parameters:

  • aInt: Unsigned Int16 value to be written

writeUInt32:

Writes a UInt32 value into the stream.

- (void) writeUInt32:(uint32)aInt

Parameters:

  • aInt: Unsigned Int32 value to be written

writeUInt64:

Writes a UInt64 value into the stream.

- (void) writeUInt64:(uint64)aInt

Parameters:

  • aInt: Unsigned Int64 value to be written

writeUtf8String:

Writes a string value into the stream as UTF8 String.

- (void) writeUtf8String:(NSString *)aString

Parameters:

  • aString: String value to be written into the stream

writeWideString:

Writes a String value into the stream as WideString.

- (void) writeWideString:(NSString *)aString

Parameters:

  • aString: String value to be written into the stream