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);
69 bool isFormatting()
const;
73 void setFormatting(
bool value);
103 void reset(std::basic_ostream<Char>& os);
107 std::basic_ostream<Char>* output();
111 std::size_t depth()
const;
115 void setDefaultNamespace(
const Pt::String& ns);
123 void writeStartDocument(
const Pt::Char* version, std::size_t versionSize,
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);
132 void writeEndDocument();
136 void writeDocType(
const Pt::Char* dtd, std::size_t n);
144 void writeStartElement(
const Pt::Char* localName, std::size_t localNameSize);
148 void writeStartElement(
const Pt::String& localName);
152 void writeStartElement(
const Char* ns, std::size_t nsSize,
153 const Char* localName, std::size_t localNameSize);
161 void writeAttribute(
const Char* localName, std::size_t localNameSize,
162 const Char* value, std::size_t valueSize);
170 void writeAttribute(
const Char* ns, std::size_t nsSize,
171 const Char* localName, std::size_t localNameSize,
172 const Char* value, std::size_t valueSize);
180 void writeEmptyElement(
const Pt::Char* localName, std::size_t localNameSize);
184 void writeEmptyElement(
const Pt::String& localName);
188 void writeEmptyElement(
const Char* ns, std::size_t nsSize,
189 const Char* localName, std::size_t localNameSize);
197 void writeEndElement();
201 void writeCharacters(
const Pt::Char* text, std::size_t n);
209 void writeEntityReference(
const Pt::Char* name, std::size_t n);
213 void writeEntityReference(
const Pt::String& name);
217 void writeCData(
const Pt::Char* text, std::size_t n);
225 void writeComment(
const Pt::Char* text, std::size_t n);
233 void writeProcessingInstruction(
const Pt::Char* target, std::size_t targetSize,
234 const Pt::Char* data, std::size_t dataSize);
242 void writeStartTag(
const Pt::Char* name);
246 void writeEndTag(
const Pt::Char* name);
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
void writeAttribute(const Char *localName, std::size_t localNameSize, const Char *value, std::size_t valueSize)
Writes an XML attribute.
void writeCData(const Pt::Char *text, std::size_t n)
Writes text as a CDATA section.
size_type size() const
Returns the length of the string.
Definition: String.h:239
void writeEmptyElement(const Pt::Char *localName, std::size_t localNameSize)
Writes an empty XML element.
Writes XML to a text stream.
Definition: XmlWriter.h:52
const Pt::Char * c_str() const
Returns a null terminated C string.
Definition: String.h:264
void writeStartElement(const Pt::Char *localName, std::size_t localNameSize)
Writes a start element.
Unicode character type.
Definition: String.h:66
Unicode capable basic_string.
Definition: String.h:42
void writeCharacters(const Pt::Char *text, std::size_t n)
Writes text as element content.
void writeEntityReference(const Pt::Char *name, std::size_t n)
Writes an entitiy reference.
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 writeProcessingInstruction(const Pt::Char *target, std::size_t targetSize, const Pt::Char *data, std::size_t dataSize)
Writes a processing instruction.
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.