Re: [Boost-users] [Serialization] Writing an old version of a class

Don, I can't speak to what support is present in boost serialization, but I have a lot of code that needs to deal with multiple versions of classes or data structures. I've found that the best way to deal with that is to store a version number as a data member and then handle the schema evolution internally in the class. In general, it is the responsibility of a class to handle older versions "appropriately" whatever that means to you in your context. If the version number is the FIRST data member of the class (in an I/O or serialization context), then you can easily write code to handle multiple versions during I/O and/or serialization. Just my $0.02. Cheers, Rick Aurbach Aurbach & Associates, Inc. On Jul 15, 2011, at 11:00 AM, boost-users-request@lists.boost.org wrote:
From: Don
Date: July 15, 2011 7:27:07 AM CDT To: "boost-users@lists.boost.org" Subject: [Boost-users] [Serialization] Writing an old version of a class Reply-To: "boost-users@lists.boost.org" I apologize if this is a duplicate posting. I sent this 2 days ago, and it appears in the archives, but I never received it back from the list and there have been no replies, so I am posting it again.
Using boost serialization, I would like to be able to write an old version of a class, so that I can save data in an "old" format to allow other users with an old version of my program to read the file.
I see from the archives that this has come up before, and Robert Ramey indicated it was doable and on the todo list, but I don't see it in the release notes or documentation. Did anything every come of this?
Or, has anyone else done this? Any suggestions on how to accomplish this?
Thanks,
Don

Richard L. Aurbach wrote:
Don,
I can't speak to what support is present in boost serialization, but I have a lot of code that needs to deal with multiple versions of classes or data structures. I've found that the best way to deal with that is to store a version number as a data member and then handle the schema evolution internally in the class. In general, it is the responsibility of a class to handle older versions "appropriately" whatever that means to you in your context. If the version number is the FIRST data member of the class (in an I/O or serialization context), then you can easily write code to handle multiple versions during I/O and/or serialization.
Just my $0.02.
This is exactly the way it's handled by the serialization library. The only difference is that the version # is included by default rather than the programmer having to explicitly do it. Robert Ramey
participants (2)
-
Richard L. Aurbach
-
Robert Ramey