Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64156 - trunk/boost/archive
From: ramey_at_[hidden]
Date: 2010-07-19 09:06:10


Author: ramey
Date: 2010-07-19 09:06:09 EDT (Mon, 19 Jul 2010)
New Revision: 64156
URL: http://svn.boost.org/trac/boost/changeset/64156

Log:
Fix? for error in library version 6 - version types and class id types
Text files modified:
   trunk/boost/archive/basic_archive.hpp | 2
   trunk/boost/archive/basic_binary_iarchive.hpp | 69 +++++++++++++++++++++++++++++++++++++--
   trunk/boost/archive/basic_binary_oarchive.hpp | 51 +++++++++++++++++++++++++++-
   3 files changed, 113 insertions(+), 9 deletions(-)

Modified: trunk/boost/archive/basic_archive.hpp
==============================================================================
--- trunk/boost/archive/basic_archive.hpp (original)
+++ trunk/boost/archive/basic_archive.hpp 2010-07-19 09:06:09 EDT (Mon, 19 Jul 2010)
@@ -74,7 +74,7 @@
 
 class version_type {
 private:
- typedef unsigned int base_type;
+ typedef uint_least32_t base_type;
     base_type t;
     version_type(): t(0) {};
 public:

Modified: trunk/boost/archive/basic_binary_iarchive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_iarchive.hpp (original)
+++ trunk/boost/archive/basic_binary_iarchive.hpp 2010-07-19 09:06:09 EDT (Mon, 19 Jul 2010)
@@ -32,6 +32,7 @@
 #include <boost/serialization/collection_size_type.hpp>
 #include <boost/serialization/string.hpp>
 #include <boost/serialization/item_version_type.hpp>
+#include <boost/integer_traits.hpp>
 
 #ifdef BOOST_MSVC
 # pragma warning(push)
@@ -82,21 +83,61 @@
     // binary files don't include the optional information
     void load_override(class_id_optional_type & /* t */, int){}
 
- void load_override(boost::serialization::item_version_type & t, int version){
- if(library_version_type(6) < this->get_library_version()){
+ 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{
- unsigned int x=0;
+ int x=0;
             * this->This() >> x;
- t = boost::serialization::item_version_type(x);
+ t = boost::archive::class_id_type(x);
+ }
+ }
+ void load_override(class_id_reference_type & t, int version){
+ load_override(static_cast<class_id_type &>(t), version);
+ }
+#if 0
+ void load_override(class_id_reference_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_reference_type(
+ boost::archive::class_id_type(x)
+ );
+ }
+ else{
+ int x=0;
+ * this->This() >> x;
+ t = boost::archive::class_id_reference_type(
+ boost::archive::class_id_type(x)
+ );
         }
     }
+#endif
 
     void load_override(version_type & t, int version){
- if(boost::archive::library_version_type(6) < this->get_library_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{
             unsigned int x=0;
             * this->This() >> x;
@@ -104,6 +145,24 @@
         }
     }
 
+ 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){
+ 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;
+ * 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()){
             this->detail_common_iarchive::load_override(t, version);

Modified: trunk/boost/archive/basic_binary_oarchive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_oarchive.hpp (original)
+++ trunk/boost/archive/basic_binary_oarchive.hpp 2010-07-19 09:06:09 EDT (Mon, 19 Jul 2010)
@@ -34,6 +34,7 @@
 #include <boost/archive/detail/common_oarchive.hpp>
 #include <boost/serialization/string.hpp>
 #include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/item_version_type.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
@@ -87,14 +88,58 @@
     // binary files don't include the optional information
     void save_override(const class_id_optional_type & /* t */, int){}
 
- #if 0 // enable this if we decide to support generation of previous versions
+ // enable this if we decide to support generation of previous versions
+ #if 0
     void save_override(const boost::archive::version_type & t, int version){
- if(this->get_library_version() < boost::archive::library_version_type(7)){
- * this->This() << static_cast<int_least16_t >(t);
+ library_version_type lvt = this->get_library_version();
+ if(boost::archive::library_version_type(7) < lvt){
+ this->detail_common_oarchive::save_override(t, version);
         }
         else
+ if(boost::archive::library_version_type(6) < lvt){
+ const boost::uint_least16_t x = t;
+ * this->This() << x;
+ }
+ else{
+ const unsigned int x = t;
+ * this->This() << x;
+ }
+ }
+ void save_override(const boost::serialization::item_version_type & t, int version){
+ library_version_type lvt = this->get_library_version();
+ if(boost::archive::library_version_type(7) < lvt){
             this->detail_common_oarchive::save_override(t, version);
+ }
+ else
+ if(boost::archive::library_version_type(6) < lvt){
+ const boost::uint_least16_t x = t;
+ * this->This() << x;
+ }
+ else{
+ const unsigned int x = t;
+ * this->This() << x;
+ }
     }
+
+ void save_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_oarchive::save_override(t, version);
+ }
+ else
+ if(boost::archive::library_version_type(6) < lvt){
+ const boost::int_least16_t x = t;
+ * this->This() << x;
+ }
+ else{
+ const int x = t;
+ * this->This() << x;
+ }
+ }
+ void save_override(class_id_reference_type & t, int version){
+ save_override(static_cast<class_id_type &>(t), version);
+ }
+
     #endif
 
     // explicitly convert to char * to avoid compile ambiguities


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