Reputation: 20360
I previously asked this question about how to make "versioned" serializaion using boost::serialization::access
I have been able to do some of what I want, but there seem to be significant limitations.
Specifically, I would like to be able to change the versions at run time and change the serialization version dynamically in the code.
However, the macro
BOOST_CLASS_VERSION(ClassName, ver)
seems not to allow this type of behavior.
I suppose I could make different classes and use them each when I need each, but I would prefer not to since that requires a lot of code changes for us.
Is there a way to programmatically change the class to use different versions during the same execution?
A little more explanation of what we need to do:
The use case I am trying to work with is the program reading in the old version (when it is first run/upgraded), then writing with the NEW version and then also being able to read that NEW version.
Upvotes: 3
Views: 232
Reputation: 31931
The design appears to intend that you do not change the version dynamically. Supporting the reading of old data is however possible via the version parameter to your serialize, save, or load functions. That is, in your loading function you can check the version and see if particular parts have to be loaded differently. So loading old data is possible, but it has to be done within one set of serialization functions.
Upvotes: 1