Xrb::Serializer Class Reference

Provides the abstract interface for serialized data streams. More...

#include <xrb_serializer.hpp>

Inheritance diagram for Xrb::Serializer:

Inheritance graph
[legend]

List of all members.

Public Types

enum  { MAX_SUPPORTED_STRING_LENGTH = MAX_SUPPORTED_STRING_BUFFER_SIZE - 1 }

Public Member Functions

bool IsOpen () const
 Get the open state of the serializer.
IODirection GetIODirection () const
 Get the I/O direction of the serializer.
virtual bool IsAtEnd () const =0
 Get the end-of-stream condition.
virtual bool HasFewerThan8BitsLeft () const =0
 Get the less-than-one-byte-left-in-in-the-stream condition.
IOError Error () const
 Get the error state of the most recently called procedure.
char const * ErrorString () const
 Get the string which describes the current error state.
virtual Sint32 ReadSignedBits (Uint32 bit_count)=0
 Read a specific number of signed bits from the stream.
virtual void WriteSignedBits (Sint32 value, Uint32 bit_count)=0
 Write the least significant bit_count bits (up to 32) of the signed integer, value, to the stream.
virtual Uint32 ReadUnsignedBits (Uint32 bit_count)=0
 Read a specific number of unsigned bits from the stream.
virtual void WriteUnsignedBits (Uint32 value, Uint32 bit_count)=0
 Write the least significant bit_count bits (up to 32) of the unsigned integer, value, to the stream.
virtual bool ReadBool ()=0
 Read a boolean value from the stream.
virtual void WriteBool (bool value)=0
 Write a boolean value to the stream.
template<Uint32 bit_count>
BitArray< bit_count > ReadBitArray ()
 Reads a BitArray<bit_count> object from the stream.
template<Uint32 bit_count>
void WriteBitArray (BitArray< bit_count > const &value)
 Writes a BitArray<bit_count> object to the stream.
template<Uint32 bit_count>
BitArray< bit_count > ReadBitArray (Uint32 bits_to_read)
 Reads bits_to_read bits from the stream into a BitArray<bit_count> object.
template<Uint32 bit_count>
void WriteBitArray (BitArray< bit_count > const &value, Uint32 bits_to_write)
 Writes bits_to_read bits to the stream from the given BitArray<bit_count> object.
virtual Sint8 ReadSint8 ()=0
 Read a signed, 8-bit integer value from the stream.
virtual void WriteSint8 (Sint8 value)=0
 Write a signed, 8-bit integer value to the stream.
virtual Uint8 ReadUint8 ()=0
 Read an unsigned, 8-bit integer value from the stream.
virtual void WriteUint8 (Uint8 value)=0
 Write an unsigned, 8-bit integer value to the stream.
virtual Sint16 ReadSint16 ()=0
 Read a signed, 16-bit integer value from the stream.
virtual void WriteSint16 (Sint16 value)=0
 Write a signed, 16-bit integer value to the stream.
virtual Uint16 ReadUint16 ()=0
 Read an unsigned, 16-bit integer value from the stream.
virtual void WriteUint16 (Uint16 value)=0
 Write an unsigned, 16-bit integer value to the stream.
virtual Sint32 ReadSint32 ()=0
 Read a signed, 32-bit integer value from the stream.
virtual void WriteSint32 (Sint32 value)=0
 Write a signed, 32-bit integer value to the stream.
virtual Uint32 ReadUint32 ()=0
 Read an unsigned, 32-bit integer value from the stream.
virtual void WriteUint32 (Uint32 value)=0
 Write an unsigned, 32-bit integer value to the stream.
ScreenCoord ReadScreenCoord ()
 Read a ScreenCoord value from the stream.
void WriteScreenCoord (ScreenCoord value)
 Write a ScreenCoord value to the stream.
virtual void ReadFloat (float *destination)=0
 Read an IEEE single-precision floating point value from the stream.
virtual void WriteFloat (float value)=0
 Write an IEEE single-precision floating point value to the stream.
virtual void ReadFloat (double *destination)=0
 Read an IEEE double-precision floating point value from the stream.
virtual void WriteFloat (double value)=0
 Write an IEEE double-precision floating point value to the stream.
virtual Uint32 ReadBufferString (char *destination, Uint32 destination_size)=0
 Read a string from the stream into the provided array.
virtual Uint32 WriteBufferString (char const *source, Uint32 source_size)=0
 Write the given string to the stream, but write no more than source_size characters (including the null-terminating character).
virtual Uint32 ReadString (char **destination)
 Reads a character string from the stream.
virtual Uint32 WriteString (char const *source)
 Writes the given null-terminated string to the stream.
std::string ReadStdString (Uint32 *string_length=NULL)
 Reads a std::string character string from the stream.
void ReadStdString (std::string *destination, Uint32 *string_length=NULL)
 Reads a std::string character string from the stream.
void WriteStdString (std::string const &source, Uint32 *string_length=NULL)
 Writes the given std::string character string to the stream.
Color ReadColor ()
 Reads a Color from the stream.
virtual void ReadColor (Color *destination)=0
 Reads a Color from the stream.
virtual void WriteColor (Color const &value)=0
 Writes the given std::string character string to the stream.
ScreenCoordVector2 ReadScreenCoordVector2 ()
 Reads a ScreenCoordVector2 from the stream.
virtual void ReadScreenCoordVector2 (ScreenCoordVector2 *destination)=0
 Reads a ScreenCoordVector2 from the stream.
virtual void WriteScreenCoordVector2 (ScreenCoordVector2 const &value)=0
 Writes the given ScreenCoordVector2 to the stream.
FloatVector2 ReadFloatVector2 ()
 Reads a FloatVector2 from the stream.
virtual void ReadFloatVector2 (FloatVector2 *destination)=0
 Reads a FloatVector2 from the stream.
virtual void WriteFloatVector2 (FloatVector2 const &value)=0
 Writes the given FloatVector2 to the stream.
FloatSimpleTransform2 ReadFloatSimpleTransform2 ()
 Reads a FloatSimpleTransform2 from the stream.
virtual void ReadFloatSimpleTransform2 (FloatSimpleTransform2 *destination)=0
 Reads a FloatSimpleTransform2 from the stream.
virtual void WriteFloatSimpleTransform2 (FloatSimpleTransform2 const &value)=0
 Writes the given FloatSimpleTransform2 to the stream.
FloatMatrix2 ReadFloatMatrix2 ()
 Reads a FloatMatrix2 from the stream.
virtual void ReadFloatMatrix2 (FloatMatrix2 *destination)=0
 Reads a FloatMatrix2 from the stream.
virtual void WriteFloatMatrix2 (FloatMatrix2 const &value)=0
 Writes the given FloatMatrix2 to the stream.
FloatTransform2 ReadFloatTransform2 ()
 Reads a FloatTransform2 from the stream.
virtual void ReadFloatTransform2 (FloatTransform2 *destination)=0
 Reads a FloatTransform2 from the stream.
virtual void WriteFloatTransform2 (FloatTransform2 const &value)=0
 Writes the given FloatTransform2 to the stream.

Protected Types

enum  { MAX_SUPPORTED_STRING_BUFFER_SIZE = 65536 }

Protected Member Functions

void SetIsOpen (bool is_open)
 Used by subclasses of Serializer to set the is-open state.
void SetIODirection (IODirection io_direction)
 Used by subclasses of Serializer to set the I/O direction.
void SetError (IOError error) const
 Used by subclasses of Serializer to set the error value.
virtual void FlushWriteCache ()=0
 Causes any uncommitted writes to be committed (e.g. writing a memory buffer to disk, or writing a bit-packing buffer to a byte-aligned buffer).

Protected Attributes

bool m_is_open
 The current open state.
IODirection m_io_direction
 The current IO direction.
IOError m_error
 The most recent error state, which must be set by each procedure call.


Detailed Description

Provides the abstract interface for serialized data streams.

The interface is general enough so that more or less any form of I/O can be accomplished (e.g. files, network streams, compression streams, memory buffers, etc).

Definition at line 39 of file xrb_serializer.hpp.


Member Function Documentation

bool Xrb::Serializer::IsOpen (  )  const [inline]

Get the open state of the serializer.

Returns:
True iff the stream is open for input/output.
Note:
Will not change the error value.

Definition at line 68 of file xrb_serializer.hpp.

References m_is_open.

IODirection Xrb::Serializer::GetIODirection (  )  const [inline]

Get the I/O direction of the serializer.

Returns:
IOD_READ if reading, IOD_WRITE if writing, or IOD_NONE if neither is applicable (e.g. if the stream is not currently open).
Note:
Will not change the error value.

Definition at line 78 of file xrb_serializer.hpp.

References m_io_direction.

virtual bool Xrb::Serializer::IsAtEnd (  )  const [pure virtual]

Get the end-of-stream condition.

Returns:
True iff the stream is at the end (e.g. end of file)
Note:
Will not change the error value.

virtual bool Xrb::Serializer::HasFewerThan8BitsLeft (  )  const [pure virtual]

Get the less-than-one-byte-left-in-in-the-stream condition.

This is necessary because IsAtEnd() doesn't work when a set of data doesn't end exactly on a byte boundary.

Returns:
True iff the stream has fewer than 8 bits left.
Note:
Will not change the error value.

IOError Xrb::Serializer::Error (  )  const [inline]

Get the error state of the most recently called procedure.

Returns:
The most recent error state value.
Note:
Will not change the error value.

Definition at line 98 of file xrb_serializer.hpp.

References m_error.

Referenced by ErrorString(), ReadBitArray(), ReadStdString(), ReadString(), and WriteBitArray().

char const* Xrb::Serializer::ErrorString (  )  const [inline]

Get the string which describes the current error state.

Returns:
The null-terminated string describing the current error state.
Note:
Will not change the error value.

Definition at line 106 of file xrb_serializer.hpp.

References Error(), and Xrb::Util::IOErrorString().

virtual Sint32 Xrb::Serializer::ReadSignedBits ( Uint32  bit_count  )  [pure virtual]

Read a specific number of signed bits from the stream.

The highest bit read in is used to fill the extra high bits in the return value so the sign is correct.

Parameters:
bit_count The number of bits (up to 32) to read.
Returns:
The bits read in from the stream, positioned in the least significant bit_count bits of the return value.
Note:
You must be careful to use enough bits when reading/writing bits from/to a signed integer value; the extra "sign bit" must be considered when deciding how many bits to use.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteSignedBits ( Sint32  value,
Uint32  bit_count 
) [pure virtual]

Write the least significant bit_count bits (up to 32) of the signed integer, value, to the stream.

Parameters:
value The value from which the lowest bit_count bits will used to write to the stream.
Note:
You must be careful to use enough bits when reading/writing bits from/to a signed integer value; the extra "sign bit" must be considered when deciding how many bits to use.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Uint32 Xrb::Serializer::ReadUnsignedBits ( Uint32  bit_count  )  [pure virtual]

Read a specific number of unsigned bits from the stream.

Parameters:
bit_count The number of bits (up to 32) to read.
Returns:
The bits read in from the stream, positioned in the least significant bit_count bits of the return value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by ReadBitArray().

virtual void Xrb::Serializer::WriteUnsignedBits ( Uint32  value,
Uint32  bit_count 
) [pure virtual]

Write the least significant bit_count bits (up to 32) of the unsigned integer, value, to the stream.

Parameters:
value The value from which the lowest bit_count bits will used to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by WriteBitArray().

virtual bool Xrb::Serializer::ReadBool (  )  [pure virtual]

Read a boolean value from the stream.

Returns:
The boolean value true or false.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteBool ( bool  value  )  [pure virtual]

Write a boolean value to the stream.

Parameters:
value The boolean value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

template<Uint32 bit_count>
BitArray< bit_count > Xrb::Serializer::ReadBitArray (  )  [inline]

Reads a BitArray<bit_count> object from the stream.

The bit_count of the BitArray template instance must not be above

 MAX_SUPPORTED_STRING_BUFFER_SIZE * 8 
.
Returns:
A BitArray<bit_count> object with the read-in bits in the least-significant position.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 718 of file xrb_serializer.hpp.

References Error(), and ReadUnsignedBits().

template<Uint32 bit_count>
void Xrb::Serializer::WriteBitArray ( BitArray< bit_count > const &  value  )  [inline]

Writes a BitArray<bit_count> object to the stream.

The bit_count of the BitArray template instance must not be above

 MAX_SUPPORTED_STRING_BUFFER_SIZE * 8 
.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 746 of file xrb_serializer.hpp.

References Error(), and WriteUnsignedBits().

template<Uint32 bit_count>
BitArray< bit_count > Xrb::Serializer::ReadBitArray ( Uint32  bits_to_read  )  [inline]

Reads bits_to_read bits from the stream into a BitArray<bit_count> object.

The bit_count of the BitArray template instance must not be above

 MAX_SUPPORTED_STRING_BUFFER_SIZE * 8 
.
Parameters:
bits_to_read The number of least-significant bits to read into the BitArray object. This value must be greater than 0 and less than or equal to bit_count.
Returns:
A BitArray<bit_count> object with the read-in bits in the least-significant position.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 770 of file xrb_serializer.hpp.

References Error(), and ReadUnsignedBits().

