Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-08-08 11:46:25


Pfligersdorffer, Christian wrote:

> That's good news. I suppose it should be doable since everything you
> need is there - solely the option to pass a version number to the
> serialize functions. I wonder how you would add that feature without
> too many changes to the user interface. Since that relies on streaming
> operators maybe stream manipulators? Or archive member functions? I am
> interested in the details! :)

Note that saving serialization functions also pass the class version
number as parameter. This is set by the BOOST_CLASS_VERSION
macro. The only thing that is necessary is to change that macro
when one creates the output. Something like

BOOST_CLASS_VERSION(T, VERSION_NUMBER_T)

rather than

BOOST_CLASS_VERSION(T, 4)

and write

template<class Archive>
void save(Archive & ar, const T &t, const unsigned int version){
    if(version < 4)
        ; // save the old way
    else
        ; // save the new way
}

just like in the load function.

The only missing piece is for things like stl collections which
don't use versioning (for speed) but rely on the global
ArchiveVersion ofr the library. This global archive version
is now a constant but will have to be "settable" to a lower
number.

Than's almost about it - except for the documentation and
testing of course.

Robert Ramey


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