Boost logo

Boost Users :

From: Martin Proulx (mproulx_at_[hidden])
Date: 2005-09-06 14:01:05


Hello,

While using the latest release of boost, I've encountered a few
questions concerning the usage of the serialization library with objects
without default constructors.

Here they are:

1-) How can we construct an instance of a serialized object that doesn't
have a default constructor?

The only option I've figured out is to normally construct an object with
bogus values, then unserialize the real values while reading from the
archive. Example:

X(0) val; // 0 being some bogus value.
inputStream >> val; // Overwrites all values within val;

Is this the correct way to do things?

2-) How should we split the serialization between the class' serialize
member versus load/save_construct_data?

My observations show that when un/serializing objects directly like
shown above, load/save_construct_data aren't needed, so the serialize
member has to handle everything. When serializing a vector<X>,
load/save_construct_data does get called, so we have to un/serialize
some members in those functions as well. At first glance, it seems some
members will have to be un/serialized for the second time within
load/save_construct_data.

Is that correct? For a class to be correctly un/serializable for all
cases, load/save_construct_data must un/serialize members that are
already taken care of in the serialize member?

Thanks!

Martin

-- 
Tel: (450) 681-1681, #271
------------------------------------------------------------------------
OKIOK
Enterprise and e-business security solutions
Solutions de sécurité d'entreprise et d'affaires électronique
Tel. : (450) 681.1681
http://www.okiok.com
This e-mail message (including attachments, if any) is intended for the 
use of the individual or entity to which it is addressed and may contain 
information that is privileged, proprietary, confidential and exempt 
from disclosure. If you are not the intended recipient, you are notified 
that any dissemination, distribution or copying of this communication is 
strictly prohibited. If you have received this communication in error, 
please notify the sender and erase this e-mail message immediately.
 
Le présent message électronique (y compris les pièces qui y sont 
annexées, le cas échéant) s'adresse au destinataire indiqué et peut 
contenir des renseignements de caractère privé ou confidentiel. Si vous 
n'êtes pas le destinataire de ce document, nous vous signalons qu'il est 
strictement interdit de le diffuser, de le distribuer ou de le 
reproduire. Si ce message vous a été transmis par erreur, veuillez en 
informer l'expéditeur et le supprimer immédiatement.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net