template<Uint32 bit_count>
void Xrb::Serializer::WriteBitArray ( BitArray< bit_count > const &  value,
Uint32  bits_to_write 
) [inline]

Writes bits_to_read bits to the stream from the given BitArray<bit_count> object.

The bit_count of the BitArray template instance must not be above

 MAX_SUPPORTED_STRING_BUFFER_SIZE * 8 
.
Parameters:
value The BitArray to write bits from.
bits_to_write The number of least-significant bits to write from the BitArray object. This value must be greater than 0 and less than or equal to bit_count.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 809 of file xrb_serializer.hpp.

References Error(), and WriteUnsignedBits().

virtual Sint8 Xrb::Serializer::ReadSint8 (  )  [pure virtual]

Read a signed, 8-bit integer value from the stream.

Returns:
A signed, 8-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteSint8 ( Sint8  value  )  [pure virtual]

Write a signed, 8-bit integer value to the stream.

Parameters:
value The signed, 8-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Uint8 Xrb::Serializer::ReadUint8 (  )  [pure virtual]

Read an unsigned, 8-bit integer value from the stream.

Returns:
An unsigned, 8-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteUint8 ( Uint8  value  )  [pure virtual]

Write an unsigned, 8-bit integer value to the stream.

Parameters:
value The unsigned, 8-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Sint16 Xrb::Serializer::ReadSint16 (  )  [pure virtual]

Read a signed, 16-bit integer value from the stream.

Returns:
A signed, 16-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteSint16 ( Sint16  value  )  [pure virtual]

Write a signed, 16-bit integer value to the stream.

Parameters:
value The signed, 16-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Uint16 Xrb::Serializer::ReadUint16 (  )  [pure virtual]

Read an unsigned, 16-bit integer value from the stream.

Returns:
An unsigned, 16-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteUint16 ( Uint16  value  )  [pure virtual]

Write an unsigned, 16-bit integer value to the stream.

Parameters:
value The unsigned, 16-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Sint32 Xrb::Serializer::ReadSint32 (  )  [pure virtual]

Read a signed, 32-bit integer value from the stream.

Returns:
A signed, 32-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by ReadScreenCoord().

virtual void Xrb::Serializer::WriteSint32 ( Sint32  value  )  [pure virtual]

Write a signed, 32-bit integer value to the stream.

Parameters:
value The signed, 32-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by WriteScreenCoord().

virtual Uint32 Xrb::Serializer::ReadUint32 (  )  [pure virtual]

Read an unsigned, 32-bit integer value from the stream.

Returns:
An unsigned, 32-bit integer value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteUint32 ( Uint32  value  )  [pure virtual]

Write an unsigned, 32-bit integer value to the stream.

Parameters:
value The unsigned, 32-bit integer value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

ScreenCoord Xrb::Serializer::ReadScreenCoord (  )  [inline]

Read a ScreenCoord value from the stream.

Returns:
A ScreenCoord value.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 326 of file xrb_serializer.hpp.

References ReadSint32().

void Xrb::Serializer::WriteScreenCoord ( ScreenCoord  value  )  [inline]

Write a ScreenCoord value to the stream.

Parameters:
value The ScreenCoord value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 334 of file xrb_serializer.hpp.

References WriteSint32().

virtual void Xrb::Serializer::ReadFloat ( float *  destination  )  [pure virtual]

Read an IEEE single-precision floating point value from the stream.

Parameters:
destination A pointer to the IEEE single-precision floating point value to be set to the value read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloat ( float  value  )  [pure virtual]

Write an IEEE single-precision floating point value to the stream.

Parameters:
value The IEEE single-precision floating point value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::ReadFloat ( double *  destination  )  [pure virtual]

Read an IEEE double-precision floating point value from the stream.

Parameters:
destination A pointer to the IEEE double-precision floating point value to be set to the value read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloat ( double  value  )  [pure virtual]

Write an IEEE double-precision floating point value to the stream.

Parameters:
value The IEEE double-precision floating point value to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual Uint32 Xrb::Serializer::ReadBufferString ( char *  destination,
Uint32  destination_size 
) [pure virtual]

Read a string from the stream into the provided array.

The array destination must be already-allocated, and at least destination_size elements long. The number of elements to read is at most

 destination_size - 1 
, though the actual number of elements read may be lower, depending on the content of the stream. If destination is longer than destination_size elements, then the extra elements will not be changed. A null-terminating character will be placed at the end of the read-in string, but will be no later in the string than the element
 destination_size - 1 
