|
Boost : |
From: johan.nilsson_at_[hidden]
Date: 2002-02-28 09:52:18
Sorry if repeating what someone else has stated earlier (I find it daunting
to go through each and every post in this discussion). Just throwing out
what's in my head.
To keep as non-intrusive as possible, it would be possible to support
specialized marshallers to support non-default constructors - thereby
allowing legacy objects to be marshalled, e.g.:
on reading:
... gps_position_marshaller::read(T& ar, ...)
{
X par1, par2;
ar >> par1 >> par2;
gps_position* pos = new gps_position(par1, par2);
...
}
Of course, implementing write could be a bit harder while maintaining the
non-intrusive approach (could work if all state was publicliy available
through get() functions).
// Johan
> -----Original Message-----
> From: Persson Jonas [SMTP:Jonas.Persson_at_[hidden]]
> Sent: Thursday, February 28, 2002 3:32 PM
> To: 'boost_at_[hidden]'
> Subject: RE: [boost] Re: Serialization (Persistence) library draft
> submiss ion
>
> > -----Original Message-----
> > From: Peter Dimov [mailto:pdimov_at_[hidden]]
> > Sent: Thursday, February 28, 2002 2:57 PM
> > To: boost_at_[hidden]
> > Subject: Re: [boost] Re: Serialization (Persistence) library draft
> > submission
> >
> >
> > From: "Persson Jonas" <Jonas.Persson_at_[hidden]>
> > > Serialization with a default constructor requirement would be almost
> > > useless.
> >
> > I find your arguments sound in general but this statement is untrue.
>
> It would mean that if I would add serialization to my project I would need
> go
> through all my classes and add a defult constructor and also remove const
> qualifiers
> of the data members I need to save the state of. And then add contracts
> and/or
> error handling to ensure proper use (wich was previously guaranteed by
> construction)
> A lot of unnessessary work that would reduce the robustness of my program.
> It would
> at least make me think twice before I added it.
>
> > > What would be needed is a deserialization constructor and a
> > way to get the
> > > next serialized object witout using operator >>
> >
> > You can't add a serialization constructor to builtins, enums,
> > std:: classes,
> > and third party classes.
>
> True, but would I need to? They already has default construction.
>
> but maybe we should use a trait to select a proper implementation
> of get
>
> template<typename T>
> T get(::boost::iarchive &ar) {
> T t;
> ar >> t;
> return t;
> }
>
> for default constructibel and:
>
> template<typename T>
> T get(::boost::iarchive &ar) {
> return T(ar);
> }
>
> for deserialize constructible.
>
>
> / Jonas
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk