|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-04-21 01:29:14
Hi Nicola,
Nicola Santi wrote:
> As I wrote in previous posts I do not write in english very well, so I
> could have made some misunderstandings. I try to clarify:
>
> > I'm afraid I don't like this approach. You have 3 ways to serialize an
> > object:
> > 1. Call operator <<
> > 2. Call put_oject
> > 3. Call serialize on object directly.
> >
> > That's quite confusing.
>
> It is NOT possible to store objects using << operator: this operator
> would store only an unsigned integer with a virtual memory address, not
> an object.
Ok, probably I wasn't clear. From my looking at code it appears that
1. For any given type only one method above makes sense
2. All methods above will be valid from compiler's POV.
It means that programmer has to consider what way is suitable in each case,
and that's probably not needed.
[...]
> So the two methods respond to two difference persistence needs and I'am
> sure they should still remain in eternity: so, do you suggest to add
> also a single method that use parameter or a single template method that
> call serialize() for reference and put_object() for pointers?
I think somethink like the former would be ok. You can
check if a type is polymorphic (there's is_polymorphic type trait). If it
is, you surely need to write type (i.e. use put_object). Otherwise, call
to 'serialize' will do. That's for pointers. And for references --- just
calling 'serialize' is reasonable.
I believe this is close to what Robert's library is doing.
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk