|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55395 - in trunk: boost/archive boost/archive/detail libs/serialization/src
From: troyer_at_[hidden]
Date: 2009-08-03 20:56:20
Author: troyer
Date: 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
New Revision: 55395
URL: http://svn.boost.org/trac/boost/changeset/55395
Log:
Collection sizes are now seriallized as std::size_t
Text files modified:
trunk/boost/archive/basic_binary_iarchive.hpp | 17 ++++++++++++-----
trunk/boost/archive/basic_binary_oarchive.hpp | 4 ++--
trunk/boost/archive/detail/iserializer.hpp | 6 +++---
trunk/boost/archive/detail/oserializer.hpp | 3 ++-
trunk/libs/serialization/src/basic_archive.cpp | 3 ++-
5 files changed, 21 insertions(+), 12 deletions(-)
Modified: trunk/boost/archive/basic_binary_iarchive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_iarchive.hpp (original)
+++ trunk/boost/archive/basic_binary_iarchive.hpp 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
@@ -101,11 +101,18 @@
* this->This() >> x;
t = (0 != x);
}
- void load_override(serialization::collection_size_type & t, int){
- unsigned int x=0;
- * this->This() >> x;
- t = serialization::collection_size_type(x);
- }
+ void load_override(serialization::collection_size_type & t, int){
+ if (this->get_library_version() < 6) {
+ unsigned int x=0;
+ * this->This() >> x;
+ t = serialization::collection_size_type(x);
+ }
+ else {
+ std::size_t x=0;
+ * this->This() >> x;
+ t = serialization::collection_size_type(x);
+ }
+ }
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
load_override(class_name_type & t, int);
Modified: trunk/boost/archive/basic_binary_oarchive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_oarchive.hpp (original)
+++ trunk/boost/archive/basic_binary_oarchive.hpp 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
@@ -85,7 +85,7 @@
}
void save_override(const class_id_reference_type & t, int){
// upto 32K classes
- assert(t.t <= boost::integer_traits<boost::uint_least32_t>::const_max);
+ assert(t.t <= boost::integer_traits<boost::uint_least16_t>::const_max);
const boost::uint_least16_t x = t.t;
* this->This() << x;
}
@@ -114,7 +114,7 @@
void save_override(const serialization::collection_size_type & t, int){
// for backward compatibility, 64 bit integer or variable length integer would be preferred
- unsigned int x = t.t;
+ std::size_t x = t.t;
* this->This() << x;
}
Modified: trunk/boost/archive/detail/iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/iserializer.hpp (original)
+++ trunk/boost/archive/detail/iserializer.hpp 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
@@ -502,13 +502,13 @@
// determine number of elements in the array. Consider the
// fact that some machines will align elements on boundries
// other than characters.
- int current_count = sizeof(t) / (
+ std::size_t current_count = sizeof(t) / (
static_cast<char *>(static_cast<void *>(&t[1]))
- static_cast<char *>(static_cast<void *>(&t[0]))
);
- int count;
+ boost::serialization::collection_size_type count;
ar >> BOOST_SERIALIZATION_NVP(count);
- if(count > current_count)
+ if(static_cast<std::size_t>(count) > current_count)
boost::serialization::throw_exception(archive::archive_exception(
boost::archive::archive_exception::array_size_too_short
));
Modified: trunk/boost/archive/detail/oserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/oserializer.hpp (original)
+++ trunk/boost/archive/detail/oserializer.hpp 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
@@ -480,10 +480,11 @@
save_access::end_preamble(ar);
// consider alignment
- int count = sizeof(t) / (
+ std::size_t c = sizeof(t) / (
static_cast<const char *>(static_cast<const void *>(&t[1]))
- static_cast<const char *>(static_cast<const void *>(&t[0]))
);
+ boost::serialization::collection_size_type count(c);
ar << BOOST_SERIALIZATION_NVP(count);
ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count);
}
Modified: trunk/libs/serialization/src/basic_archive.cpp
==============================================================================
--- trunk/libs/serialization/src/basic_archive.cpp (original)
+++ trunk/libs/serialization/src/basic_archive.cpp 2009-08-03 20:56:19 EDT (Mon, 03 Aug 2009)
@@ -57,10 +57,11 @@
// 5 - Boost 1.36
// changed serialization of collections: adding version even for primitive
// types caused backwards compatibility breaking change in 1.35
+// 6 - Boost 1.41, serializing collection sizes as std::size_t
BOOST_ARCHIVE_DECL(unsigned char)
BOOST_ARCHIVE_VERSION(){
- return 5;
+ return 6;
}
} // 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