Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | List of all members
ISerializer Class Referenceabstract

Serialization interface; see serialization overview. More...

#include <ISerializer.h>

Inheritance diagram for ISerializer:
CBinarySerializer< T > CBinarySerializer< CBufferBinarySerializerImpl > CBinarySerializer< CHashSerializerImpl > CBinarySerializer< CLengthBinarySerializerImpl > CBinarySerializer< CStdSerializerImpl > CDebugSerializer CBufferBinarySerializer CHashSerializer CLengthBinarySerializer CStdSerializer

Public Member Functions

virtual ~ISerializer ()
 
void NumberU8 (const char *name, uint8_t value, uint8_t lower, uint8_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI8 (const char *name, int8_t value, int8_t lower, int8_t upper)
 
void NumberU16 (const char *name, uint16_t value, uint16_t lower, uint16_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI16 (const char *name, int16_t value, int16_t lower, int16_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberU32 (const char *name, uint32_t value, uint32_t lower, uint32_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberI32 (const char *name, int32_t value, int32_t lower, int32_t upper)
 Serialize a number, which must be lower <= value <= upper. More...
 
void NumberU8_Unbounded (const char *name, uint8_t value)
 Serialize a number. More...
 
void NumberI8_Unbounded (const char *name, int8_t value)
 Serialize a number. More...
 
void NumberU16_Unbounded (const char *name, uint16_t value)
 Serialize a number. More...
 
void NumberI16_Unbounded (const char *name, int16_t value)
 Serialize a number. More...
 
void NumberU32_Unbounded (const char *name, uint32_t value)
 Serialize a number. More...
 
void NumberI32_Unbounded (const char *name, int32_t value)
 Serialize a number. More...
 
void NumberFloat_Unbounded (const char *name, float value)
 Serialize a number. More...
 
void NumberDouble_Unbounded (const char *name, double value)
 Serialize a number. More...
 
void NumberFixed_Unbounded (const char *name, fixed value)
 Serialize a number. More...
 
void Bool (const char *name, bool value)
 Serialize a boolean. More...
 
void StringASCII (const char *name, const std::string &value, uint32_t minlength, uint32_t maxlength)
 Serialize an ASCII string. More...
 
void String (const char *name, const std::wstring &value, uint32_t minlength, uint32_t maxlength)
 Serialize a Unicode string. More...
 
void ScriptVal (const char *name, jsval value)
 Serialize a jsval. More...
 
void ScriptVal (const char *name, CScriptVal value)
 Serialize a CScriptVal. More...
 
void ScriptVal (const char *name, CScriptValRooted value)
 Serialize a CScriptValRooted. More...
 
void RawBytes (const char *name, const u8 *data, size_t len)
 Serialize a stream of bytes. More...
 
virtual bool IsDebug () const
 Returns true if the serializer is being used in debug mode. More...
 
virtual std::ostream & GetStream ()=0
 Returns a stream which can be used to serialize data directly. More...
 

Protected Member Functions

virtual void PutNumber (const char *name, uint8_t value)=0
 
virtual void PutNumber (const char *name, int8_t value)=0
 
virtual void PutNumber (const char *name, uint16_t value)=0
 
virtual void PutNumber (const char *name, int16_t value)=0
 
virtual void PutNumber (const char *name, uint32_t value)=0
 
virtual void PutNumber (const char *name, int32_t value)=0
 
virtual void PutNumber (const char *name, float value)=0
 
virtual void PutNumber (const char *name, double value)=0
 
virtual void PutNumber (const char *name, fixed value)=0
 
virtual void PutBool (const char *name, bool value)=0
 
virtual void PutString (const char *name, const std::string &value)=0
 
virtual void PutScriptVal (const char *name, jsval value)=0
 
virtual void PutRaw (const char *name, const u8 *data, size_t len)=0
 

Detailed Description

Serialization interface; see serialization overview.

Definition at line 120 of file ISerializer.h.

Constructor & Destructor Documentation

ISerializer::~ISerializer ( )
virtual

Definition at line 24 of file ISerializer.cpp.

Member Function Documentation

void ISerializer::Bool ( const char *  name,
bool  value 
)
inline

Serialize a boolean.

Definition at line 199 of file ISerializer.h.

virtual std::ostream& ISerializer::GetStream ( )
pure virtual

Returns a stream which can be used to serialize data directly.

(This is particularly useful for chaining multiple serializers together.)

Implemented in CBinarySerializer< T >, CBinarySerializer< CStdSerializerImpl >, CBinarySerializer< CHashSerializerImpl >, CBinarySerializer< CLengthBinarySerializerImpl >, CBinarySerializer< CBufferBinarySerializerImpl >, CStdSerializer, and CDebugSerializer.

bool ISerializer::IsDebug ( ) const
virtual

Returns true if the serializer is being used in debug mode.

Components should serialize non-critical data (e.g. data that is unchanged from the template) only if this is true. (It must still only be used for synchronised, deterministic data.)

Reimplemented in CDebugSerializer.

Definition at line 115 of file ISerializer.cpp.

void ISerializer::NumberDouble_Unbounded ( const char *  name,
double  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 186 of file ISerializer.h.

void ISerializer::NumberFixed_Unbounded ( const char *  name,
fixed  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 191 of file ISerializer.h.

void ISerializer::NumberFloat_Unbounded ( const char *  name,
float  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 181 of file ISerializer.h.

void ISerializer::NumberI16 ( const char *  name,
int16_t  value,
int16_t  lower,
int16_t  upper 
)

Serialize a number, which must be lower <= value <= upper.

The same bounds must be used when deserializing the number. This should be used in preference to the Unbounded functions, to detect erroneous or malicious values that might cause problems when used.

Exceptions
PSERROR_Serialize_OutOfBoundsif value is out of bounds
PSERROR_Serializefor any other errors
Parameters
nameinformative name for debug output
valuevalue to serialize
lowerinclusive lower bound
upperinclusive upper bound

Definition at line 49 of file ISerializer.cpp.

void ISerializer::NumberI16_Unbounded ( const char *  name,
int16_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 166 of file ISerializer.h.

void ISerializer::NumberI32 ( const char *  name,
int32_t  value,
int32_t  lower,
int32_t  upper 
)

Serialize a number, which must be lower <= value <= upper.

The same bounds must be used when deserializing the number. This should be used in preference to the Unbounded functions, to detect erroneous or malicious values that might cause problems when used.

Exceptions
PSERROR_Serialize_OutOfBoundsif value is out of bounds
PSERROR_Serializefor any other errors
Parameters
nameinformative name for debug output
valuevalue to serialize
lowerinclusive lower bound
upperinclusive upper bound

Definition at line 63 of file ISerializer.cpp.

void ISerializer::NumberI32_Unbounded ( const char *  name,
int32_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 176 of file ISerializer.h.

void ISerializer::NumberI8 ( const char *  name,
int8_t  value,
int8_t  lower,
int8_t  upper 
)

Definition at line 35 of file ISerializer.cpp.

void ISerializer::NumberI8_Unbounded ( const char *  name,
int8_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 156 of file ISerializer.h.

void ISerializer::NumberU16 ( const char *  name,
uint16_t  value,
uint16_t  lower,
uint16_t  upper 
)

Serialize a number, which must be lower <= value <= upper.

The same bounds must be used when deserializing the number. This should be used in preference to the Unbounded functions, to detect erroneous or malicious values that might cause problems when used.

Exceptions
PSERROR_Serialize_OutOfBoundsif value is out of bounds
PSERROR_Serializefor any other errors
Parameters
nameinformative name for debug output
valuevalue to serialize
lowerinclusive lower bound
upperinclusive upper bound

Definition at line 42 of file ISerializer.cpp.

void ISerializer::NumberU16_Unbounded ( const char *  name,
uint16_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 161 of file ISerializer.h.

void ISerializer::NumberU32 ( const char *  name,
uint32_t  value,
uint32_t  lower,
uint32_t  upper 
)

Serialize a number, which must be lower <= value <= upper.

The same bounds must be used when deserializing the number. This should be used in preference to the Unbounded functions, to detect erroneous or malicious values that might cause problems when used.

Exceptions
PSERROR_Serialize_OutOfBoundsif value is out of bounds
PSERROR_Serializefor any other errors
Parameters
nameinformative name for debug output
valuevalue to serialize
lowerinclusive lower bound
upperinclusive upper bound

Definition at line 56 of file ISerializer.cpp.

void ISerializer::NumberU32_Unbounded ( const char *  name,
uint32_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 171 of file ISerializer.h.

void ISerializer::NumberU8 ( const char *  name,
uint8_t  value,
uint8_t  lower,
uint8_t  upper 
)

Serialize a number, which must be lower <= value <= upper.

The same bounds must be used when deserializing the number. This should be used in preference to the Unbounded functions, to detect erroneous or malicious values that might cause problems when used.

Exceptions
PSERROR_Serialize_OutOfBoundsif value is out of bounds
PSERROR_Serializefor any other errors
Parameters
nameinformative name for debug output
valuevalue to serialize
lowerinclusive lower bound
upperinclusive upper bound

Definition at line 28 of file ISerializer.cpp.

void ISerializer::NumberU8_Unbounded ( const char *  name,
uint8_t  value 
)
inline

Serialize a number.

Exceptions
PSERROR_Serializefor any errors
Parameters
nameinformative name for debug output
valuevalue to serialize

Definition at line 150 of file ISerializer.h.

virtual void ISerializer::PutBool ( const char *  name,
bool  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
uint8_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
int8_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
uint16_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
int16_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
uint32_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
int32_t  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
float  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
double  value 
)
protectedpure virtual
virtual void ISerializer::PutNumber ( const char *  name,
fixed  value 
)
protectedpure virtual
virtual void ISerializer::PutRaw ( const char *  name,
const u8 data,
size_t  len 
)
protectedpure virtual
virtual void ISerializer::PutScriptVal ( const char *  name,
jsval  value 
)
protectedpure virtual
virtual void ISerializer::PutString ( const char *  name,
const std::string &  value 
)
protectedpure virtual
void ISerializer::RawBytes ( const char *  name,
const u8 data,
size_t  len 
)

Serialize a stream of bytes.

It is the caller's responsibility to deal with portability (padding, endianness, etc); the typed serialize methods should usually be used instead of this.

Definition at line 110 of file ISerializer.cpp.

void ISerializer::ScriptVal ( const char *  name,
jsval  value 
)

Serialize a jsval.

The value must not contain any unserializable values (like functions). Likely to trigger GC, so value must be rooted.

Definition at line 95 of file ISerializer.cpp.

void ISerializer::ScriptVal ( const char *  name,
CScriptVal  value 
)

Serialize a CScriptVal.

The value must not contain any unserializable values (like functions). Likely to trigger GC, so value must be rooted.

Definition at line 100 of file ISerializer.cpp.

void ISerializer::ScriptVal ( const char *  name,
CScriptValRooted  value 
)

Serialize a CScriptValRooted.

The value must not contain any unserializable values (like functions).

Definition at line 105 of file ISerializer.cpp.

void ISerializer::String ( const char *  name,
const std::wstring &  value,
uint32_t  minlength,
uint32_t  maxlength 
)

Serialize a Unicode string.

Characters must be in the range U+0000..U+D7FF, U+E000..U+FDCF, U+FDF0..U+FFFD (inclusive). The string must be between minlength .. maxlength (inclusive) characters.

Definition at line 82 of file ISerializer.cpp.

void ISerializer::StringASCII ( const char *  name,
const std::string &  value,
uint32_t  minlength,
uint32_t  maxlength 
)

Serialize an ASCII string.

Characters must be in the range U+0001 .. U+00FF (inclusive). The string must be between minlength .. maxlength (inclusive) characters.

Definition at line 70 of file ISerializer.cpp.


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