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 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 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 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 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 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 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 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 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 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 attach (XmlWriter &writer)
 Attach to an XmlWriter.
 
void attach (XmlReader &reader)
 Attach to an XmlReader.
 
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 beginDictKey ()
 Formats the begin of a dict key.
 
void beginDictValue ()
 Formats the begin of a dict value.
 
void beginElement ()
 Formats the begin of an array element.
 
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 beginParse (Composer &composer)
 Begin to parse to a composer.
 
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 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 detach ()
 Detach from its XmlReader and XmlWriter.
 
void finishDict ()
 Formats the end of a dict.
 
void finishDictElement ()
 Formats the end of a dict element.
 
void finishDictKey ()
 Formats the end of a dict key.
 
void finishDictValue ()
 Formats the end of a dict value.
 
void finishElement ()
 Formats the end of an array element.
 
void finishMember ()
 Formats the end of a struct member.
 
void finishSequence ()
 Formats the end of an array.
 
void finishStruct ()
 Formats the end of a struct.
 
void parse ()
 Parse until composer completes.
 
bool parseSome ()
 Returns true if composer completes, false if no more data available.
 
XmlReaderreader ()
 Returns the attached XmlReader or a nullptr.
 
XmlWriterwriter ()
 Returns the attached XmlWriter or a nullptr.
 

Protected Member Functions

void onAddBinary (const char *name, const char *type, const char *value, std::size_t length, const char *id)
 Formats a binary 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 onAddDouble (const char *name, double value, const char *id)
 Formats a double value.
 
void onAddFloat (const char *name, float value, const char *id)
 Formats a float value.
 
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 onAddInt8 (const char *name, Pt::int8_t value, const char *id)
 Formats a 8-bit integer.
 
void onAddLongDouble (const char *name, long double value, const char *id)
 Formats a long double value.
 
void onAddReference (const char *name, const char *value)
 Formats a reference.
 
void onAddString (const char *, const char *type, const Pt::Char *value, const char *id)
 Formats a string value.
 
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 onAddUInt8 (const char *name, Pt::uint8_t value, const char *id)
 Formats a 8-bit unsigned integer.
 
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 onBeginDictValue ()
 Formats the begin of a dict value.
 
void onBeginElement ()
 Formats the begin of a sequence element.
 
void onBeginMember (const char *name)
 Formats the begin of a struct member.
 
void onBeginParse (Composer &composer)
 Begin to parse to a composer.
 
void onBeginSequence (const char *name, const char *type, const char *id)
 Formats the begin of a sequence.
 
void onBeginStruct (const char *name, const char *type, const char *id)
 Formats the begin of a struct.
 
virtual void onFinishDict ()
 Formats the end of a dict.
 
virtual void onFinishDictElement ()
 Formats the end of a dict element.
 
virtual void onFinishDictKey ()
 Formats the end of a dict key.
 
virtual void onFinishDictValue ()
 Formats the end of a dict value.
 
void onFinishElement ()
 Formats the end of a sequence element.
 
void onFinishMember ()
 Formats the end of a struct member.
 
void onFinishSequence ()
 Formats the end of a sequence.
 
void onFinishStruct ()
 Formats the end of a struct.
 
void onParse ()
 Parse until composer completes.
 
bool onParseSome ()
 Returns true if composer completes, false if no more data available.