|
Boost-Commit : |
From: troyer_at_[hidden]
Date: 2008-07-05 10:25:59
Author: troyer
Date: 2008-07-05 10:25:59 EDT (Sat, 05 Jul 2008)
New Revision: 47112
URL: http://svn.boost.org/trac/boost/changeset/47112
Log:
Added backwards compatibility header for 1.35
Added:
branches/release/boost/serialization/vector_135.hpp (contents, props changed)
Text files modified:
branches/release/boost/serialization/array.hpp | 25 +++++++++++++++++++------
branches/release/boost/serialization/vector.hpp | 14 ++++++++++----
branches/release/libs/serialization/src/basic_archive.cpp | 6 +++++-
3 files changed, 34 insertions(+), 11 deletions(-)
Modified: branches/release/boost/serialization/array.hpp
==============================================================================
--- branches/release/boost/serialization/array.hpp (original)
+++ branches/release/boost/serialization/array.hpp 2008-07-05 10:25:59 EDT (Sat, 05 Jul 2008)
@@ -29,8 +29,17 @@
// traits to specify whether to use an optimized array serialization
+#ifdef __BORLANDC__
+// workaround for Borland compiler
+template <class Archive>
+struct use_array_optimization {
+ template <class T> struct apply : boost::mpl::false_ {};
+};
+
+#else
template <class Archive>
struct use_array_optimization : boost::mpl::always<boost::mpl::false_> {};
+#endif
template<class T>
class array
@@ -75,14 +84,15 @@
{
ar.load_array(*this,version);
}
-
+
// default implementation
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
- typedef BOOST_DEDUCED_TYPENAME serialization::use_array_optimization<Archive>
- ::template apply<BOOST_DEDUCED_TYPENAME remove_const<T>::type
- >::type use_optimized;
+ typedef BOOST_DEDUCED_TYPENAME
+ boost::serialization::use_array_optimization<Archive>::template apply<
+ BOOST_DEDUCED_TYPENAME remove_const<T>::type
+ >::type use_optimized;
serialize_optimized(ar,version,use_optimized());
}
@@ -123,7 +133,10 @@
} } // end namespace boost::serialization
-
+#ifdef __BORLANDC__
+// ignore optimizations for Borland
+#define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive)
+#else
#define BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(Archive) \
namespace boost { namespace serialization { \
template <> struct use_array_optimization<Archive> { \
@@ -132,6 +145,6 @@
, BOOST_DEDUCED_TYPENAME boost::remove_const<ValueType>::type \
>::type {}; \
}; }}
-
+#endif // __BORLANDC__
#endif //BOOST_SERIALIZATION_ARRAY_HPP
Modified: branches/release/boost/serialization/vector.hpp
==============================================================================
--- branches/release/boost/serialization/vector.hpp (original)
+++ branches/release/boost/serialization/vector.hpp 2008-07-05 10:25:59 EDT (Sat, 05 Jul 2008)
@@ -29,6 +29,12 @@
#include <boost/serialization/detail/get_data.hpp>
#include <boost/mpl/bool.hpp>
+// default is being compatible with version 1.34.1 files, not 1.35 files
+#ifndef BOOST_SERIALIZATION_VECTOR_VERSION
+#define BOOST_SERIALIZATION_VECTOR_VERSION 3
+#endif
+
+
namespace boost {
namespace serialization {
@@ -77,7 +83,7 @@
){
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 @@
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());
@@ -110,7 +116,7 @@
const std::vector<U, Allocator> &t,
const unsigned int file_version
){
- save(ar,t,file_version, typename use_array_optimization<Archive>::template apply<U>::type());
+ save(ar,t,file_version, BOOST_DEDUCED_TYPENAME use_array_optimization<Archive>::template apply<U>::type());
}
template<class Archive, class U, class Allocator>
@@ -119,7 +125,7 @@
std::vector<U, Allocator> &t,
const unsigned int file_version
){
- load(ar,t,file_version, typename use_array_optimization<Archive>::template apply<U>::type());
+ load(ar,t,file_version, BOOST_DEDUCED_TYPENAME use_array_optimization<Archive>::template apply<U>::type());
}
// split non-intrusive serialization function member into separate
Added: branches/release/boost/serialization/vector_135.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/serialization/vector_135.hpp 2008-07-05 10:25:59 EDT (Sat, 05 Jul 2008)
@@ -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 != 4
+#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 4
+#endif
+
+#include <boost/serialization/vector.hpp>
+
+#endif // BOOST_SERIALIZATION_VECTOR_134_HPP
Modified: branches/release/libs/serialization/src/basic_archive.cpp
==============================================================================
--- branches/release/libs/serialization/src/basic_archive.cpp (original)
+++ branches/release/libs/serialization/src/basic_archive.cpp 2008-07-05 10:25:59 EDT (Sat, 05 Jul 2008)
@@ -54,9 +54,13 @@
// 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
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk