Boost logo

Boost :

From: Nicola Santi (nicola.santi_at_[hidden])
Date: 2003-04-19 06:11:00


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.

serialize() method is used for objects on the stacks, like in the example:

                       Widget widget;
                        ...
                       widget.serialize(archive);

put_object() is used for objects that need dynamic creation (like ones
allocated on the heap). See the example:

                      Widget* pWidget = new Widget();
                       ...
                      archive.put_object(pWidget);

While serialize (in the first example) put in the archive only Widget
object content (fields, an so), the put_object() store also the class
information to dynamic recreate a pointer during archive reading.

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?

> OK, short name will help with the space issue. But still, lookup up that
> short name will take time.

Ok, I think I've understand the point. I'll work on it.

Thank you.
N.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk