Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Reading back old archives
From: David Raulo (david.raulo_at_[hidden])
Date: 2010-07-11 13:16:56


I have a problem reading back serialization archives generated by older version of boost. I used to have a YYYYMMDD class versioning scheme. This broke with boost 1.42, which truncates the class version numbers to 16 bits, causing my code to generated corrupted archives. I fixed my code by implementing my own class versioning when compiling with boost 1.42, so I am again able to create archives that I can read back. Unfortunately this fixes only half of the problem. How can I read back archives that were saved using older releases of the serialization library?

I saw that someone else opened ticket 3990 for the same problem. Here you suggested using the function get_library_version() in the following way:

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;
        // don't use the boost serialization number, use ours instead
        ar & my_date;
    ar && old_data_items
       if(my_date > "jan 10, 2010")
           ar & new_data_item;

but I can't get this to work: the version argument is already truncated, and can't be interpreted as a date. As the bug reporter said, this is a case of data loss. Should I reopen ticket 3990, or is this code supposed to work with svn (I admit I did not test the trunk)?

Thanks for your help,


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at