Backwards compatibility

[SVN r46997]
This commit is contained in:
Matthias Troyer
2008-07-02 19:13:56 +00:00
parent de383cb6f7
commit a333600aae
3 changed files with 33 additions and 3 deletions

View File

@@ -29,6 +29,12 @@
#include <boost/serialization/detail/get_data.hpp>
#include <boost/mpl/bool.hpp>
// default is being compatible with version 1.35 files, not 1.34.1 files
#ifndef BOOST_SERIALIZATION_VECTOR_VERSION
#define BOOST_SERIALIZATION_VECTOR_VERSION 4
#endif
namespace boost {
namespace serialization {
@@ -77,7 +83,7 @@ inline void save(
){
const collection_size_type count(t.size());
ar << BOOST_SERIALIZATION_NVP(count);
if(3 < ar.get_library_version()) {
if(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version()) {
const unsigned int item_version = version<U>::value;
ar << BOOST_SERIALIZATION_NVP(item_version);
}
@@ -96,7 +102,7 @@ inline void load(
ar >> BOOST_SERIALIZATION_NVP(count);
t.resize(count);
unsigned int item_version=0;
if(3 < ar.get_library_version())
if(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version())
ar >> BOOST_SERIALIZATION_NVP(item_version);
if (!t.empty())
ar >> make_array(detail::get_data(t),t.size());

View File

@@ -0,0 +1,20 @@
#ifndef BOOST_SERIALIZATION_VECTOR_134_HPP
#define BOOST_SERIALIZATION_VECTOR_134_HPP
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// vector_134.hpp: backwards compatibility with 1.34.1 files
// (C) Copyright 2008 Matthias Troyer
#ifdef BOOST_SERIALIZATION_VECTOR_VERSION
#if BOOST_SERIALIZATION_VECTOR_VERSION != 3
#error Boost.Serialization cannot be compatible with both 1.34.1. and 1.35 files. Please include boost/serialization/vector_134.hpp before vector.hpp to be compatible with 1.34.1 files
#endif
#else
#define BOOST_SERIALIZATION_VECTOR_VERSION 3
#endif
#include <boost/serialization/vector.hpp>
#endif // BOOST_SERIALIZATION_VECTOR_134_HPP

View File

@@ -54,9 +54,13 @@ ARCHIVE_SIGNATURE(){
// 3 - numerous changes - can't guarentee compatibility with previous versions
// 4 - Boost 1.34
// added register_version to properly support versioning for collections
// 5 - Boost 1.36
// changed serialization of collections: adding version even for primitive
// types caused backwards compatibility breaking change in 1.35
BOOST_ARCHIVE_DECL(unsigned char)
ARCHIVE_VERSION(){
return 4;
return 5;
}
} // namespace archive