Boost logo

Boost Users :

From: Tarjei Knapstad (tarjei.knapstad_at_[hidden])
Date: 2006-06-15 05:29:51


[sorry for breaking the threading, just re-joined the list]

> We have system data written out to an XML archive and being
> de-serialized at application startup.
>
> One object type in the archive we written at version 1 by a newer
> version of the application. We then ran an older version of the
> software which only understood version 0 of the object.

Hi Russel,

To handle different versions of data you should split serialize() into
separate save()/load() functions as described in the tutorial:

http://boost.org/libs/serialization/doc/tutorial.html#splitting

The implementation will look something like:

void save(...)
{
  // Serialize all data here
}

void load(Archive & ar, unsigned int version)
{
   if (version > 0)
   {
        // Load data added in version 1
   }
   if (version > 1)
   {
       // Load data added in version 2
   }
   // Load version 0 data
}

Regards,

--
Tarjei

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