|
Boost : |
From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-09-27 06:09:56
Hi,
I am using the Boost Serialization library with the text archive
implementation in my project and it works quite well. Robert did
a very good job - thanks!
For some reason I am considering switching to the xml archive
implementation. However, this triggers a BOOST_STATIC_ASSERT in
basic_xml_oarchive<Archive>::save_override<T>(const T&, BOOST_PFTO int).
The implementation insists that all serialized types be wrapped in a
nvp<T>.
I think I understand more or less why this is necessary - the xml
archive implementation generates the xml name tags from the
information stored in the nvp wrapper. But I couldn't find an
explanation in the docs what special steps a user is supposed to take
if the data shall be serialized into an xml archive. (The only hint
that xml archives need special care that I found was the description
of the header file nvp.hpp libs/serialization/doc/headers.html: "To
associate a name tag with a serializable object. This is necessary to
properly render an xml archive which includes the object name." BTW,
this webpage claims nvp.hpp is in boost/archive, but in fact it is in
boost/serialization.)
Do I need to write
ar & nvp<MyMemberType>("my_member_tag", this->my_member);
in my serialization functions for every variable I want to
(de-)serialize? Can I choose an arbitrary tag for each variable or is
it supposed to be consistent for all variables of a specific type? Am
I correct to assume that the code will still work if I serialize into
a "normal" text archive and the nvp will essentially be ignored?
I guess I could find my answers by some trial and error and digging
through the test cases. But since I probably won't be the only user
looking for this information may I suggest that a section explaining
the issues with xml archives be added to the docs before the 1.32
release?
Thanks
Christoph
-- http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk