Classes | Defines

Serialization.h File Reference

#include <map>
#include <vector>
#include <string>
#include <string.h>
#include <ut_types.h>
#include <ut_string_class.h>

Go to the source code of this file.

Classes

struct  CompactInt
class  Archive
 Base archive. More...
class  StrArchive
 String based archive. More...
class  IStrArchive
 Input (loading) archive. More...
class  OStrArchive
 Output (saving) archive. More...

Defines

#define DEFINE_POD_OPERATOR_ONE(T)
#define DEFINE_POD_OPERATOR_VECTOR(T)
#define DEFINE_POD_OPERATOR(T)
#define COMPACT_INT(v)   (*(CompactInt*)&v)
 Compact serializer, can safely be used to compact int's and unsigned int's.

Define Documentation

#define COMPACT_INT (   v  )     (*(CompactInt*)&v)

Compact serializer, can safely be used to compact int's and unsigned int's.

Basically any 4-bytes value. Don't use it on size_t's or longs, 64-bits machines will crash. Use the COMPACT_INT define to easily serialize integer values: e.g. ar << COMPACT_INT(m_iRev);

Referenced by AccountHandler::_createPacket(), AccountHandler::_createPacketStream(), and Archive::operator<<().

#define DEFINE_POD_OPERATOR (   T  ) 
#define DEFINE_POD_OPERATOR_ONE (   T  ) 
Value:
Archive& operator<<( T& Val )                   \
    {                                               \
        Serialize( &Val, sizeof(T) );               \
        return *this;                               \
    }
#define DEFINE_POD_OPERATOR_VECTOR (   T  ) 
Value:
Archive& operator<<( std::vector<T>& Val )      \
    {                                               \
        unsigned int count;                         \
        if (isLoading()) {                          \
            *this << COMPACT_INT(count);            \
            Val.resize( count );                    \
        } else {                                    \
            count = Val.size();                     \
            *this << COMPACT_INT(count);            \
        }                                           \
        Serialize( &Val[0], count*sizeof(T) );      \
        return *this;                               \
    }