|
Boost : |
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2004-09-28 11:00:50
"Caleb Epstein" <caleb.epstein_at_[hidden]> wrote in message
news:989aceac04092808315b0da3e3_at_mail.gmail.com...
> On Mon, 27 Sep 2004 09:58:04 -0700, Robert Ramey <ramey_at_[hidden]> wrote:
> > 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);
>
> Might I also suggest a similar interface which allows the caller to
> specify the name to go with the value:
>
> BOOST_SERIALIZATION_NAME_VALUE ("variable", m_variable);
>
> I'm sure many folks add prefix m_ or trailing underscore warts to
> member names, and IMHO these don't really have any business being in
> the serialized form of the object.
In this case there's no need for a macro. Just use:
using boost::serialization::make_nvp;
ar & make_nvp( "variable", m_variable);
What would be useful (for me ) would be a macro that used a user defined
default for the prefix. We use CamelCase type names here.
#define BOOST_SERIALIZATION_NVP_PREFIX_DEFAULT m
ar & BOOST_SERIALIZATION_NVP_PREFIXED( Variable );
Which would be equivalent to:
ar & make_nvp( "Variable", mVariable);
But, looking at it now, the non-macro version is more readable, flexible and
fewer characters to boot.
Jeff F
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk