
Russell Hind wrote:
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.
Does serialization not check the 'BOOST_CLASS_VERSION' of an object before attempting to de-serialize it?
If not, how can we access the 'BOOST_CLASS_VERSION' in a serialization member function? I'm looking to do something like this: (this code is just written now so probably is incorrect but hopefully gives the idea). How do we check 'version_of_T' below which should correspond to the BOOST_CLASS_VERSION for T?
boost::serialization::version<T>::value should contain the version of the type being used by program. If you want old programs to check for newer versions try void serialize(Archive &ar, T & t, const unsigned version){ if(version > boost::serialization::version<T>::value) throw exception(....) It never occured to me to build this into the serialization library itself, Now that it has been mentioned, it seems like a worthy idea. I'll consider it. Robert Ramey