Pixel Dust Game Engine  v0.9.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
IDeserializer Class Referenceabstract
Inheritance diagram for IDeserializer:
Inheritance graph
[legend]
Collaboration diagram for IDeserializer:
Collaboration graph
[legend]

Public Types

typedef ISerializable *(* CreateSerializableFunc )()
 

Public Member Functions

virtual uint64 deserialize_8u () MAY_THROW(out_of_data)=0
 Deserialize an 8 byte (64 bit) value.
 
int64 deserialize_8 () MAY_THROW(out_of_data)
 
virtual uint32 deserialize_4u () MAY_THROW(out_of_data)=0
 Deserialize a 4 byte (32 bit) value.
 
int32 deserialize_4 () MAY_THROW(out_of_data)
 
virtual uint32 deserialize_3u () MAY_THROW(out_of_data)=0
 Deserialize a 3 byte (24 bit) value.
 
virtual uint16 deserialize_2u () MAY_THROW(out_of_data)=0
 Deserialize a 2 byte (16 bit) value.
 
int16 deserialize_2 () MAY_THROW(out_of_data)
 
virtual uint8 deserialize_1u () MAY_THROW(out_of_data)=0
 Deserialize an 1 byte (8 bit) value.
 
int8 deserialize_1 () MAY_THROW(out_of_data)
 
float deserialize_f () MAY_THROW(out_of_data)
 Serialize a floating point value into a buffer.
 
double deserialize_d () MAY_THROW(out_of_data)
 Serialize a double precision floating point value into a buffer.
 
virtual bool deserialize_bool () MAY_THROW(out_of_data)=0
 Deserialize a boolean (1 bit) value.
 
virtual uint32 deserialize_uint () MAY_THROW(out_of_data)=0
 Deserialize an unsigned value.
 
virtual Color deserialize_color () MAY_THROW(out_of_data)=0
 Deserialize a pdg::Color value.
 
virtual Offset deserialize_offset () MAY_THROW(out_of_data)=0
 Deserialize a pdg::Offset value.
 
Point deserialize_point () MAY_THROW(out_of_data)
 Deserialize a pdg::Point value.
 
Vector deserialize_vector () MAY_THROW(out_of_data)
 Deserialize a pdg::Vector value.
 
virtual Rect deserialize_rect () MAY_THROW(out_of_data)=0
 Deserialize a pdg::Rect.
 
virtual RotatedRect deserialize_rotr () MAY_THROW(out_of_data)=0
 Deserialize a pdg::RotatedRect.
 
virtual Quad deserialize_quad () MAY_THROW(out_of_data)=0
 Deserialize a pdg::Quad.
 
