Proxy class to conveniently convert user data into XML structure. More...
#include <bind.h>
Public Member Functions | |
XmlOut (XmlDoc &doc) | |
Construct an output proxy for an XML document. More... | |
XmlOut (XmlElement &element) | |
Construct an output proxy for a single XML element. More... | |
template<class String > | |
XmlOut | operator[] (const String &name) const |
Retrieve a handle to an XML child element for writing. More... | |
template<class T > | |
void | operator() (const T &value) |
Write user data to the underlying XML element. More... | |
template<class String , class T > | |
void | attribute (const String &name, const T &value) |
Write user data to an XML attribute. More... | |
XmlElement & | ref () |
Return a reference to the underlying Xml element. | |
Proxy class to conveniently convert user data into XML structure.
zen::XmlOut::XmlOut | ( | XmlDoc & | doc | ) |
Construct an output proxy for an XML document.
Output:
<?xml version="1.0" encoding="UTF-8"?> <Root> <elem1>1</elem1> <elem2>2</elem2> <elem3>-3</elem3> </Root>
zen::XmlOut::XmlOut | ( | XmlElement & | element | ) |
Construct an output proxy for a single XML element.
void zen::XmlOut::attribute | ( | const String & | name, |
const T & | value | ||
) |
Write user data to an XML attribute.
This conversion requires a specialization of zen::writeText() for type T.
Output:
<?xml version="1.0" encoding="UTF-8"?> <Root> <elem attr1="1" attr2="2" attr3="-3"/> </Root>
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
T | String-convertible user data type: e.g. any string-like type, all built-in arithmetic numbers |
void zen::XmlOut::operator() | ( | const T & | value | ) |
Write user data to the underlying XML element.
This conversion requires a specialization of zen::writeText() or zen::writeStruc() for type T.
T | User type that is converted into an XML element value. |
XmlOut zen::XmlOut::operator[] | ( | const String & | name | ) | const |
Retrieve a handle to an XML child element for writing.
The child element will be created if it is not yet existing.
String | Arbitrary string-like type: e.g. std::string, wchar_t*, char[], wchar_t, wxString, MyStringClass, ... |
name | The name of the child element |