.
Parameters:
destination An already-allocated character array which will store the string which is to be read in. It must be at least destination_size elements long.
destination_size The number of characters to read into destination, including the null-terminating character. Indicates the minimum guaranteed array size of destination.
Returns:
The actual length of the read-in string, not including the null-terminating character.
Note:
Must guarantee that strings up to 65536 characters long, including the null-terminating character, are supported.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by ReadStdString(), and ReadString().

virtual Uint32 Xrb::Serializer::WriteBufferString ( char const *  source,
Uint32  source_size 
) [pure virtual]

Write the given string to the stream, but write no more than source_size characters (including the null-terminating character).

The character array source must be at least source_size elements long. If it is longer, then the extra elements will be ignored. The string up to either the first null-terminating character or the maximum length will be written to the stream. If the maximum length is written, without encountering a null-terminating character, a null-terminating character will be written to the stream in place of the last character.

Parameters:
source The character string to write to the stream. Must be at least source_size elements long.
source_size The maximum possible number of characters to write to the stream, including the null-terminating character. Indicates the minimum guaranteed array size of source.
Returns:
The actual length of the written string, not including the null-terminating character.
Note:
Must not write a string that is longer than 65536 characters, including the null-terminating character. If a line is longer than 65536 characters, including the null-terminating character, only 65536 characters will be written, including the null-terminating character.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Referenced by WriteStdString(), and WriteString().

Uint32 Xrb::Serializer::ReadString ( char **  destination  )  [virtual]

Reads a character string from the stream.

The null-terminated string assigned to *destination is allocated inside the function and must be manually deleted.

Parameters:
destination A pointer to a char * which will be assigned with the address of a newly allocated, null-terminated string containing the read-in contents. The allocated string must be manually deleted. If an error occurred, null will be assigned to *destination, and no allocation will be made. This parameter must not be null.
Returns:
The length of the read-in string.
Note:
This is more or less an alias for the pure-virtual ReadString().
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 32 of file xrb_serializer.cpp.

References Error(), and ReadBufferString().

Uint32 Xrb::Serializer::WriteString ( char const *  source  )  [virtual]

Writes the given null-terminated string to the stream.

Parameters:
source The null-terminated string to write to the stream.
Note:
This is more or less an alias for the pure-virtual WriteString().
Returns:
The length of the written string.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 47 of file xrb_serializer.cpp.

References Xrb::Min(), and WriteBufferString().

std::string Xrb::Serializer::ReadStdString ( Uint32 *  string_length = NULL  )  [inline]

Reads a std::string character string from the stream.

Parameters:
string_length An optional pointer to a Uint32 which, if not null, will be assigned the actual length of the read-in string, not including the null-terminating character.
Returns:
A std::string character string read in from the stream.
Note:
This is more or less an alias for the pure-virtual ReadString().
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 470 of file xrb_serializer.hpp.

void Xrb::Serializer::ReadStdString ( std::string *  destination,
Uint32 *  string_length = NULL 
)

Reads a std::string character string from the stream.

Parameters:
destination A pointer to a std::string object to read into.
string_length An optional pointer to a Uint32 which, if not null, will be assigned the actual length of the read-in string, not including the null-terminating character.
Returns:
A std::string character string read in from the stream.
Note:
This is more or less an alias for the pure-virtual ReadString().
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 59 of file xrb_serializer.cpp.

References Error(), and ReadBufferString().

void Xrb::Serializer::WriteStdString ( std::string const &  source,
Uint32 *  string_length = NULL 
)

Writes the given std::string character string to the stream.

Parameters:
source The std::string character string to write to the stream.
string_length An optional pointer to a Uint32 which, if not null, will be assigned the actual length of the read-in string, not including the null-terminating character.
Note:
This is more or less an alias for the pure-virtual WriteString().
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 73 of file xrb_serializer.cpp.

References WriteBufferString().

Color Xrb::Serializer::ReadColor (  )  [inline]

Reads a Color from the stream.

Returns:
A Color read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 508 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadColor ( Color *  destination  )  [pure virtual]

Reads a Color from the stream.

Parameters:
destination A pointer to the Color object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteColor ( Color const &  value  )  [pure virtual]

Writes the given std::string character string to the stream.

Parameters:
source The std::string character string to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

ScreenCoordVector2 Xrb::Serializer::ReadScreenCoordVector2 (  )  [inline]

Reads a ScreenCoordVector2 from the stream.

Returns:
A ScreenCoordVector2 read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 535 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadScreenCoordVector2 ( ScreenCoordVector2 destination  )  [pure virtual]

