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

#include <elm/serial2/TextSerializer.h>

+ Inheritance diagram for TextSerializer:

Public Member Functions

 TextSerializer (io::Output &out=cout)
 
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 onItem (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 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)
 
- Public Member Functions inherited from Serializer
virtual ~Serializer (void)
 

Detailed Description

Serialize the given data to a character output stream, readable by human being.

Constructor & Destructor Documentation

◆ TextSerializer()

TextSerializer ( io::Output out = cout)
inline

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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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

Flush to the media (disk, network) the current state of the serialization.

Implements Serializer.

References HashMap< K, T, H, A, E >::clear(), Pair< T1, T2 >::fst, HashMap< K, T, H, A, E >::get(), and Pair< T1, T2 >::snd.

◆ 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.

◆ 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 HashMap< K, T, H, A, E >::exists(), elm::pair(), and HashMap< K, T, H, A, E >::put().

◆ onValue() [1/16]

void onValue ( const bool v)
virtual

Called to serialize a value of type boolean.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [2/16]

void onValue ( const CString v)
virtual

Called to serialize a value of type C string.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [3/16]

void onValue ( const double &  v)
virtual

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

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [4/16]

void onValue ( const float &  v)
virtual

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

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [5/16]

void onValue ( const long double &  v)
virtual

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

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [6/16]

void onValue ( const signed char &  v)
virtual

Called to serialize a value of type signed byte.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [7/16]

void onValue ( const signed int &  v)
virtual

Called to serialize a value of type signed integer.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [8/16]

void onValue ( const signed long &  v)
virtual

Called to serialize a value of type signed long integer.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [9/16]

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.

◆ onValue() [10/16]

void onValue ( const signed short &  v)
virtual

Called to serialize a value of type signed short integer.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [11/16]

void onValue ( const String v)
virtual

Called to serialize a value of type ELM string.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [12/16]

void onValue ( const unsigned char &  v)
virtual

Called to serialize a value of type unsigned byte.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [13/16]

void onValue ( const unsigned int &  v)
virtual

Called to serialize a value of type unsigned integer.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [14/16]

void onValue ( const unsigned long &  v)
virtual

Called to serialize a value of type unsigned long integer.

Parameters
vValue to serialize.

Implements Serializer.

◆ onValue() [15/16]

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.

◆ onValue() [16/16]

void onValue ( const unsigned short &  v)
virtual

Called to serialize a value of type unsigned short integer.

Parameters
vValue to serialize.

Implements Serializer.


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