Hi, On Friday, September 23, 2011 7:10:48 PM UTC-7, Bob Dean wrote:
The BOOST_SERIALIZATION_NVP macro is shorthand for the boost::serialization::make_nvp(string name,object) template function. Easiest thing would be to call it directly:
oa << boost::serialization::make_nvp("quantity_si_length",q);
sorry if my question was not understood. It is fine (and necessary to have
the element named "q"), what I want is that in the class description some
information about the type itself, instead of class_id = 0. Such to produce:
<*q* class_id="0" class_name = "*quantity_si_length*" tracking_level="1"
version="0" object_id="_0">
<value>5</value>
*q*>
note that I am fine with the "q" name (either using BOOST_..._NV or
make_nvp), I want some (automatic) description of the type not the element.
Thank you,
Alfredo
On Sep 23, 2011, at 8:50 PM, alfC
Hi, I am serializing a bunch of object that contains boost.units quantities. Boost.Units provides serialization for quantities already. By default, the output file looks ok but I would like to add a class name to the object description.
Current, serializing quantitysi::length q produces:
<q class_id="0" tracking_level="1" version="0" object_id="_0"> <value>5</value> </q>
Which doesn't give any information about the quantity at hand, not even for the human reading it. So, I tried to use BOOST_CLASS_EXPORT_GUID to register a name for the serialized class, but it is ignored. Ideally I would like to have something like this, with a class_name description for example:
<q class_id="0" class_name = "quantity_si_length" tracking_level="1" version="0" object_id="_0"> <value>5</value> </q>
Is something like this possible? Below is the working code:
#include <fstream> #include
#include #include #include using namespace boost::units; BOOST_CLASS_EXPORT_GUID(quantitysi::length, "quantity_si_length") //ignored int main(int argc, char *argv[]) { std::ofstream ofs("filename.xml"); boost::archive::xml_oarchive oa(ofs);
quantitysi::length q = 5.*si::meter;
oa << BOOST_SERIALIZATION_NVP(q);
return 0; }
_______________________________________________ Boost-users mailing list Boost...@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list Boost...@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users