All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Valuable::Serializer Namespace Reference

XML Serializer namespace that has handles the (de)serialize dispatching. More...

Classes

class  Trait
 Trait class for compile time separation of different kinds of serializable objects. More...
 

Functions

template<typename T >
std::remove_cv< T >::type deserialize (const ArchiveElement &element)
 Deserializes an element. More...
 
template<typename T >
std::remove_cv< T >::type deserializeXML (const DOMElement &element)
 Compatibility function that deserializes DOMElement. More...
 
template<typename T >
deserializeXML (const QString &filename)
 Deserialize object from a XML file. More...
 
template<typename T >
ArchiveElement serialize (Archive &archive, const T &t)
 Serializes object t to new element that is added to the archive. More...
 
template<typename T >
bool serializeXML (const QString &filename, const T &t, unsigned int opts=SerializationOptions::DEFAULTS)
 Serialize object to a XML file. More...
 

Detailed Description

XML Serializer namespace that has handles the (de)serialize dispatching.

Correct way to save/load object state to/from XML is to use static serialize/deserialize methods.

Function Documentation

template<typename T >
std::remove_cv<T>::type Valuable::Serializer::deserialize ( const ArchiveElement &  element)

Deserializes an element.

If deserialization fails or the template type is not compatible with the data in the element, an object of T created by its default constructor or NULL is returned.

Parameters
elementSerialized element that holds the data that should be deserialized.
Returns
Deserialized type
template<typename T >
std::remove_cv<T>::type Valuable::Serializer::deserializeXML ( const DOMElement &  element)

Compatibility function that deserializes DOMElement.

Use deserialize(const ArchiveElement&) instead.

Parameters
elementXML element that is deserialized
Returns
Deserialized type
template<typename T >
T Valuable::Serializer::deserializeXML ( const QString &  filename)
inline

Deserialize object from a XML file.

Example usage:

Widget * widget = Serializer::deserializeXML<Widget*>("widget.xml");
Parameters
filenameName of the XML file
Returns
Serialized object
template<typename T >
ArchiveElement Valuable::Serializer::serialize ( Archive &  archive,
const T &  t 
)

Serializes object t to new element that is added to the archive.

Parameters
archiveThe serializer archive that is used to create the new element and maintains the serialization state and options.
tObject to be serialized
Returns
The new serialized element.
template<typename T >
bool Valuable::Serializer::serializeXML ( const QString &  filename,
const T &  t,
unsigned int  opts = SerializationOptions::DEFAULTS 
)
inline

Serialize object to a XML file.

Example usage:

Serializer::serializeXML("widget.xml", widget);
Parameters
filenameoutput xml filename
tObject to be serialized
optsBitmask of SerializationOptions::Options
Returns
True on success