MIRA
|
Abstract base class for codecs that can be used with BinarySerializer and BinaryDeserializer. More...
#include <serialization/BinarySerializerCodec.h>
Classes | |
struct | Fourcc |
A four-character code that is used to identify data formats and codecs. More... | |
Public Member Functions | |
virtual | ~BinarySerializerCodec () |
template<typename Reflector > | |
void | reflect (Reflector &r) |
virtual Fourcc | getFourcc () const |
Returns the Fourcc code information. More... | |
virtual TypeId | getSupportedTypeId () const =0 |
Returns the TypeId of the type that is supported by the codec. More... | |
template<typename T > | |
Buffer< uint8 > | encode (const T &object) |
Encodes the given object and returns the buffer with the encoded data. More... | |
template<typename T > | |
void | decode (const Buffer< uint8 > &data, T &ioObject) |
Decodes the given buffer into the object. More... | |
Class const & | getClass () const |
call the virtual internalGetClass(). More... | |
Static Public Member Functions | |
template<typename T > | |
static BinarySerializerCodecPtr | createCodec (Fourcc fourcc) |
Creates a codec with the specified FOURCC code that is suitable for encoding/decoding the specified type T. More... | |
static PseudoClass const & | CLASS () |
Protected Member Functions | |
virtual Buffer< uint8 > | encodeBuffer (TypedVoidConstPtr objectPtr)=0 |
This methods must be implemented in derived classes. More... | |
virtual void | decodeBuffer (const Buffer< uint8 > &data, TypedVoidPtr ioObjectPtr)=0 |
This methods must be implemented in derived classes. More... | |
virtual Class const & | internalGetClass () const =0 |
Abstract base class for codecs that can be used with BinarySerializer and BinaryDeserializer.
Each codec is identified by a four character code (fourcc). Moreover, a codec usually can handle a certain type of data which can be transformed into a binary buffer using the encode() method. Vice versa, a binary buffer can be restored into the object using the decode() method.
When developing a codec, the encodeBuffer() and decodeBuffer() must be implemented. Moreover the Codec class must provide the following meta information:
Example:
|
inlinevirtual |
|
inline |
|
pure virtual |
Returns the TypeId of the type that is supported by the codec.
Objects and instances of that type can be encoded and decoded by the codec.
|
inline |
Encodes the given object and returns the buffer with the encoded data.
|
inline |
Decodes the given buffer into the object.
|
protectedpure virtual |
This methods must be implemented in derived classes.
The typed objects that are passed to the above encode() method, are passed as untyped void pointers through this interface. Within the implementation of this method, you can use the castObject() methods to obtain a safe reference to the passed object. castObject() will do a type check so the casts are safe.
|
protectedpure virtual |
This methods must be implemented in derived classes.
The typed objects that are passed to the above encode() method, are passed as untyped void pointers through this interface. Within the implementation of this method, you can use the castObject() methods to obtain a safe reference to the passed object. castObject() will do a type check so the casts are safe.
|
inlinestatic |
Creates a codec with the specified FOURCC code that is suitable for encoding/decoding the specified type T.
Throws | XInvalidParameter if no such codec exists. |
|
inlineinherited |
call the virtual internalGetClass().
|
inlinestaticinherited |
|
protectedpure virtualinherited |