cxxtools::xml::XmlFormatter Class Reference

Serialize objects or object data to XML. More...

#include <cxxtools/xml/xmlformatter.h>

Inheritance diagram for cxxtools::xml::XmlFormatter:
cxxtools::Formatter

Public Member Functions

 XmlFormatter ()
 Construct a serializer without initializing the serializer for writing.
 XmlFormatter (std::ostream &os)
 Construct a serializer writing to a byte stream.
 XmlFormatter (XmlWriter *writer)
 Construct a serializer writing to the given XmlWriter object.
 ~XmlFormatter ()
 Destructor.
void attach (std::ostream &os)
 Opens this serializer for writing into the given stream.
void attach (XmlWriter &writer)
 Opens this serializer for writing into the given XmlWriter object.
void detach ()
 Detaches the currently set writer from this object.
void flush ()
void useXmlDeclaration (bool sw)
bool useXmlDeclaration () const
void useIndent (bool sw)
bool useIndent () const
void useEndl (bool sw)
bool useEndl () const
void useAttributes (bool sw)
bool useAttributes () const
void addValueString (const std::string &name, const std::string &type, const cxxtools::String &value)
void beginArray (const std::string &name, const std::string &type)
void finishArray ()
void beginObject (const std::string &name, const std::string &type)
void beginMember (const std::string &name)
void finishMember ()
void finishObject ()
void finish ()
- Public Member Functions inherited from cxxtools::Formatter
virtual ~Formatter ()
virtual void addValueStdString (const std::string &name, const std::string &type, const std::string &value)
virtual void addValueBool (const std::string &name, const std::string &type, bool value)
virtual void addValueInt (const std::string &name, const std::string &type, int_type value)
virtual void addValueUnsigned (const std::string &name, const std::string &type, unsigned_type value)
virtual void addValueFloat (const std::string &name, const std::string &type, long double value)
virtual void addNull (const std::string &name, const std::string &type)

Additional Inherited Members

- Public Types inherited from cxxtools::Formatter
typedef long int_type
typedef unsigned long unsigned_type
- Protected Member Functions inherited from cxxtools::Formatter
 Formatter ()

Detailed Description

Serialize objects or object data to XML.

Thic class performs XML serialization of a single object or object data.

Constructor & Destructor Documentation

cxxtools::xml::XmlFormatter::XmlFormatter ( )

Construct a serializer without initializing the serializer for writing.

The serializer can be "opened" for writing by calling method attach().

cxxtools::xml::XmlFormatter::XmlFormatter ( std::ostream &  os)

Construct a serializer writing to a byte stream.

The serializer will write the objects as XML with UTF-8 encoding to the output stream.

cxxtools::xml::XmlFormatter::XmlFormatter ( XmlWriter writer)

Construct a serializer writing to the given XmlWriter object.

The serializer will write the objects to the given XmlWriter object. This class will not free the given XmlWriter object. The caller is responsible to free it if needed.

cxxtools::xml::XmlFormatter::~XmlFormatter ( )

Destructor.

Member Function Documentation

void cxxtools::xml::XmlFormatter::addValueString ( const std::string &  name,
const std::string &  type,
const cxxtools::String value 
)
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::attach ( std::ostream &  os)

Opens this serializer for writing into the given stream.

The serializer will write the objects as XML with UTF-8 encoding to the output stream.

This method does not have to be called if this XmlSerializer object was constructed using the constructor that takes an ostream or XmlWriter object. If this method is called anyway or called twice an std::logic_error is thrown.

void cxxtools::xml::XmlFormatter::attach ( XmlWriter writer)

Opens this serializer for writing into the given XmlWriter object.

The serializer will write the objects to the given XmlWriter object.

This method does not have to be called if this XmlSerializer object was constructed using the constructor that takes an ostream or XmlWriter object. If this method is called anyway or called twice an std::logic_error is thrown.

This class will not free the given XmlWriter object. The caller is responsible to free it if needed.

void cxxtools::xml::XmlFormatter::beginArray ( const std::string &  name,
const std::string &  type 
)
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::beginMember ( const std::string &  name)
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::beginObject ( const std::string &  name,
const std::string &  type 
)
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::detach ( )

Detaches the currently set writer from this object.

Before detaching the writer, the underlaying stream is flushed. If there is no currently set writer, nothing happens.

void cxxtools::xml::XmlFormatter::finish ( )
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::finishArray ( )
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::finishMember ( )
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::finishObject ( )
virtual

Implements cxxtools::Formatter.

void cxxtools::xml::XmlFormatter::flush ( )
void cxxtools::xml::XmlFormatter::useAttributes ( bool  sw)
inline
bool cxxtools::xml::XmlFormatter::useAttributes ( ) const
inline
void cxxtools::xml::XmlFormatter::useEndl ( bool  sw)
inline
bool cxxtools::xml::XmlFormatter::useEndl ( ) const
inline
void cxxtools::xml::XmlFormatter::useIndent ( bool  sw)
inline
bool cxxtools::xml::XmlFormatter::useIndent ( ) const
inline
void cxxtools::xml::XmlFormatter::useXmlDeclaration ( bool  sw)
inline
bool cxxtools::xml::XmlFormatter::useXmlDeclaration ( ) const
inline

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