XmlFormatter Class Reference

#include <Pt/Xml/XmlFormatter.h>

Format objects or data to XML.

Inherits Formatter, and NonCopyable.

Public Member Functions

 XmlFormatter ()
 Default Constructor.
 
 XmlFormatter (XmlWriter &writer)
 Construct a formatter writing to a XmlWriter.
 
 XmlFormatter (XmlReader &reader)
 Construct a formatter reading from a XmlReader.
 
 ~XmlFormatter ()
 Destructor.
 
void attach (XmlWriter &writer)
 Attach to an XmlWriter.
 
XmlWriterwriter ()
 Returns the attached XmlWriter or a nullptr.
 
void attach (XmlReader &reader)
 Attach to an XmlReader.
 
XmlReaderreader ()
 Returns the attached XmlReader or a nullptr.
 
void detach ()
 Detach from its XmlReader and XmlWriter.
 
void addString (const std::string &name, const std::string &type, const Pt::String &value, const std::string &id)
 Formats a string value.
 
void addString (const char *name, const char *type, const Pt::Char *value, const char *id)
 Formats a string value.
 
void addBinary (const std::string &name, const std::string &type, const char *value, std::size_t length, const std::string &id)
 Formats a binary value.
 
void addBinary (const char *name, const char *type, const char *value, std::size_t length, const char *id)
 Formats a binary value.
 
void addBool (const std::string &name, bool value, const std::string &id)
 Formats a boolean value.
 
void addBool (const char *name, bool value, const char *id)
 Formats a boolean value.
 
void addChar (const std::string &name, const Pt::Char &value, const std::string &id)
 Formats a character value.
 
void addChar (const char *name, const Pt::Char &value, const char *id)
 Formats a character value.
 
void addInt8 (const std::string &name, Pt::int8_t value, const std::string &id)
 Formats a 8-bit signed integer value.
 
void addInt8 (const char *name, Pt::int8_t value, const char *id)
 Formats a 8-bit signed integer value.
 
void addInt16 (const std::string &name, Pt::int16_t value, const std::string &id)
 Formats a 16-bit signed integer value.
 
void addInt16 (const char *name, Pt::int16_t value, const char *id)
 Formats a 16-bit signed integer value.
 
void addInt32 (const std::string &name, Pt::int32_t value, const std::string &id)
 Formats a 32-bit signed integer value.
 
void addInt32 (const char *name, Pt::int32_t value, const char *id)
 Formats a 32-bit signed integer value.
 
void addInt64 (const std::string &name, Pt::int64_t value, const std::string &id)
 Formats a 64-bit signed integer value.
 
void addInt64 (const char *name, Pt::int64_t value, const char *id)
 Formats a 64-bit signed integer value.
 
void addUInt8 (const std::string &name, Pt::uint8_t value, const std::string &id)
 Formats a 8-bit unsigned integer value.
 
void addUInt8 (const char *name, Pt::uint8_t value, const char *id)
 Formats a 8-bit unsigned integer value.
 
void addUInt16 (const std::string &name, Pt::uint16_t value, const std::string &id)
 Formats a 16-bit unsigned integer value.
 
void addUInt16 (const char *name, Pt::uint16_t value, const char *id)
 Formats a 16-bit unsigned integer value.
 
void addUInt32 (const std::string &name, Pt::uint32_t value, const std::string &id)
 Formats a 32-bit unsigned integer value.
 
void addUInt32 (const char *name, Pt::uint32_t value, const char *id)
 Formats a 32-bit unsigned integer value.
 
void addUInt64 (const std::string &name, Pt::uint64_t value, const std::string &id)
 Formats a 64-bit unsigned integer value.
 
void addUInt64 (const char *name, Pt::uint64_t value, const char *id)
 Formats a 64-bit unsigned integer value.
 
void addFloat (const std::string &name, float value, const std::string &id)
 Formats a float value.
 
void addFloat (const char *name, float value, const char *id)
 Formats a float value.
 
void addDouble (const std::string &name, double value, const std::string &id)
 Formats a double value.
 
void addDouble (const char *name, double value, const char *id)
 Formats a double value.
 
void addLongDouble (const std::string &name, long double value, const std::string &id)
 Formats a long double value.
 
void addLongDouble (const char *name, long double value, const char *id)
 Formats a long double value.
 
void addReference (const std::string &name, const std::string &refId)
 Formats a reference.
 
void addReference (const char *name, const char *refId)
 Formats a reference.
 
void beginStruct (const std::string &name, const std::string &type, const std::string &id)
 Formats the begin of a struct.
 
void beginStruct (const char *name, const char *type, const char *id)
 Formats the begin of a struct.
 
