[serialization] documentation for xml archive usage

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

Hi Christoph,
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>. ... 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?
You can also use ar & BOOST_SERIALIZATION_NVP("my_member")
Can I choose an arbitrary tag for each variable or is it supposed to be consistent for all variables of a specific type?
I believe each variable of each class can have arbitrary name.
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?
That's right. HTH, Volodya

Hi Vladimir, On Mon, Sep 27, 2004 at 03:21:17PM +0400, Vladimir Prus wrote:
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?
You can also use
ar & BOOST_SERIALIZATION_NVP("my_member")
Ah, now I found it in the docs! I had searched the table of contents for xml and nvp but the non abbreviated entry "Name-Value Pairs" escaped me. Since you mentioned above macro I decided to look again... Thanks! Regards Christoph -- http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html
participants (2)
-
Christoph Ludwig
-
Vladimir Prus