XmlWriter Class Reference

#include <Pt/Xml/XmlWriter.h>

Writes XML to a text stream.

Public Member Functions

 XmlWriter ()
 Constructor.
 
 XmlWriter (std::basic_ostream< Char > &os)
 Constructs with output stream.
 
 ~XmlWriter ()
 Destructor.
 
std::size_t depth () const
 Returns the current element depth.
 
const Pt::Stringindent () const
 Returns the indentation string.
 
bool isFormatting () const
 Returns true if indentation should be written.
 
std::basic_ostream< Char > * output ()
 Returns the output stream or a nullptr if none was set.
 
Pt::Char quote () const
 Returns the quotation character.
 
void reset ()
 Clears the writer state and output. More...
 
void reset (std::basic_ostream< Char > &os)
 Clears the writer state and output. More...
 
void setDefaultNamespace (const Pt::String &ns)
 Sets the default namespace for the child elemnts.
 
void setFormatting (bool value)
 Indicates wether indentation should be written.
 
void setIndent (const Pt::String &indent)
 Sets the indentation string.
 
void setNamespacePrefix (const Pt::String &prefix, const Pt::String &ns)
 Sets the namespace for the child elemnts.
 
void setQuote (Pt::Char ch)
 Sets the quotation character.
 
void writeAttribute (const Char *localName, std::size_t localNameSize, const Char *value, std::size_t valueSize)
 Writes an XML attribute.
 
void writeAttribute (const Pt::String &localName, const Pt::String &value)
 Writes an XML attribute.
 
void writeAttribute (const Char *ns, std::size_t nsSize, const Char *localName, std::size_t localNameSize, const Char *value, std::size_t valueSize)
 Writes an XML attribute.
 
void writeAttribute (const Pt::String &ns, const Pt::String &localName, const Pt::String &value)
 Writes an XML attribute.
 
void writeCData (const Pt::Char *text, std::size_t n)
 Writes text as a CDATA section.
 
void writeCData (const Pt::String &text)
 Writes text as a CDATA section.
 
void writeCharacters (const Pt::Char *text, std::size_t n)
 Writes text as element content.
 
void writeCharacters (const Pt::String &text)
 Writes text as element content.
 
void writeComment (const Pt::Char *text, std::size_t n)
 Writes a comment.
 
void writeComment (const Pt::String &text)
 Writes a comment.
 
void writeDocType (const Pt::Char *dtd, std::size_t n)
 Writes a DOCTYPE declaration.
 
void writeDocType (const Pt::String &dtd)
 Writes a DOCTYPE declaration.
 
void writeEmptyElement (const Pt::Char *localName, std::size_t localNameSize)
 Writes an empty XML element.
 
void writeEmptyElement (const Pt::String &localName)
 Writes an empty XML element.
 
void writeEmptyElement (const Char *ns, std::size_t nsSize, const Char *localName, std::size_t localNameSize)
 Writes an empty XML element.
 
void writeEmptyElement (const Pt::String &ns, const Pt::String &localName)
 Writes an empty XML element.
 
void writeEndDocument ()
 Finishes the document and closes all open elements.
 
void writeEndElement ()
 Closes the last XML element.
 
void writeEndTag (const Pt::Char *name)
 Writes an end tag.
 
void writeEntityReference (const Pt::Char *name, std::size_t n)
 Writes an entitiy reference.
 
void writeEntityReference (const Pt::String &name)
 Writes an entitiy reference.
 
void writeProcessingInstruction (const Pt::Char *target, std::size_t targetSize, const Pt::Char *data, std::size_t dataSize)
 Writes a processing instruction.
 
void writeProcessingInstruction (const Pt::String &text, const Pt::String &data)
 Writes a processing instruction.
 
void writeStartDocument (const Pt::Char *version, std::size_t versionSize, const Pt::Char *encoding, std::size_t encodingSize, bool standalone=false)
 Writes an XML declaration.
 
void writeStartDocument (const Pt::String &version, const Pt::String &encoding, bool standalone=false)
 Writes an XML declaration.
 
void writeStartElement (const Pt::Char *localName, std::size_t localNameSize)
 Writes a start element.
 
void writeStartElement (const Pt::String &localName)
 Writes a start element.
 
void writeStartElement (const Char *ns, std::size_t nsSize, const Char *localName, std::size_t localNameSize)
 Writes a start element.
 
void writeStartElement (const Pt::String &ns, const Pt::String &localName)
 Writes a start element.
 
void writeStartTag (const Pt::Char *name)
 Writes a start tag.
 

Member Function Documentation

void reset ( )

Ther output stream is removed and the writer state is reset to write a new document. The formatting options are not changed.

void reset ( std::basic_ostream< Char > &  os)

Ther output stream is set and the writer state is reset to write a new document. The formatting options are not changed.