Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-09-27 11:58:04

>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

That is the intent.

>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

>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?

Oh - no. Use the variable name for the tag not the name of the type. This
is encouraged by usage of the idiom

ar & BOOST_SERIALIZATION_NVP(my_variable);

>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?

And all other archives as well - with no extra runtime overhead (assuming a
decent optimizing compiler)

There a section Reference:Class Serialization:Serialization
Wrappers:Name-Value pairs where this is described. Perhaps this isn't
obvious from contents.

>May I suggest that a section explaining the issues with xml archives be
>added to the docs before the 1.32 release?

Yes you may.

Boost list run by bdawes at, gregod at, cpdaniel at, john at