24#ifndef _XMLWRITER_HPP_
25#define _XMLWRITER_HPP_
30#include "boost/shared_ptr.hpp"
31#include "boost/iostreams/positioning.hpp"
32#include "boost/iostreams/filter/counter.hpp"
57 StyleFlag_AttributesOnMultipleLines = 0x04
64 virtual void update(
const std::string& output) = 0;
76 : initialStyle(0), indentationStep(2), outputObserver(0)
84 void add(
const std::string& name,
const double& value);
85 void add(
const std::string& name,
const int& value);
88 inline void add(
const std::string& name,
const T& value)
90 push_back(make_pair(name, boost::lexical_cast<std::string>(value)));
121 void characters(
const std::string& text,
bool autoEscape =
true);
166 : boost::iostreams::dual_use,
167 boost::iostreams::filter_tag,
168 boost::iostreams::multichar_tag,
169 boost::iostreams::optimally_buffered_tag
177 template<
typename Source>
180 std::streamsize result = boost::iostreams::read(src, s, n);
187 template<
typename Sink>
190 std::streamsize result = boost::iostreams::write(snk, s, n);
vector of name/value pairs to be written as XML attributes
void add(const std::string &name, const int &value)
void add(const std::string &name, const T &value)
void add(const std::string &name, const double &value)
interface to allow outside observation of data sent to output stream
virtual ~OutputObserver()
virtual void update(const std::string &output)=0
The XMLWriter class provides simple, tag-level XML syntax writing.
void characters(const std::string &text, bool autoEscape=true)
writes character data; autoEscape writes reserved XML characters in the input text in their escaped f...
void startElement(const std::string &name, const Attributes &attributes=Attributes(), EmptyElementTag emptyElementTag=NotEmptyElement)
writes element start tag
void endElement()
writes element end tag
stream_offset positionNext() const
returns stream position of next element start tag
void popStyle()
pops the style stack
boost::iostreams::stream_offset stream_offset
XMLWriter & operator=(const XMLWriter &)
XMLWriter(std::ostream &os, const Config &config=Config())
constructor
void processingInstruction(const std::string &name, const std::string &data)
writes a processing instruction
boost::shared_ptr< Impl > impl_
EmptyElementTag
tag for indicating an empty element
XMLWriter(const XMLWriter &)
stream_offset position() const
returns current stream position
void pushStyle(unsigned int flags)
pushes style flags onto the internal style stack
basic_charcounter(int first_char=0)
boost::iostreams::stream_offset chars_
boost::iostreams::stream_offset characters() const
std::streamsize optimal_buffer_size() const
std::streamsize write(Sink &snk, const char_type *s, std::streamsize n)
std::streamsize read(Source &src, char_type *s, std::streamsize n)
basic_charcounter< char > charcounter
PWIZ_API_DECL std::string encode_xml_id_copy(const std::string &str)
Encodes any characters not suitable in an xml:ID or xml:IDREF with their hexadecimal value,...
PWIZ_API_DECL std::string & encode_xml_id(std::string &str)
Encodes any characters not suitable in an xml:ID or xml:IDREF with their hexadecimal value,...
basic_charcounter< wchar_t > wcharcounter
initial configuration of the XMLWriter
OutputObserver * outputObserver
unsigned int indentationStep
unsigned int initialStyle