cxxtools::SerializationInfo Class Reference

Represents arbitrary types during serialization. More...

#include <cxxtools/serializationinfo.h>

Inheritance diagram for cxxtools::SerializationInfo:
cxxtools::Settings

Classes

union  U

Public Types

enum  Category { Void = 0, Value = 1, Object = 2, Array = 6 }
typedef Nodes::iterator Iterator
 iterator over subnodes.
typedef Nodes::const_iterator ConstIterator
 const iterator over subnodes.
typedef Nodes::iterator iterator
 iterator over subnodes, std style name.
typedef Nodes::const_iterator const_iterator
 const iterator over subnodes, std style name.
typedef long int_type
typedef unsigned long unsigned_type

Public Member Functions

 SerializationInfo ()
 SerializationInfo (const SerializationInfo &si)
 ~SerializationInfo ()
SerializationInfooperator= (const SerializationInfo &si)
Category category () const
void setCategory (Category cat)
const std::string & typeName () const
void setTypeName (const std::string &type)
const std::string & name () const
void setName (const std::string &name)
void setValue (const String &value)
 Serialization of flat data-types.
void setValue (const std::string &value)
void setValue (const char *value)
void setValue (Char value)
void setValue (wchar_t value)
void setValue (bool value)
void setValue (char value)
void setValue (unsigned char value)
void setValue (short value)
void setValue (unsigned short value)
void setValue (int value)
void setValue (unsigned int value)
void setValue (long value)
void setValue (unsigned long value)
void setValue (float value)
void setValue (double value)
void setValue (long double value)
void setNull ()
void getValue (String &value) const
 Deserialization of flat data-types.
void getValue (std::string &value) const
void getValue (Char &value) const
void getValue (wchar_t &value) const
void getValue (bool &value) const
void getValue (char &value) const
void getValue (signed char &value) const
void getValue (unsigned char &value) const
void getValue (short &value) const
void getValue (unsigned short &value) const
void getValue (int &value) const
void getValue (unsigned int &value) const
void getValue (long &value) const
void getValue (unsigned long &value) const
void getValue (float &value) const
void getValue (double &value) const
void getValue (long double &value) const
template<typename T >
SerializationInfoaddValue (const std::string &name, const T &value)
 Serialization of flat member data-types.
SerializationInfoaddMember (const std::string &name=std::string())
 Serialization of member data.
SerializationInfogetAddMember (const std::string &name)
 Returns a member; adds when not yet found.
const SerializationInfogetMember (const std::string &name) const
 Deserialization of member data.
const SerializationInfogetMember (unsigned idx) const
 Deserialization of member data.
template<typename T >
bool getMember (const std::string &name, T &value) const
 Deserialization of member data.
const SerializationInfofindMember (const std::string &name) const
 Find member data by name.
SerializationInfofindMember (const std::string &name)
 Find member data by name.
size_t memberCount () const
Iterator begin ()
Iterator end ()
ConstIterator begin () const
ConstIterator end () const
void clear ()
void swap (SerializationInfo &si)
bool isNull () const
bool isString () const
bool isString8 () const
bool isChar () const
bool isBool () const
bool isInt () const
bool isUInt () const
bool isFloat () const
void dump (std::ostream &out, const std::string &prefix=std::string()) const

Friends

void operator<<= (SerializationInfo &si, const SerializationInfo &ssi)

Detailed Description

Represents arbitrary types during serialization.

A SerializationInfo represent arbitrary types during serialization. It is a flexible structure, which can hold all informations to reconstruct a object.

The types of informations are:

  • a category (Void, Value, Object or Array)
  • a scalar value
  • a name of the type
  • a ordered list of SerializationInfo objects

Those informations are filled when objects are serialized using a serialization operator and a serializer can use those to create a serialized representation of a object.

A deserializer is used to convert a serialized representation into a SerializationInfo and a deserialization operator is used to convert the SerializationInfo back to the desired object.

To serialize and deserialize a object, those operators are needed. For all standard types there are predefined operators. For user types like own classes a operator can easily be written. The signature is always the same.

Serialization operator is defined as:

void operator <<= (cxxtools::SerializationInfo& si, const YourType& object);

It must collect all informations from YourType and put them to the cxxtools::SerializationInfo.

The deserialization operator is defined as:

void operator >>= (const cxxtools::SerializationInfo& si, YourType& object);

It must fetch the informations from SerializationInfo and fill the passed object to reconstruct it.

With those 2 operators a serializer is able to to convert the object to some format and the deserializers to convert it back to the object.

Since for standard container types operators are defined using templates, The operators above are also able to serializer and deserialize e.g. a std::vector<YourType>.

The scalar value may have several types. When accessing the value it is typically converted implicitly when possible. So when e.g. the SerializationInfo is set to a numeric value and a string value is read, you get a string representation of the numeric value.

Member Typedef Documentation

typedef Nodes::const_iterator cxxtools::SerializationInfo::const_iterator

const iterator over subnodes, std style name.

typedef Nodes::const_iterator cxxtools::SerializationInfo::ConstIterator

const iterator over subnodes.

typedef Nodes::iterator cxxtools::SerializationInfo::Iterator

iterator over subnodes.

typedef Nodes::iterator cxxtools::SerializationInfo::iterator

iterator over subnodes, std style name.

Member Enumeration Documentation

Enumerator:
Void 
Value 
Object 
Array 

Constructor & Destructor Documentation

cxxtools::SerializationInfo::SerializationInfo ( )
inline
cxxtools::SerializationInfo::SerializationInfo ( const SerializationInfo si)
cxxtools::SerializationInfo::~SerializationInfo ( )

Member Function Documentation

SerializationInfo& cxxtools::SerializationInfo::addMember ( const std::string &  name = std::string())

Serialization of member data.

