A Quick Sample
Given the following C++ structure...
struct Store
{
int a;
float b;
double c;
};...can one quickly load/save it from a document such as...
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <store> <a>100</a> <b>25.43</b> <c>39.282393</c> </store>
...by this command to load...
ReadXML( "store.xml", aStore );
...and similarily to save...
WriteXML( "store.xml", aStore );
...and this simple defintion of the XML structure itself...
XMLS_Define( Store, "store" ) XMLS_Part( a ) XMLS_Part( b ) XMLS_Part( c ) XMLS_Define_End( Store )
A Larger Structure
The system supports all built-in fundamental types, including strings, and also including STL vectors. More STL types will be added as requested.
Here is a more complete example (ctstring is just a typdef to a std::string, or std::wstring, depending on compiler flags).
struct SubStore
{
bool a;
ctstring b;
};
struct Store
{
int a;
float b;
double c;
std::vector<unsigned> d;
SubStore e;
};The XML Declaration.
XMLS_Define( Store, "store" )
XMLS_Part( a )
XMLS_Part( b )
XMLS_Part( c )
XMLS_Part( d )
XMLS_SubPart( e )
XMLS_Define_End( Store )
XMLS_Define( SubStore, "substore" )
XMLS_PartDef( a, true )
XMLS_PartDef( b, ctstring( CHAR_T("Hello") ) )
XMLS_Define_End( SubStore )
A sample file (written from the system). Note that vectors are supported by using multiple elements with the same name.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<store>
<a>100</a>
<b>25.430000305175781</b>
<c>39.282392999999999</c>
<d>5</d>
<d>17</d>
<d>10238</d>
<e>
<a>0</a>
<b>Howdy</b>
</e>
</store>