Index: boost/archive/basic_binary_iarchive.hpp =================================================================== --- boost/archive/basic_binary_iarchive.hpp (revision 83148) +++ boost/archive/basic_binary_iarchive.hpp (working copy) @@ -82,39 +82,18 @@ // binary files don't include the optional information void load_override(class_id_optional_type & /* t */, int){} - void load_override(tracking_type & t, int /*version*/){ + void load_override(tracking_type & t, int version){ library_version_type lvt = this->get_library_version(); - if(boost::archive::library_version_type(6) < lvt){ - int_least8_t x=0; - * this->This() >> x; - t = boost::archive::tracking_type(x); - } - else{ - bool x=0; - * this->This() >> x; - t = boost::archive::tracking_type(x); - } - } - void load_override(class_id_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){ - int_least16_t x=0; - * this->This() >> x; - t = boost::archive::class_id_type(x); - } else{ - int x=0; + char x=0; * this->This() >> x; - t = boost::archive::class_id_type(x); + t = boost::archive::tracking_type(x); } } - void load_override(class_id_reference_type & t, int version){ - load_override(static_cast(t), version); - } + #if 0 void load_override(class_id_reference_type & t, int version){ library_version_type lvt = this->get_library_version(); @@ -144,55 +123,34 @@ 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_least8_t x=0; - * this->This() >> x; - t = boost::archive::version_type(x); - } - else - if(boost::archive::library_version_type(5) < lvt){ - uint_least16_t x=0; - * this->This() >> x; - t = boost::archive::version_type(x); - } - else - if(boost::archive::library_version_type(2) < lvt){ - // upto 255 versions + else{ 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); } } void load_override(boost::serialization::item_version_type & t, int version){ library_version_type lvt = this->get_library_version(); -// if(boost::archive::library_version_type(7) < lvt){ - if(boost::archive::library_version_type(6) < lvt){ + 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::serialization::item_version_type(x); - } else{ - unsigned int x=0; + unsigned char x=0; * this->This() >> x; t = boost::serialization::item_version_type(x); } } void load_override(serialization::collection_size_type & t, int version){ - if(boost::archive::library_version_type(5) < this->get_library_version()){ + if(boost::archive::library_version_type(7) < this->get_library_version()){ this->detail_common_iarchive::load_override(t, version); } + else if(boost::archive::library_version_type(5) < this->get_library_version()){ + size_t x=0; + * this->This() >> x; + t = serialization::collection_size_type(x); + } else{ unsigned int x=0; * this->This() >> x; Index: boost/archive/impl/basic_binary_iarchive.ipp =================================================================== --- boost/archive/impl/basic_binary_iarchive.ipp (revision 83148) +++ boost/archive/impl/basic_binary_iarchive.ipp (working copy) @@ -79,33 +79,41 @@ library_version_type input_library_version; //* this->This() >> input_library_version; { + //Boost serialization 1.42, 1.43 and 1.44 all wrote archives with an archive version of 7. + //1.42 and 1.43 used "version_type" as archive version type and explicitely stored it as "unsigned char" like other versions before. + //1.44 started to use "library_version_type" to store the archive version as an "uint_least16_t" with two bytes but didn't increase the archive version. + //1.45 finally increased the archive version. So the problem is to detect which version an archive with a version of 7 belongs to. + //Fortunately the archive version is followed by a byte that contains sizeof(int) which cannot be zero and will currently not exceed 255. + //This way the higher order byte of the 2 byte archive version will always be zero and can be used to detect which boost serialization version was used to write the archive. + //If version 1.44 is detected the archive version is increased to 8. This kind of fixes the issue that 1.44 did not increase the archive version as it should have. + //Fortunately 1.45 (the first version that writes archive version 8 binary archives) didn't do any changes in the way archives are writte by its own so this fix works. + int v = 0; - v = this->This()->m_sb.sbumpc(); + v = this->This()->m_sb.sbumpc(); //reads low order byte #if defined(BOOST_LITTLE_ENDIAN) - if(v < 6){ - ; - } - else if(v < 7){ - // version 6 - next byte should be zero - this->This()->m_sb.sbumpc(); + ; //version 6 and below used "version_type" as archive version type and explicitely stored it as "unsigned char" } else if(v < 8){ int x1; - // version 7 = might be followed by zero or some other byte - x1 = this->This()->m_sb.sgetc(); - // it's =a zero, push it back - if(0 == x1) + x1 = this->This()->m_sb.sgetc(); //reads possible high order byte + // it's a zero, remove it from input stream + if(0 == x1){ this->This()->m_sb.sbumpc(); + ++v; //increase archive version to 8 } + } else{ // version 8+ followed by a zero this->This()->m_sb.sbumpc(); } #elif defined(BOOST_BIG_ENDIAN) - if(v == 0) - v = this->This()->m_sb.sbumpc(); + if(v == 0){ //check if high order byte is zero + v = this->This()->m_sb.sbumpc(); //read the low order byte + if (7 == v) + ++v; //increase the archive version to 8 because it has a value of 7 and consists of 2 bytes + } #endif input_library_version = static_cast(v); }