Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

XmlFormatter Class Reference

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

#include <cxxtools/xml/xmlserializer.h>

Inheritance diagram for XmlFormatter:

List of all members.

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 (cxxtools::xml::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 (cxxtools::xml::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 addValue (const std::string &name, const std::string &type, const cxxtools::String &value, const std::string &id)
void addReference (const std::string &name, const cxxtools::String &value)
void beginArray (const std::string &name, const std::string &type, const std::string &id)
void finishArray ()
void beginObject (const std::string &name, const std::string &type, const std::string &id)
void beginMember (const std::string &name)
void finishMember ()
void finishObject ()
void finish ()


Detailed Description

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

Constructor & Destructor Documentation

XmlFormatter (  ) 

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

XmlFormatter ( std::ostream &  os  ) 

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

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

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.


Member Function Documentation

void attach ( std::ostream &  os  ) 

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 attach ( cxxtools::xml::XmlWriter &  writer  ) 

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 detach (  ) 

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

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6