Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost serialization: archive "unsupported version" exception

I've got the exception "unsupported version" when I try to deserialize through a text archive some data previously serialized with a upper version of Boost (1.46 to serialize and 1.38 to deserialize)...is there a way to downgrade (in the code) the serialization?

Something like "set_library_version"?

like image 367
marco Avatar asked May 16 '11 09:05

marco


Video Answer


1 Answers

See the Error read binary archive, created by old Boost version mail archive post about the serialization error.

It says that the code below does the job:

void load_override(version_type & t, int version){

    library_version_type lvt = this->get_library_version();
    if (boost::archive::library_version_type(7) < lvt){
        this->detail_common_iarchive::load_override(t, version);
    }
    else
        if (boost::archive::library_version_type(6) < lvt){
            uint_least16_t x = 0;
            * this->This() >> x;
            t = boost::archive::version_type(x);
        }
        else
            if (boost::archive::library_version_type(3) == lvt ||
                boost::archive::library_version_type(5) == lvt){

                #pragma message("CTMS fix for serialization bug (lack of backwards compatibility) introduced by Boost 1.45.")
                // Up to 255 versions
                unsigned char x = 0;
                * this->This() >> x;
                t = version_type(x);
            }
            else{
                unsigned int x = 0;
                * this->This() >> x;
                t = boost::archive::version_type(x);
            }
}
like image 185
O.C. Avatar answered Oct 01 '22 10:10

O.C.