Photon C++ Client API
4.1.12.2
|
Public Member Functions | |
const nByte * | getData (void) const |
int | getSize (void) const |
template<typename T > | |
bool | push (const T &data) |
template<typename T > | |
bool | push (const T pData, typename Helpers::ArrayLengthType< T >::type arraySize) |
template<typename T > | |
bool | push (const T pData, const short *arraySizes) |
JString & | toString (JString &retStr, bool withTypes=false) const |
Public Member Functions inherited from Base | |
virtual | ~Base (void) |
Public Member Functions inherited from ToString | |
virtual | ~ToString (void) |
virtual JString | typeToString (void) const |
JString | toString (bool withTypes=false) const |
Additional Inherited Members | |
Static Public Member Functions inherited from Base | |
static void | setListener (const BaseListener *baseListener) |
static int | getDebugOutputLevel (void) |
static bool | setDebugOutputLevel (int debugLevel) |
static const LogFormatOptions & | getLogFormatOptions (void) |
static void | setLogFormatOptions (const LogFormatOptions &options) |
Detailed Description
The Serializer class serializes everything, that gets added to it, into a byte-array.
You can add data of suported types to a Serializer instance by calling push() on it, passing that data. A call to push() will automatically serialize the data before adding it to the instance. The content of a Serializer instance can be retrieved in form form of a byte array by calling getData().
If you do multiple calls to push() on the same instance, then the array retrieved by getData() will contain serialized representations of the passed data for all of them. The order in which these representations are stored will match the order of the calls.
The serialized data can be used to construct a DeSerializer instance from it, which provides the interface for retrieving the original datatypes from the byte array.
Member Function Documentation
§ getData()
const nByte * getData | ( | void | ) | const |
§ getSize()
int getSize | ( | void | ) | const |
- Returns
- the size in bytes of the payload
§ push() [1/3]
bool push | ( | const T & | data | ) |
Adds a serialized representation of parameter data to the Serializer-instance on which it is called.
- Template Parameters
-
T type of parameter data - has to be of one of the supported datatypes
- Parameters
-
data data to serialize
- Returns
- true if successful, false in case of an error
§ push() [2/3]
bool push | ( | const T | pData, |
typename Helpers::ArrayLengthType< T >::type | arraySize | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload accepts singledimensional arrays and NULL-pointers passed for parameter pData.
- Parameters
-
pData array of data to serialize arraySize the size of the value array
§ push() [3/3]
bool push | ( | const T | pData, |
const short * | arraySizes | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This overload accepts multidimensional arrays and NULL-pointers passed for parameter val. The array, passed for parameter pData has to be a pointer of the correct abstraction level, meaning a normal pointer for a singledimensional array, a doublepointer for a twodimensional array, a triplepointer for a threedimensional array and so on.
- Parameters
-
pData array of data to serialize arraySizes the sizes for every dimension of the array
§ toString()
- Remarks
- The cost of this function depends a lot on implementation details of the implementing subclasses, but for container classes this function can become quite expensive, if the instance contains huge amounts of data, as its cost for many container class implementations increases disproportionately high to the size of the payload.
- Parameters
-
retStr reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string withTypes set to true, to include type information in the generated string
- Returns
- a JString representation of the instance and its contents for debugging purposes.
Implements ToString.