The zen::Xml namespace. More...
Classes | |
class | XmlOut |
Proxy class to conveniently convert user data into XML structure. More... | |
class | XmlIn |
Proxy class to conveniently convert XML structure to user data. More... | |
class | XmlElement |
An XML element. More... | |
class | XmlDoc |
The complete XML document. More... | |
struct | XmlError |
Exception base class for zen::Xml. More... | |
struct | XmlFileError |
Exception thrown due to failed file I/O. More... | |
struct | XmlParsingError |
Exception thrown due to an XML parsing error. More... | |
Functions | |
template<class String > | |
void | load (const String &filename, XmlDoc &doc) |
Load XML document from a file. | |
template<class String > | |
void | save (const XmlDoc &doc, const String &filename, const std::string &lineBreak="\r\n", const std::string &indent=" ") |
Save XML document to a file. | |
template<class T > | |
bool | readStruc (const XmlElement &input, T &value) |
Convert XML element to structured user data. | |
template<class T > | |
void | writeStruc (const T &value, XmlElement &output) |
Convert structured user data into an XML element. | |
template<class T > | |
bool | readText (const std::string &input, T &value) |
Convert text to user data - used by XML elements and attributes. | |
template<class T > | |
void | writeText (const T &value, std::string &output) |
Convert user data into text - used by XML elements and attributes. | |
template<class String > | |
void | saveStream (const std::string &stream, const String &filename) |
Save byte stream to a file. | |
template<class String > | |
std::string | loadStream (const String &filename) |
Load byte stream from a file. | |
std::string | serialize (const XmlDoc &doc, const std::string &lineBreak="\r\n", const std::string &indent=" ") |
Save XML document as a byte stream. | |
void | parse (const std::string &stream, XmlDoc &doc) |
Load XML document from a byte stream. |
The zen::Xml namespace.
void zen::load | ( | const String & | filename, |
XmlDoc & | doc | ||
) |
Load XML document from a file.
Convenience function that does nothing more than calling loadStream() and parse().
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
filename | Input file name |
doc | The XML document to load |
XmlFileError | |
XmlParsingError |
std::string zen::loadStream | ( | const String & | filename | ) |
Load byte stream from a file.
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
filename | Input file name |
XmlFileError |
void zen::parse | ( | const std::string & | stream, |
XmlDoc & | doc | ||
) |
Load XML document from a byte stream.
stream | Input byte stream |
doc | Output XML document |
XmlParsingError |
bool zen::readStruc | ( | const XmlElement & | input, |
T & | value | ||
) |
Convert XML element to structured user data.
input | The input XML element. |
value | Conversion target value. |
bool zen::readText | ( | const std::string & | input, |
T & | value | ||
) |
Convert text to user data - used by XML elements and attributes.
input | Input text. |
value | Conversion target value. |
void zen::save | ( | const XmlDoc & | doc, |
const String & | filename, | ||
const std::string & | lineBreak = "\r\n" , |
||
const std::string & | indent = " " |
||
) |
Save XML document to a file.
Convenience function that does nothing more than calling serialize() and saveStream().
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
doc | The XML document to save |
filename | Output file name |
lineBreak | Line break, default: carriage return + new line |
indent | Indentation, default: four space characters |
XmlFileError |
void zen::saveStream | ( | const std::string & | stream, |
const String & | filename | ||
) |
Save byte stream to a file.
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
stream | Input byte stream |
filename | Output file name |
XmlFileError |
std::string zen::serialize | ( | const XmlDoc & | doc, |
const std::string & | lineBreak = "\r\n" , |
||
const std::string & | indent = " " |
||
) |
Save XML document as a byte stream.
doc | Input XML document |
lineBreak | Line break, default: carriage return + new line |
indent | Indentation, default: four space characters |
void zen::writeStruc | ( | const T & | value, |
XmlElement & | output | ||
) |
Convert structured user data into an XML element.
value | The value to be converted. |
output | The output XML element. |
void zen::writeText | ( | const T & | value, |
std::string & | output | ||
) |
Convert user data into text - used by XML elements and attributes.
value | The value to be converted. |
output | Output text. |