Reads a ScreenCoordVector2 from the stream.

Parameters:
destination A pointer to the ScreenCoordVector2 object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteScreenCoordVector2 ( ScreenCoordVector2 const &  value  )  [pure virtual]

Writes the given ScreenCoordVector2 to the stream.

Parameters:
source The ScreenCoordVector2 to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

FloatVector2 Xrb::Serializer::ReadFloatVector2 (  )  [inline]

Reads a FloatVector2 from the stream.

Returns:
A FloatVector2 read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 562 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadFloatVector2 ( FloatVector2 destination  )  [pure virtual]

Reads a FloatVector2 from the stream.

Parameters:
destination A pointer to the FloatVector2 object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloatVector2 ( FloatVector2 const &  value  )  [pure virtual]

Writes the given FloatVector2 to the stream.

Parameters:
source The FloatVector2 to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

FloatSimpleTransform2 Xrb::Serializer::ReadFloatSimpleTransform2 (  )  [inline]

Reads a FloatSimpleTransform2 from the stream.

Returns:
A FloatSimpleTransform2 read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 589 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadFloatSimpleTransform2 ( FloatSimpleTransform2 destination  )  [pure virtual]

Reads a FloatSimpleTransform2 from the stream.

Parameters:
destination A pointer to the FloatSimpleTransform2 object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloatSimpleTransform2 ( FloatSimpleTransform2 const &  value  )  [pure virtual]

Writes the given FloatSimpleTransform2 to the stream.

Parameters:
source The FloatSimpleTransform2 to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

FloatMatrix2 Xrb::Serializer::ReadFloatMatrix2 (  )  [inline]

Reads a FloatMatrix2 from the stream.

Returns:
A FloatMatrix2 read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 617 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadFloatMatrix2 ( FloatMatrix2 destination  )  [pure virtual]

Reads a FloatMatrix2 from the stream.

Parameters:
destination A pointer to the FloatMatrix2 object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloatMatrix2 ( FloatMatrix2 const &  value  )  [pure virtual]

Writes the given FloatMatrix2 to the stream.

Parameters:
source The FloatMatrix2 to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

FloatTransform2 Xrb::Serializer::ReadFloatTransform2 (  )  [inline]

Reads a FloatTransform2 from the stream.

Returns:
A FloatTransform2 read in from the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

Definition at line 644 of file xrb_serializer.hpp.

virtual void Xrb::Serializer::ReadFloatTransform2 ( FloatTransform2 destination  )  [pure virtual]

Reads a FloatTransform2 from the stream.

Parameters:
destination A pointer to the FloatTransform2 object to read into.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_READ, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

virtual void Xrb::Serializer::WriteFloatTransform2 ( FloatTransform2 const &  value  )  [pure virtual]

Writes the given FloatTransform2 to the stream.

Parameters:
source The FloatTransform2 to write to the stream.
Precondition:
IsOpen() must return true, GetIODirection() must return IOD_WRITE, and IsAtEnd() must return false.
Postcondition:
The error state is set to indicate the status of the operation.

void Xrb::Serializer::SetIsOpen ( bool  is_open  )  [inline, protected]

Used by subclasses of Serializer to set the is-open state.

Parameters:
is_open The value to set the is-open state to.
Postcondition:
Will not change the error value.

Definition at line 676 of file xrb_serializer.hpp.

References m_is_open.

void Xrb::Serializer::SetIODirection ( IODirection  io_direction  )  [inline, protected]

Used by subclasses of Serializer to set the I/O direction.

Parameters:
io_direction The value to set the I/O direction to.
Postcondition:
Will not change the error value.

Definition at line 684 of file xrb_serializer.hpp.

References m_io_direction.

void Xrb::Serializer::SetError ( IOError  error  )  const [inline, protected]

Used by subclasses of Serializer to set the error value.

Parameters:
error The value to set the error to.

Definition at line 691 of file xrb_serializer.hpp.

References m_error.

virtual void Xrb::Serializer::FlushWriteCache (  )  [protected, pure virtual]

Causes any uncommitted writes to be committed (e.g. writing a memory buffer to disk, or writing a bit-packing buffer to a byte-aligned buffer).

Precondition:
IsOpen() must return true, and GetIODirection() must return IOD_WRITE.
Postcondition:
The error state is set to indicate the status of the operation.


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

Hosted by SourceForge.net Logo -- Generated on Fri Aug 21 21:46:39 2009 for XuqRijBuh by doxygen 1.5.8