xml_pack
and xml_unpack
generate XML serialisations of
C++ objects. The exact mapping between C++ types and XML was inspired
by .Net's serialisation library. In particular, container sequences
will have elements named by the type of the element, so a
vector<double>
will be expressed as an XL sequence of
<double>
tags. For deserialisation, all tags are optional, ie
if a tag is not present in the XML file, then the corresponding C++
member is not updated. Any tags present in the XML file not
corresponding to a C++ member will be ignored. Most usefully, this
means that by setting a default initialiser for struct members, schema
migration can easily be handled and a bnackward compatible fashion.
This has advantages in creating (let's say) configuration files, in that the output is human editable, and handles schema migration easily. As an example of this, the Minsky project (https://minsky.sf.net) uses this descriptor for generating the .mky and .rvl files used to store model data.
xsd_generate
creates an XML schema file (.xsd) corresponding
the C++ schema object, that can be used in documentation and XML
linting tools. The xsd file marks everything as mandatory, however
xml\_unpack
actually treats every attribute as optional.
It is usual (though not necessary) to only serialise public members of classes.