virtual uint32 deserialize_str (char *outStr, uint32 strMaxLen) MAY_THROW((out_of_data
 Deserialize a string value.
 
virtual uint32 deserialize_strGetLen () MAY_THROW((out_of_data
 get length of a string value, including NUL terminator, as if it were deserialized
 
void deserialize_string (std::string &outStr) MAY_THROW((out_of_data
 Deserialize a string value into a std::string.
 
virtual uint32 deserialize_mem (void *outMem, uint32 memMaxLen) MAY_THROW((out_of_data
 Deserialize an arbitrary block of memory.
 
virtual uint32 deserialize_memGetLen () MAY_THROW((out_of_data
 Deserialize an string value.
 
virtual ISerializabledeserialize_obj () MAY_THROW((out_of_data
 Deserialize a serializable object.
 
template<typename T >
T * deserialize_ref () MAY_THROW((out_of_data
 Deserialize a reference to a non-serializable object.
 

Static Public Member Functions

template<class T >
static void registerClass ()
 Register a class that is derived from Serializable.
 
static void registerClass (uint32 classTag, CreateSerializableFunc classNewFunc)
 Register a class that is derived from ISerializable.
 
static void registerObject (void *obj, uint32 uniqueId)
 Register object that is not serializable for use with |de|serialize_ref()
 

Public Attributes

virtual uint32 bad_tag = 0
 
void bad_tag
 
virtual ISerializable bad_tag
 
virtual ISerializable sync_error
 
virtual ISerializable unknown_object = 0
 
bad_tag
 
sync_error
 
unknown_object
 

Static Public Attributes

static int s_TraceDepth
 

Protected Member Functions

virtual char * statusDump (int hiliteBytes=0)=0
 
virtual void * deserialize_ptr () MAY_THROW((out_of_data
 

Protected Attributes

virtual void bad_tag
 
virtual void sync_error
 
virtual void unknown_object = 0
 

Member Typedef Documentation

typedef ISerializable*(* CreateSerializableFunc)()

Member Function Documentation

int8 deserialize_1 ( )
inline
virtual uint8 deserialize_1u ( )
pure virtual

Deserialize an 1 byte (8 bit) value.

internal pointer is advanced 1 btye

Returns
the deserialized 8 bit value

Implemented in Deserializer.

int16 deserialize_2 ( )
inline
virtual uint16 deserialize_2u ( )
pure virtual

Deserialize a 2 byte (16 bit) value.

internal pointer is advanced 2 btyes

Returns
the deserialized 16 bit value

Implemented in Deserializer.

virtual uint32 deserialize_3u ( )
pure virtual

Deserialize a 3 byte (24 bit) value.

internal pointer is advanced 3 btyes

Returns
the deserialized 24 bit value

Implemented in Deserializer.

int32 deserialize_4 ( )
inline
virtual uint32 deserialize_4u ( )
pure virtual

Deserialize a 4 byte (32 bit) value.

internal pointer is advanced 4 btyes

Returns
the deserialized 32 bit value

Implemented in Deserializer.

int64 deserialize_8 ( )
inline
virtual uint64 deserialize_8u ( )
pure virtual

Deserialize an 8 byte (64 bit) value.

internal pointer is advanced 8 btyes

Returns
the deserialized 64 bit value

Implemented in Deserializer.

virtual bool deserialize_bool ( )
pure virtual

Deserialize a boolean (1 bit) value.

internal pointer gets advanced by 1 or 0 bytes, depending on bytes required to store the value

Returns
the boolean that was deserialized This is optimized for series of boolean values, so that between 1 and 8 bools serialized sequentially only use a single byte

Implemented in Deserializer.

virtual Color deserialize_color ( )
pure virtual

Deserialize a pdg::Color value.

internal pointer is advanced by ? bytes, depending on bytes required to store value

Returns
the Color that was deserialized

Implemented in Deserializer.

double deserialize_d ( )
inline

Serialize a double precision floating point value into a buffer.

internal pointer gets advanced by 8 bytes

Returns
the floating point value that was deserialized
float deserialize_f ( )
inline

Serialize a floating point value into a buffer.

internal pointer gets advanced by 4 bytes

Returns
the floating point value that was deserialized
virtual uint32 deserialize_mem ( void *  outMem,
uint32  memMaxLen 
)
virtual

Deserialize an arbitrary block of memory.

Parameters
pa reference to a buffer pointer; pointer gets advanced past mem block to start of next entity in buffer
outMem,abuffer to hold the resulting block of memory
memMaxLen,themax length of the output block, that the buffer can accomodate If the serialized memory is longer than memMaxLen, it will be truncated and the buffer pointer p will still be advanced past the memory block to the start of the next entity in the buffer.
Returns
the length of the string in bytes

Reimplemented in Deserializer.

virtual uint32 deserialize_memGetLen ( )
virtual

Deserialize an string value.

internal pointer is NOT advanced. Use this to pre-flight allocation for blocks of memory

Returns
the length of the serialized block of memory in bytes

Reimplemented in Deserializer.

virtual ISerializable* deserialize_obj ( )
virtual

Deserialize a serializable object.

internal pointer gets advanced past object to start of next entity in buffer

Returns
NULL, or a newly created Serializable object NULL return happens if serialized object reference was null, or if the object could not be deserialized If object could not be deserialized, either because the subclass was unknown or because the data was corrupt, the internal pointer will still be advanced past the object to the start of the next entity in the buffer.

Reimplemented in Deserializer.

virtual Offset deserialize_offset ( )
pure virtual

Deserialize a pdg::Offset value.

internal pointer is advanced by 1 to 9 bytes, depending on bytes required to store value

Returns
the Offset that was deserialized

Implemented in Deserializer.

Point deserialize_point ( )
inline

Deserialize a pdg::Point value.

internal pointer is advanced by 1 to 9 bytes, depending on bytes required to store value

Returns
the Point that was deserialized
virtual void* deserialize_ptr ( )
protectedvirtual

Reimplemented in Deserializer.

virtual Quad deserialize_quad ( )
pure virtual

Deserialize a pdg::Quad.

internal pointer is advanced by 1, 3 or 5 bytes, depending on bytes required to store value

Returns
the Quad that was deserialized

Implemented in Deserializer.

virtual Rect deserialize_rect ( )
pure virtual

Deserialize a pdg::Rect.

internal pointer is advanced by ? bytes, depending on bytes required to store value

Returns
the Rect that was deserialized

Implemented in Deserializer.

T * deserialize_ref ( )
inline

Deserialize a reference to a non-serializable object.

virtual RotatedRect deserialize_rotr ( )
pure virtual

Deserialize a pdg::RotatedRect.

internal pointer is advanced by ? bytes, depending on bytes required to store value

Returns
the RotatedRect that was deserialized

Implemented in Deserializer.

virtual uint32 deserialize_str ( char *  outStr,
uint32  strMaxLen 
)
virtual

Deserialize a string value.

Parameters
outStr,abuffer to hold the resulting string
strMaxLen,themax length of the output string, including NUL terminator, that the buffer can accomodate If the serialized string is longer than strMaxLen, it will be truncated and the internal pointer p will still be advanced past the string to the start of the next entity in the internal buffer.
Returns
the length of the string in bytes (not including NUL terminator)

Reimplemented in Deserializer.

virtual uint32 deserialize_strGetLen ( )
virtual

get length of a string value, including NUL terminator, as if it were deserialized

internal pointer is NOT advanced. Use this to pre-flight allocation for longer strings

Returns
the length of the serialized string plus nul terminator in bytes

Reimplemented in Deserializer.

void deserialize_string ( std::string &  outStr)
inline

Deserialize a string value into a std::string.

Parameters
outStr,astd::string to hold the resulting string
Returns
none
virtual uint32 deserialize_uint ( )
pure virtual

Deserialize an unsigned value.

internal pointer is advanced by 1, 3 or 5 bytes, depending on bytes required to store value

Returns
the unsigned value that was deserialized

Implemented in Deserializer.

Vector deserialize_vector ( )
inline

Deserialize a pdg::Vector value.

internal pointer is advanced by 1 to 9 bytes, depending on bytes required to store value

Returns
the Vector that was deserialized
void registerClass ( )
inlinestatic

Register a class that is derived from Serializable.

this is the prefered way of registering classes for serialization

static void registerClass ( uint32  classTag,
CreateSerializableFunc  classNewFunc 
)
static

Register a class that is derived from ISerializable.

Parameters
classTaga 32 bit value uniquely identifying the class
classNewFuncthe factory function that can create new instances of the class You should derive classes from Serializable rather than ISerializable, and use the template based registerClass() to register them unless you have a really good reason not to.
static void registerObject ( void *  obj,
uint32  uniqueId 
)
static

Register object that is not serializable for use with |de|serialize_ref()

Parameters
uniqueIda 32 bit value that uniquely identifies this object Calling this twice with the same uniqueId will replace the old value. These values are then sent instead of the object data or pointer. On deserialization, the object registered to that id on the receiver is used.
virtual char* statusDump ( int  hiliteBytes = 0)
protectedpure virtual

Implemented in Deserializer.

Member Data Documentation

uint32 bad_tag = 0
void bad_tag
virtual void bad_tag
protected
int s_TraceDepth
static
virtual void sync_error
protected
virtual void unknown_object = 0
protected