|
PLaSK library
|
Object of this class help produce valid XML documents. More...
#include <plask/utils/xml/writer.hpp>
Classes | |
| class | Element |
| Represent single XML element connected with writer. More... | |
| struct | Output |
| Base class for output (stream). More... | |
Public Member Functions | |
| XMLWriter (std::ostream &out, std::size_t indentation=2) | |
Construct XML writer which will write content to given out stream. | |
| XMLWriter (const std::string &file_name, std::size_t indentation=2) | |
| Construct XML writer which will write content to file with given name. | |
| XMLWriter (std::FILE *cfile, std::size_t indentation=2) | |
| Construct XML writer which will write content to given C file. | |
| XMLWriter (Output *out, std::size_t indentation=2) | |
Construct XML writer which will write content to given out. | |
| ~XMLWriter () | |
| Delete output object. | |
| void | writeHeader () |
| Append to stream XML document header. | |
| template<typename name_t > | |
| Element | addElement (name_t &&name) |
| Append element/tag to stream. | |
| template<typename name_t > | |
| Element | addTag (name_t &&name) |
| Append element/tag to stream. | |
| template<typename text_t > | |
| void | writeText (text_t &&text) |
| Write text content for the current element. | |
| template<typename text_t > | |
| void | writeCDATA (text_t &&cdata) |
| Write CDATA for the current element. | |
| void | indent () |
| Write spaces to the current indentation level. | |
| Element * | getCurrent () |
| Get current element. | |
Object of this class help produce valid XML documents.
It holds std output stream and helps format valid XML data written to this stream.
Example:
Definition at line 46 of file writer.hpp.
| plask::XMLWriter::XMLWriter | ( | std::ostream & | out, |
| std::size_t | indentation = 2 |
||
| ) |
Construct XML writer which will write content to given out stream.
| out | output stream which will be used as destination to XML content, will be not closed by this writer |
| indentation | indentation for each tag level |
Definition at line 210 of file writer.cpp.
| plask::XMLWriter::XMLWriter | ( | const std::string & | file_name, |
| std::size_t | indentation = 2 |
||
| ) |
Construct XML writer which will write content to file with given name.
| file_name | name of file which will be used as destination to XML content |
| indentation | indentation for each tag level |
Definition at line 213 of file writer.cpp.
| plask::XMLWriter::XMLWriter | ( | std::FILE * | cfile, |
| std::size_t | indentation = 2 |
||
| ) |
Construct XML writer which will write content to given C file.
Writer will not close given descriptor.
| cfile | opened, C file descriptor, writer will not close it |
| indentation | indentation for each tag level |
Definition at line 217 of file writer.cpp.
| plask::XMLWriter::XMLWriter | ( | Output * | out, |
| std::size_t | indentation = 2 |
||
| ) |
Construct XML writer which will write content to given out.
| out | output which will be used as destination to XML content, will be delete (with delete operator) by writer destructor |
| indentation | indentation for each tag level |
Definition at line 221 of file writer.cpp.
|
inline |
Delete output object.
Definition at line 324 of file writer.hpp.
Append element/tag to stream.
| name | tag name |
Definition at line 338 of file writer.hpp.
Append element/tag to stream.
| name | tag name |
Definition at line 346 of file writer.hpp.
|
inline |
Get current element.
nullptr if there are no elements (root was not open jet or was already closed) Definition at line 379 of file writer.hpp.
|
inline |
Write spaces to the current indentation level.
Definition at line 371 of file writer.hpp.
Write CDATA for the current element.
| cdata | data to write |
Definition at line 363 of file writer.hpp.
|
inline |
Append to stream XML document header.
Definition at line 327 of file writer.hpp.
Write text content for the current element.
| text | text to write |
Definition at line 353 of file writer.hpp.