Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-04-17 10:13:35


Matthias Troyer wrote:

> I have two more questions regarding the serialization library which I
> need to have answered before I can see if I can read my old archives
> with your library:

> 1. when overloading the save/load functions in an archive, do I bypass
> writing preambles and other class information or do I need to overload
> operator <<? What is the difference between implementing operator<< and
> save?

> 2. which functions do I need to implement in my archive class to skip
> writing the standard preamble that your archives write? Is it just the
> init function or are there more functions?

Depending on the implementation traits for each class, there may be a
preamble written by the serialization library. This contains information
such as version number, class id info, perhaps export key, etc required by
the s library to reconstruct a faithful reproduction of the original data.
If there is a preamble, there is no information in that can be discarded and
still reproduce the original data.

In general it can't be guaranteed that one can read an arbitrary file format
created independently of the serialization library. With the serialization
library, it's the class/instance structure that drives the file format
rather than the other way around. To transition to use the serialization
library the strategy would be:

a) add serialization to the classes desired.
b) write a program which reads the "old" data files using the "old" method -
whatever that might be.
c) invoke serialization to save in the desired new format. The old data
files should no longer be necessary.

Best regards

Matthias


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