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

#include <elm/serial2/XOMUnserializer.h>

+ Inheritance diagram for XOMUnserializer:

Public Member Functions

 XOMUnserializer (xom::Element *element)
 
 XOMUnserializer (const char *path)
 
 XOMUnserializer (cstring path)
 
 XOMUnserializer (sys::Path path)
 
 ~XOMUnserializer (void)
 
ExternalSolversolver (void) const
 
void setSolver (ExternalSolver &solver)
 
virtual void flush (void)
 
virtual void beginObject (const rtti::Type &clazz, void *object)
 
virtual void endObject (const rtti::Type &clazz, void *object)
 
virtual bool beginField (CString name)
 
virtual void endField (void)
 
virtual void onPointer (const rtti::Type &clazz, void **object)
 
virtual bool beginCompound (void *)
 
virtual int countItems (void)
 
virtual bool nextItem (void)
 
virtual void endCompound (void *)
 
virtual int onEnum (const rtti::Type &clazz)
 
virtual void onValue (bool &v)
 
virtual void onValue (signed int &v)
 
virtual void onValue (unsigned int &v)
 
virtual void onValue (char &v)
 
virtual void onValue (signed char &v)
 
virtual void onValue (unsigned char &v)
 
virtual void onValue (signed short &v)
 
virtual void onValue (unsigned short &v)
 
virtual void onValue (signed long &v)
 
virtual void onValue (unsigned long &v)
 
virtual void onValue (signed long long &v)
 
virtual void onValue (unsigned long long &v)
 
virtual void onValue (float &v)
 
virtual void onValue (double &v)
 
virtual void onValue (long double &v)
 
virtual void onValue (CString &v)
 
virtual void onValue (String &v)
 
- Public Member Functions inherited from Unserializer
virtual ~Unserializer (void)
 

Static Public Attributes

const static cstring id_tag = "id"
 
const static cstring ref_tag = "ref"
 
const static cstring null_tag = "NULL"
 
const static cstring class_tag = "class"
 

Detailed Description

This class an unserializer for XML files using XOM module.

The XML file / node must meet the following rules:

  • 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

◆ XOMUnserializer() [1/4]

XOMUnserializer ( xom::Element element)

Build the unserializer for using the given element.

Parameters
elementXOM element to use.

References Node::getDocument().

◆ XOMUnserializer() [2/4]

XOMUnserializer ( const char *  path)

Build an unserializer from the given XOM document.

Parameters
pathPath document to unserialize from.

◆ XOMUnserializer() [3/4]

Build an unserializer from the given XOM document.

Parameters
pathPath document to unserialize from.

◆ XOMUnserializer() [4/4]

Build an unserializer from the given XOM document.

Parameters
pathPath document to unserialize from.

References String::toCString(), and Path::toString().

◆ ~XOMUnserializer()

Member Function Documentation

◆ beginCompound()

bool beginCompound ( void )
virtual

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

Parameters
objectCompound object to unserialize.

Implements Unserializer.

References Node::ELEMENT, Node::kind(), and Vector< T, E, A >::push().

◆ beginField()

bool beginField ( CString  name)
virtual

Called to begin the unserialization 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 unserializer functions are performed to serialize the corresponding data.

Parameters
nameName of the field.

Implements Unserializer.

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

◆ beginObject()

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

Called to start the unserialization of a new object.

Parameters
clazzObject class descriptor.
objectUnserialized object.

Implements Unserializer.

◆ countItems()

int countItems ( void  )
virtual

This function is called to get the count if items in a compound.

If it only called after a beginCompound() and before any to nextItem().

Returns
Count of values in the compound.

Implements Unserializer.

References Node::ELEMENT, and Node::kind().

◆ endCompound()

void endCompound ( 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 Unserializer.

◆ endField()

void endField ( void  )
virtual

Called to end the unserialization 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 Unserializer.

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

◆ endObject()

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

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

Parameters
clazzObject class descriptor.
objectUnserialized object.

Implements Unserializer.

◆ flush()

◆ nextItem()

bool nextItem ( void  )
virtual

Afgter getting a value of a compound object, a call to this function must be 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 unserialization function in order to unserialize the value itself.

Implements Unserializer.

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

◆ onEnum()

int onEnum ( const rtti::Type clazz)
virtual

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

Parameters
clazzEnumerated type.
Returns
Enumerated value.

Implements Unserializer.

References elm::_, Type::asEnum(), String::free(), and Enumerable::valueFor().

◆ onPointer()

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

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

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

Implements Unserializer.

References XOMUnserializer::null_tag, elm::pair(), elm::t::ref(), and XOMUnserializer::ref_tag.

◆ onValue() [1/17]

void onValue ( bool v)
virtual

Called to unserialize a value of type boolean.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [2/17]

void onValue ( char &  v)
virtual

Implements Unserializer.

References String::free(), and Input::setStream().

◆ onValue() [3/17]

void onValue ( CString v)
virtual

Called to unserialize a value of type C string.

Parameters
vReference to unserialize in.

Implements Unserializer.

◆ onValue() [4/17]

void onValue ( double &  v)
virtual

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

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [5/17]

void onValue ( float &  v)
virtual

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

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [6/17]

void onValue ( long double &  v)
virtual

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

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [7/17]

void onValue ( signed char &  v)
virtual

Implements Unserializer.

References String::free(), and Input::setStream().

◆ onValue() [8/17]

void onValue ( signed int &  v)
virtual

Called to unserialize a value of type signed integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [9/17]

void onValue ( signed long &  v)
virtual

Called to unserialize a value of type signed long integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [10/17]

void onValue ( signed long long &  v)
virtual

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

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [11/17]

void onValue ( signed short &  v)
virtual

Called to unserialize a value of type signed short integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [12/17]

void onValue ( String v)
virtual

Called to unserialize a value of type ELM string.

Parameters
vReference to unserialize in.

Implements Unserializer.

References String::free().

◆ onValue() [13/17]

void onValue ( unsigned char &  v)
virtual

Called to unserialize a value of type unsigned byte.

Parameters
vReference to unserialize in.

Implements Unserializer.

References String::free(), and Input::setStream().

◆ onValue() [14/17]

void onValue ( unsigned int &  v)
virtual

Called to unserialize a value of type unsigned integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [15/17]

void onValue ( unsigned long &  v)
virtual

Called to unserialize a value of type unsigned long integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [16/17]

void onValue ( unsigned long long &  v)
virtual

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

Parameters
vValue to serialize.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ onValue() [17/17]

void onValue ( unsigned short &  v)
virtual

Called to unserialize a value of type unsigned short integer.

Parameters
vReference to unserialize in.

Implements Unserializer.

References elm::_, String::free(), and Input::setStream().

◆ setSolver()

void setSolver ( ExternalSolver solver)
inline

Set the current external solver.

Parameters
solverNew solver to use.

References XOMUnserializer::solver().

◆ solver()

ExternalSolver & solver ( void  ) const
inline

Get the current solver of external entities. External entities are objects provided by the application with which serialized objects ma be linked.

Returns
Current external solver.

Referenced by XOMUnserializer::setSolver().

Member Data Documentation

◆ class_tag

const cstring class_tag = "class"
static

◆ id_tag

const cstring id_tag = "id"
static

Referenced by XOMUnserializer::flush().

◆ null_tag

const cstring null_tag = "NULL"
static

◆ ref_tag

const cstring ref_tag = "ref"
static

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