Re: [Boost-bugs] [Boost C++ Libraries] #3990: [serialization] data loss in version field

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3990: [serialization] data loss in version field
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-05-30 16:06:11


#3990: [serialization] data loss in version field
-------------------------------+--------------------------------------------
  Reporter: vgough@… | Owner: ramey
      Type: Feature Requests | Status: closed
 Milestone: Boost 1.43.0 | Component: serialization
   Version: Boost 1.42.0 | Severity: Showstopper
Resolution: wontfix | Keywords:
-------------------------------+--------------------------------------------
Changes (by ramey):

  * status: assigned => closed
  * type: Bugs => Feature Requests
  * resolution: => wontfix

Comment:

 I can't fix this. I'm not going to expand the version # definition beyond
 the originally contemplated 8 bits. I can prevent it from happening in the
 future and this is what's been done. That is, violations of the 8 bit
 limitation will be trapped as soon as possible.

 So if you want maintain you're system of using dates for version numbers,
 you'll have to implement it yourself. This is fairly easy if you want to
 do it. e.g.

 {{{
 template<class Archive>
 void serialization(Archive & ar, unsigned int version){
     // don't use the boost serialization number, use ours instead
     ar & my_date;
     ar && old_data_items
     if(ar.is_loading)
        if(my_date > "jan 10, 2010")
            ar & new_data_item;
 }}}

 Of course this begs the question about how to use the old archives. This
 can be addressed with the function get_library_version() which returns an
 integer indicating which version of he api is being called. The library
 version number associated to boost 1.42 (I believe the last one which
 would work for you) is 5. So the above would be enhanced to be

 {{{
 template<class Archive>
 void serialization(Archive & ar, unsigned int version){
     library_version_type library_version = get_library_version
     if(library_version < 6)
         // the library version is a date
         my_date = version;
     else{
         // don't use the boost serialization number, use ours instead
         ar & my_date;
     }
     ar && old_data_items
     if(ar.is_loading)
        if(my_date > "jan 10, 2010")
            ar & new_data_item;

 }}}

 Alternatively if you want to give up on using the date as a version number
 you can make the transition like this:

 {{{
 template<class Archive>
 void serialization(Archive & ar, unsigned int version){
     library_version_type library_version = get_library_version
     if(library_version < 6)
         // the library version is a date
         // look up integer version # from a table
         version = convert_date_to_version_number(version)
     }
     ar & old_data_items
     if(ar.is_loading){
         if(version > 9?)
             ar & new_data_items;
     }
 }}}

 I realize that this is likely not the answer you were interested in, but
 it DOES address the issue of handling old archives and it will transition
 you to a method of handling versioning consistent with the design of the
 boost serialization library.

 Robert Ramey

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3990#comment:5>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC