XmlSerializer Class Reference

#include <Pt/Xml/XmlSerializer.h>

Serialize objects or data to XML.

Inherits Serializer.

Public Member Functions

 XmlSerializer ()
 Default Constructor.
 
 XmlSerializer (XmlWriter &writer)
 Construct to use an XmlWriter.
 
void attach (XmlWriter &writer)
 Attach to an XmlWriter.
 
void detach ()
 Detach from its XmlWriter.
 
XmlWriterwriter ()
 Returns the attached XmlWriter or a nullptr.
 
SerializationContextcontext ()
 Returns the used context.
 
void reset (SerializationContext *context)
 Clears the serializer and sets a new context.
 
Formatterformatter ()
 Returns the used formatter.
 
void setFormatter (Formatter &formatter)
 Returns formatter to use.
 
void clear ()
 Clears all content.
 
template<typename T >
void begin (const T &type, const char *name)
 Begins serialization of an object. More...
 
bool advance ()
 Advances formatting of the object set. More...
 
void finish ()
 Finishes parsing of the object set. More...
 

Member Function Documentation

◆ begin()

void begin ( const T &  type,
const char *  name 
)
inherited

This method has to be called for each object to be part of the object stream before formatting is done by calling advance() or finish(). This is neccessary, because reference IDs have to be assigned to referenced objects before they can formatted. The string name will be used as the instance name of type. The type must be serializable.

◆ advance()

bool advance ( )
inherited

Returns true if the objects passed to begin() were completely formatted, otherwise false is returned, in which case only a part of the objects was formatted and advance() has to be called again until formatting is complete.

◆ finish()

void finish ( )
inherited

This method will finish formatting of all objects started by begin() or partially formatted by calling advance().