Boost logo

Boost Users :

Subject: [Boost-users] [Boost.Serialization] (De-)serialization with class versioning
From: Lars Ruoff (lars.ruoff_at_[hidden])
Date: 2018-03-11 12:57:39


Hi,
i use the class versioning feature of Boost.Serialization, with an external
(non-intrusive) serialization function like this:

BOOST_CLASS_VERSION(GAMEINFO, 1)

template <typename Archive>
void serialize(Archive &ar, GAMEINFO& gameSettings, const unsigned int
version)
{
ar & gameSettings.NPODS;
// ...
if (version > 0)
ar & gameSettings.ARENA_GOAL_EXCLUSION_RADIUS;
}

Now as soon, as i set BOOST_CLASS_VERSION(GAMEINFO, 1), i get version==1 in
this serialize function, even when i *deserialize* (load from archive).
I would have expected to get the version of the data in the saved archive
in this case.

Say i saved with an old version=0.
Then my class evolved and i set BOOST_CLASS_VERSION(GAMEINFO, 1).
But when reading the old archive, i expect version==0 in the function so i
can react on it.
Instead, i get always version==1, as soon as i compile with
BOOST_CLASS_VERSION(GAMEINFO, 1), even when i'm reading old files!
What am i missing?

regards,
Lars R.



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