template<typename T >
SerializationInfo& cxxtools::SerializationInfo::addValue ( const std::string &  name,
const T &  value 
)
inline

Serialization of flat member data-types.

Iterator cxxtools::SerializationInfo::begin ( )
inline
ConstIterator cxxtools::SerializationInfo::begin ( ) const
inline
Category cxxtools::SerializationInfo::category ( ) const
inline
void cxxtools::SerializationInfo::clear ( )
void cxxtools::SerializationInfo::dump ( std::ostream &  out,
const std::string &  prefix = std::string() 
) const
Iterator cxxtools::SerializationInfo::end ( )
inline
ConstIterator cxxtools::SerializationInfo::end ( ) const
inline
const SerializationInfo* cxxtools::SerializationInfo::findMember ( const std::string &  name) const

Find member data by name.

This method returns the data for an object with the name name. or null if it is not present.

SerializationInfo* cxxtools::SerializationInfo::findMember ( const std::string &  name)

Find member data by name.

This method returns the data for an object with the name name. or null if it is not present.

SerializationInfo& cxxtools::SerializationInfo::getAddMember ( const std::string &  name)
inline

Returns a member; adds when not yet found.

const SerializationInfo& cxxtools::SerializationInfo::getMember ( const std::string &  name) const

Deserialization of member data.

Exceptions
SerializationErrorwhen member is not found.
const SerializationInfo& cxxtools::SerializationInfo::getMember ( unsigned  idx) const

Deserialization of member data.

Exceptions
std::range_errorwhen index is too large
template<typename T >
bool cxxtools::SerializationInfo::getMember ( const std::string &  name,
T &  value 
) const
inline

Deserialization of member data.

Returns
true if member is found, false otherwise. The passed value is not modified when the member was not found.
void cxxtools::SerializationInfo::getValue ( String value) const

Deserialization of flat data-types.

void cxxtools::SerializationInfo::getValue ( std::string &  value) const
void cxxtools::SerializationInfo::getValue ( Char value) const
inline
void cxxtools::SerializationInfo::getValue ( wchar_t &  value) const
inline
void cxxtools::SerializationInfo::getValue ( bool &  value) const
inline
void cxxtools::SerializationInfo::getValue ( char &  value) const
inline
void cxxtools::SerializationInfo::getValue ( signed char &  value) const
inline
void cxxtools::SerializationInfo::getValue ( unsigned char &  value) const
inline
void cxxtools::SerializationInfo::getValue ( short &  value) const
inline
void cxxtools::SerializationInfo::getValue ( unsigned short &  value) const
inline
void cxxtools::SerializationInfo::getValue ( int &  value) const
inline
void cxxtools::SerializationInfo::getValue ( unsigned int &  value) const
inline
void cxxtools::SerializationInfo::getValue ( long &  value) const
inline
void cxxtools::SerializationInfo::getValue ( unsigned long &  value) const
inline
void cxxtools::SerializationInfo::getValue ( float &  value) const
inline
void cxxtools::SerializationInfo::getValue ( double &  value) const
inline
void cxxtools::SerializationInfo::getValue ( long double &  value) const
inline
bool cxxtools::SerializationInfo::isBool ( ) const
inline
bool cxxtools::SerializationInfo::isChar ( ) const
inline
bool cxxtools::SerializationInfo::isFloat ( ) const
inline
bool cxxtools::SerializationInfo::isInt ( ) const
inline
bool cxxtools::SerializationInfo::isNull ( ) const
inline
bool cxxtools::SerializationInfo::isString ( ) const
inline
bool cxxtools::SerializationInfo::isString8 ( ) const
inline
bool cxxtools::SerializationInfo::isUInt ( ) const
inline
size_t cxxtools::SerializationInfo::memberCount ( ) const
inline
const std::string& cxxtools::SerializationInfo::name ( ) const
inline
SerializationInfo& cxxtools::SerializationInfo::operator= ( const SerializationInfo si)
void cxxtools::SerializationInfo::setCategory ( Category  cat)
inline
void cxxtools::SerializationInfo::setName ( const std::string &  name)
inline
void cxxtools::SerializationInfo::setNull ( )
void cxxtools::SerializationInfo::setTypeName ( const std::string &  type)
inline
void cxxtools::SerializationInfo::setValue ( const String value)
inline

Serialization of flat data-types.

void cxxtools::SerializationInfo::setValue ( const std::string &  value)
inline
void cxxtools::SerializationInfo::setValue ( const char *  value)
inline
void cxxtools::SerializationInfo::setValue ( Char  value)
inline
void cxxtools::SerializationInfo::setValue ( wchar_t  value)
inline
void cxxtools::SerializationInfo::setValue ( bool  value)
inline
void cxxtools::SerializationInfo::setValue ( char  value)
inline
void cxxtools::SerializationInfo::setValue ( unsigned char  value)
inline
void cxxtools::SerializationInfo::setValue ( short  value)
inline
void cxxtools::SerializationInfo::setValue ( unsigned short  value)
inline
void cxxtools::SerializationInfo::setValue ( int  value)
inline
void cxxtools::SerializationInfo::setValue ( unsigned int  value)
inline
void cxxtools::SerializationInfo::setValue ( long  value)
inline
void cxxtools::SerializationInfo::setValue ( unsigned long  value)
inline
void cxxtools::SerializationInfo::setValue ( float  value)
inline
void cxxtools::SerializationInfo::setValue ( double  value)
inline
void cxxtools::SerializationInfo::setValue ( long double  value)
inline
void cxxtools::SerializationInfo::swap ( SerializationInfo si)
const std::string& cxxtools::SerializationInfo::typeName ( ) const
inline

Friends And Related Function Documentation

void operator<<= ( SerializationInfo si,
const SerializationInfo ssi 
)
friend

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