18#ifndef INCLUDED_NETWORK_SERIALIZATION
19#define INCLUDED_NETWORK_SERIALIZATION
21#define Serialize_int_1(_pos, _val) \
22 STMT( *((_pos)++) = (u8)((_val)&0xff); )
24#define Serialize_int_2(_pos, _val) STMT(\
25 Serialize_int_1(_pos, (_val)>>8); \
26 Serialize_int_1(_pos, (_val)); \
29#define Serialize_int_3(_pos, _val) STMT(\
30 Serialize_int_1(_pos, (_val)>>16); \
31 Serialize_int_2(_pos, (_val)); \
34#define Serialize_int_4(_pos, _val) STMT(\
35 Serialize_int_1(_pos, (_val)>>24); \
36 Serialize_int_3(_pos, (_val)); \
39#define Serialize_int_8(_pos, _val) STMT(\
40 Serialize_int_4(_pos, (_val)>>32); \
41 Serialize_int_4(_pos, (_val)); \
44#define __shift_de(_pos, _val) STMT( \
46 (_val) += *((_pos)++); )
48#define Deserialize_int_1(_pos, _val) STMT(\
49 (_val) = *((_pos)++); )
51#define Deserialize_int_2(_pos, _val) STMT(\
52 Deserialize_int_1(_pos, _val); \
53 __shift_de(_pos, _val); )
55#define Deserialize_int_3(_pos, _val) STMT(\
56 Deserialize_int_2(_pos, _val); \
57 __shift_de(_pos, _val); )
59#define Deserialize_int_4(_pos, _val) STMT(\
60 Deserialize_int_3(_pos, _val); \
61 __shift_de(_pos, _val); )
63#define Deserialize_int_8(_pos, _val) STMT(\
64 uint32 _v1; uint32 _v2; \
65 Deserialize_int_4(_pos, _v1); \
66 Deserialize_int_4(_pos, _v2); \
An interface for serializable objects.
Definition: Serialization.h:76
virtual ~ISerializable()
Definition: Serialization.h:78
virtual u8 * Serialize(u8 *buffer) const =0
Serialize the object into the passed buffer.
virtual const u8 * Deserialize(const u8 *buffer, const u8 *end)=0
Deserialize the object (i.e.
virtual size_t GetSerializedLength() const =0
Return the length of the serialized form of this object.
uint8_t u8
Definition: types.h:37