Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
XOMElementSerializer Class Reference

#include <elm/serial2/XOMSerializer.h>

+ Inheritance diagram for XOMElementSerializer:

Public Member Functions

 XOMElementSerializer (xom::Element *top)
 
virtual ~XOMElementSerializer (void)
 
ExternalSolversolver (void) const
 
void setSolver (ExternalSolver &solver)
 
virtual void flush (void)
 
virtual void beginObject (const rtti::Type &clazz, const void *object)
 
virtual void endObject (const rtti::Type &clazz, const void *object)
 
virtual void beginField (CString name)
 
virtual void endField (void)
 
virtual void onPointer (const rtti::Type &clazz, const void *object)
 
virtual void beginCompound (const void *)
 
virtual void endCompound (const void *)
 
virtual void onEnum (const void *address, int value, const rtti::Type &clazz)
 
virtual void onValue (const bool &v)
 
virtual void onValue (const signed int &v)
 
virtual void onValue (const unsigned int &v)
 
virtual void onValue (const char &v)
 
virtual void onValue (const signed char &v)
 
virtual void onValue (const unsigned char &v)
 
virtual void onValue (const signed short &v)
 
virtual void onValue (const unsigned short &v)
 
virtual void onValue (const signed long &v)
 
virtual void onValue (const unsigned long &v)
 
virtual void onValue (const signed long long &v)
 
virtual void onValue (const unsigned long long &v)
 
virtual void onValue (const float &v)
 
virtual void onValue (const double &v)
 
virtual void onValue (const long double &v)
 
virtual void onValue (const CString &v)
 
virtual void onValue (const String &v)
 
virtual void onItem (void)
 
- Public Member Functions inherited from Serializer
virtual ~Serializer (void)
 

Detailed Description

An XOM serializer provides serialization facility to XML using XOM library.

The XML serialization follows the rules below:

  • An object is serialized by an XML element. XML element name is not important as the deserialization is led by the C++ types.
  • An element representing an object supports the "id" attribute to implemenet pointer or references to it.
  • unserializing of an object is led by the reference or the pointer of access but the actual type, if different, is given by a "class" providing the fully qualified C++ path of the class.
  • A pointer or a reference field are implemented either by included the pointed or referenced object inside the element, or by providing a "ref" attribute with the identifier of the object.
  • Null pointers have a special "ref" attribute with value "NULL".
  • Field are implemented as sub-element of the object element whose name is the field name.
  • Compound object is implemented with a sub-element for each item of the compound.
  • Enumeration are serialized using their non-qualified identifier string.
  • Other values must be serialized as human readable text nodes.

Constructor & Destructor Documentation

◆ XOMElementSerializer()

Build a serializer to the given XOM document.

Parameters
elementElement to populate with serialization.

◆ ~XOMElementSerializer()

Member Function Documentation

◆ beginCompound()

void beginCompound ( const void object)
virtual

This function is called to serialize a compound object, that is, an object containing a collection of values with the same type.

Parameters
objectCompound object to serialize.

Implements Serializer.

References elm::_, and Vector< T, E, A >::push().

◆ beginField()

void beginField ( CString  name)
virtual

Called to begin the serialization of a field in an object.

This call is always preceded by call to beginObject() for the object containing the field and there is no more call to this function as soon as the corresponding endObject() call is performed.

Between a call to a beginField() and of a endField(), calls to the serializer functions are performed to serialize the corresponding data.

Parameters
nameName of the field.

Implements Serializer.

References Vector< T, E, A >::push().

◆ beginObject()

void beginObject ( const rtti::Type clazz,
const void object 
)
virtual

Called to start the serialization of a new object.

Parameters
clazzObject class descriptor.
objectSerialized object.

Implements Serializer.

References elm::_, elm::cout, ParentNode::getChild(), ParentNode::getChildCount(), Type::name(), and ParentNode::removeChild().

◆ endCompound()

void endCompound ( const void )
virtual

This function is called at the end of a compound.

This function is only called after a call to beginCompound() and matches any call to beginCompound().

Implements Serializer.

References Vector< T, E, A >::pop().

◆ endField()

void endField ( void  )
virtual

Called to begin the serialization of a field in an object.

This call is always preceded by call to beginField() and there is no more call to this function as soon as the corresponding endObject() call is performed.

Implements Serializer.

References Vector< T, E, A >::pop().

◆ endObject()

void endObject ( const rtti::Type clazz,
const void object 
)
virtual

Called to finish the serialization of a new object. This function call is always preceded by a call to beginObject().

Parameters
clazzObject class descriptor.
objectSerialized object.

Implements Serializer.

◆ flush()

void flush ( void  )
virtual

◆ onEnum()

void onEnum ( const void address,
int  value,
const rtti::Type clazz 
)
virtual

Called when a value of type enumerate has to be serialized.

Parameters
addressAddress of the value.
valueValue to serialzie.
clazzEnumerated type.

Implements Serializer.

References Type::asEnum(), and Enumerable::nameFor().

◆ onItem()

void onItem ( void  )
virtual

For each value of a compound object, a call to this function is performed.

This function call is always preceded by a call to beginCompound() and will not call anymore after a call to endCompound().

This call is followed by calls to other serialization function in order to serialize the value itself.

Implements Serializer.

References Vector< T, E, A >::pop(), and Vector< T, E, A >::push().

◆ onPointer()

void onPointer ( const rtti::Type clazz,
const void object 
)
virtual

This function is called to serialize a pointer to an object.

A special caution must be devoted to serialize pointer because of the possibility of a circular data structures that may lead to endless looping on this function.

Parameters
clazzClass of the pointed object.
objectPointed object to serialize.

Implements Serializer.

References elm::_, HashMap< K, T, H, A, E >::hasKey(), elm::pair(), and HashMap< K, T, H, A, E >::put().

◆ onValue() [1/17]

void onValue ( const bool v)
virtual

Called to serialize a value of type boolean.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [2/17]

void onValue ( const char &  v)
virtual

References elm::_, and String::toCString().

◆ onValue() [3/17]

void onValue ( const CString v)
virtual

Called to serialize a value of type C string.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [4/17]

void onValue ( const double &  v)
virtual

Called to serialize a value of type double-precision floating point.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [5/17]

void onValue ( const float &  v)
virtual

Called to serialize a value of type single-precision floating point.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [6/17]

void onValue ( const long double &  v)
virtual

Called to serialize a value of type quadruple-precision floating point.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [7/17]

void onValue ( const signed char &  v)
virtual

Called to serialize a value of type signed byte.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [8/17]

void onValue ( const signed int &  v)
virtual

Called to serialize a value of type signed integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [9/17]

void onValue ( const signed long &  v)
virtual

Called to serialize a value of type signed long integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [10/17]

void onValue ( const signed long long &  v)
virtual

Called to serialize a value of type signed long long integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [11/17]

void onValue ( const signed short &  v)
virtual

Called to serialize a value of type signed short integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [12/17]

void onValue ( const String v)
virtual

Called to serialize a value of type ELM string.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [13/17]

void onValue ( const unsigned char &  v)
virtual

Called to serialize a value of type unsigned byte.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [14/17]

void onValue ( const unsigned int &  v)
virtual

Called to serialize a value of type unsigned integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [15/17]

void onValue ( const unsigned long &  v)
virtual

Called to serialize a value of type unsigned long integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [16/17]

void onValue ( const unsigned long long &  v)
virtual

Called to serialize a value of type unsigned long long integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ onValue() [17/17]

void onValue ( const unsigned short &  v)
virtual

Called to serialize a value of type unsigned short integer.

Parameters
vValue to serialize.

Implements Serializer.

References elm::_, and String::toCString().

◆ setSolver()

void setSolver ( ExternalSolver solver)
inline

◆ solver()

ExternalSolver& solver ( void  ) const
inline

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