void beginMember (const std::string &name)
 Formats the begin of a struct member.
 
void beginMember (const char *name)
 Formats the begin of a struct member.
 
void finishMember ()
 Formats the end of a struct member.
 
void finishStruct ()
 Formats the end of a struct.
 
void beginSequence (const std::string &name, const std::string &type, const std::string &id)
 Formats the begin of an array.
 
void beginSequence (const char *name, const char *type, const char *id)
 Formats the begin of an array.
 
void beginElement ()
 Formats the begin of an array element.
 
void finishElement ()
 Formats the end of an array element.
 
void finishSequence ()
 Formats the end of an array.
 
void beginDict (const std::string &name, const std::string &type, const std::string &id)
 Formats the begin of a dict.
 
void beginDict (const char *name, const char *type, const char *id)
 Formats the begin of a dict.
 
void beginDictElement ()
 Formats the begin of a dict element.
 
void finishDictElement ()
 Formats the end of a dict element.
 
void beginDictKey ()
 Formats the begin of a dict key.
 
void finishDictKey ()
 Formats the end of a dict key.
 
void beginDictValue ()
 Formats the begin of a dict value.
 
void finishDictValue ()
 Formats the end of a dict value.
 
void finishDict ()
 Formats the end of a dict.
 
void beginParse (Composer &composer)
 Begin to parse to a composer.
 
bool parseSome ()
 Returns true if composer completes, false if no more data available.
 
void parse ()
 Parse until composer completes.
 

Protected Member Functions

void onAddString (const char *, const char *type, const Pt::Char *value, const char *id)
 Formats a string value.
 
void onAddBool (const char *name, bool value, const char *id)
 Formats a bool value.
 
void onAddChar (const char *name, const Pt::Char &value, const char *id)
 Formats a character value.
 
void onAddInt8 (const char *name, Pt::int8_t value, const char *id)
 Formats a 8-bit integer.
 
void onAddInt16 (const char *name, Pt::int16_t value, const char *id)
 Formats a 16-bit integer.
 
void onAddInt32 (const char *name, Pt::int32_t value, const char *id)
 Formats a 32-bit integer.
 
void onAddInt64 (const char *name, Pt::int64_t value, const char *id)
 Formats a 64-bit integer.
 
void onAddUInt8 (const char *name, Pt::uint8_t value, const char *id)
 Formats a 8-bit unsigned integer.
 
void onAddUInt16 (const char *name, Pt::uint16_t value, const char *id)
 Formats a 16-bit unsigned integer.
 
void onAddUInt32 (const char *name, Pt::uint32_t value, const char *id)
 Formats a 32-bit unsigned integer.
 
void onAddUInt64 (const char *name, Pt::uint64_t value, const char *id)
 Formats a 64-bit unsigned integer.
 
void onAddFloat (const char *name, float value, const char *id)
 Formats a float value.
 
void onAddDouble (const char *name, double value, const char *id)
 Formats a double value.
 
void onAddLongDouble (const char *name, long double value, const char *id)
 Formats a long double value.
 
void onAddBinary (const char *name, const char *type, const char *value, std::size_t length, const char *id)
 Formats a binary value.
 
void onAddReference (const char *name, const char *value)
 Formats a reference.
 
void onBeginSequence (const char *name, const char *type, const char *id)
 Formats the begin of a sequence.
 
void onBeginElement ()
 Formats the begin of a sequence element.
 
void onFinishElement ()
 Formats the end of a sequence element.
 
void onFinishSequence ()
 Formats the end of a sequence.
 
void onBeginStruct (const char *name, const char *type, const char *id)
 Formats the begin of a struct.
 
void onBeginMember (const char *name)
 Formats the begin of a struct member.
 
void onFinishMember ()
 Formats the end of a struct member.
 
void onFinishStruct ()
 Formats the end of a struct.
 
void onBeginParse (Composer &composer)
 Begin to parse to a composer.
 
bool onParseSome ()
 Returns true if composer completes, false if no more data available.
 
void onParse ()
 Parse until composer completes.
 
virtual void onBeginDict (const char *name, const char *type, const char *id)
 Formats the begin of a dict.
 
virtual void onBeginDictElement ()
 Formats the begin of a dict element.
 
virtual void onBeginDictKey ()
 Formats the begin of a dict key.
 
virtual void onFinishDictKey ()
 Formats the end of a dict key.
 
virtual void onBeginDictValue ()
 Formats the begin of a dict value.
 
virtual void onFinishDictValue ()
 Formats the end of a dict value.
 
virtual void onFinishDictElement ()
 Formats the end of a dict element.
 
virtual void onFinishDict ()
 Formats the end of a dict.