29 #ifndef Pt_Xml_XmlWriter_h
30 #define Pt_Xml_XmlWriter_h
32 #include <Pt/Xml/Api.h>
33 #include <Pt/String.h>
34 #include <Pt/TextStream.h>
42 PT_XML_API
void xmlEncode(std::basic_ostream<Pt::Char>& os,
const Pt::Char* str, std::size_t n);
45 PT_XML_API
void xmlEncode(std::basic_ostream<Pt::Char>& os,
const Pt::Char* str);
48 inline void xmlEncode(std::basic_ostream<Pt::Char>& os,
const Pt::String& str);
103 void reset(std::basic_ostream<Char>& os);
124 const Pt::Char* encoding, std::size_t encodingSize,
bool standalone =
false);
128 void writeStartDocument(
const Pt::String& version,
const Pt::String& encoding,
bool standalone =
false);
148 void writeStartElement(
const Pt::String& localName);
153 const Char* localName, std::size_t localNameSize);
162 const Char* value, std::size_t valueSize);
171 const Char* localName, std::size_t localNameSize,
172 const Char* value, std::size_t valueSize);
184 void writeEmptyElement(
const Pt::String& localName);
189 const Char* localName, std::size_t localNameSize);
213 void writeEntityReference(
const Pt::String& name);
234 const Pt::Char* data, std::size_t dataSize);
249 class XmlWriterImpl* _impl;
253 inline void xmlEncode(std::basic_ostream<Pt::Char>& os,
const Pt::String& str)
262 encoding.
c_str(), encoding.
size(), standalone);
347 #endif // Pt_Xml_XmlWriter_h
Core module.
Definition: pt-gfx-images.dox:14
std::size_t depth() const
Returns the current element depth.
size_type size() const
Returns the length of the string.
Definition: String.h:239
void writeCData(const Pt::Char *text, std::size_t n)
Writes text as a CDATA section.
void setQuote(Pt::Char ch)
Sets the quotation character.
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::Char *localName, std::size_t localNameSize)
Writes an empty XML element.
void setIndent(const Pt::String &indent)
Sets the indentation string.
const Pt::Char * c_str() const
Returns a null terminated C string.
Definition: String.h:264
void writeEndDocument()
Finishes the document and closes all open elements.
void writeEndTag(const Pt::Char *name)
Writes an end tag.
void writeStartTag(const Pt::Char *name)
Writes a start tag.
void writeEndElement()
Closes the last XML element.
Writes XML to a text stream.
Definition: XmlWriter.h:53
void writeAttribute(const Char *localName, std::size_t localNameSize, const Char *value, std::size_t valueSize)
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.
Unicode character type.
Definition: String.h:67
void writeCharacters(const Pt::Char *text, std::size_t n)
Writes text as element content.
bool isFormatting() const
Returns true if indentation should be written.
void setDefaultNamespace(const Pt::String &ns)
Sets the default namespace for the child elemnts.
void setNamespacePrefix(const Pt::String &prefix, const Pt::String &ns)
Sets the namespace for the child elemnts.
void writeEntityReference(const Pt::Char *name, std::size_t n)
Writes an entitiy reference.
XmlWriter(std::basic_ostream< Char > &os)
Constructs with output stream.
void writeStartElement(const Pt::Char *localName, std::size_t localNameSize)
Writes a start element.
const Pt::String & indent() const
Returns the indentation string.
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.
std::basic_ostream< Char > * output()
Returns the output stream or a nullptr if none was set.
void writeStartElement(const Char *ns, std::size_t nsSize, const Char *localName, std::size_t localNameSize)
Writes a start element.
Pt::Char quote() const
Returns the quotation character.
void setFormatting(bool value)
Indicates wether indentation should be written.
void reset(std::basic_ostream< Char > &os)
Clears the writer state and output.
Unicode capable basic_string.
Definition: String.h:43
void writeProcessingInstruction(const Pt::Char *target, std::size_t targetSize, const Pt::Char *data, std::size_t dataSize)
Writes a processing instruction.
void reset()
Clears the writer state and output.
void writeDocType(const Pt::Char *dtd, std::size_t n)
Writes a DOCTYPE declaration.
void writeComment(const Pt::Char *text, std::size_t n)
Writes a comment.