Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51941 - in trunk/boost/archive: . detail impl iterators
From: ramey_at_[hidden]
Date: 2009-03-23 12:59:09


Author: ramey
Date: 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
New Revision: 51941
URL: http://svn.boost.org/trac/boost/changeset/51941

Log:
Throw new exception when program class version is less than file class version.
Other miscellaneous improvements

Text files modified:
   trunk/boost/archive/archive_exception.hpp | 8 +++++++-
   trunk/boost/archive/basic_binary_iprimitive.hpp | 4 ++--
   trunk/boost/archive/basic_binary_oprimitive.hpp | 2 +-
   trunk/boost/archive/basic_text_iprimitive.hpp | 11 +++++------
   trunk/boost/archive/basic_text_oprimitive.hpp | 1 +
   trunk/boost/archive/basic_xml_oarchive.hpp | 1 -
   trunk/boost/archive/codecvt_null.hpp | 3 +++
   trunk/boost/archive/detail/iserializer.hpp | 9 +++++++++
   trunk/boost/archive/impl/basic_binary_oprimitive.ipp | 2 +-
   trunk/boost/archive/iterators/dataflow.hpp | 3 ++-
   trunk/boost/archive/iterators/head_iterator.hpp | 6 +++---
   trunk/boost/archive/tmpdir.hpp | 2 +-
   trunk/boost/archive/xml_archive_exception.hpp | 2 +-
   13 files changed, 36 insertions(+), 18 deletions(-)

Modified: trunk/boost/archive/archive_exception.hpp
==============================================================================
--- trunk/boost/archive/archive_exception.hpp (original)
+++ trunk/boost/archive/archive_exception.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -51,8 +51,11 @@
         invalid_class_name, // class name greater than the maximum permitted.
                             // most likely a corrupted archive or an attempt
                             // to insert virus via buffer overrun method.
- unregistered_cast // base - derived relationship not registered with
+ unregistered_cast, // base - derived relationship not registered with
                             // void_cast_register
+ unsupported_class_version // type saved with a version # greater than the
+ // one used by the program. This indicates that the proggram
+ // needs to be rebuilt.
     } exception_code;
     exception_code code;
     archive_exception(exception_code c) :
@@ -92,6 +95,9 @@
         case unregistered_cast:
             msg = "unregistered void cast";
             break;
+ case unsupported_class_version:
+ msg = "class version";
+ break;
         case other_exception:
             // if get here - it indicates a derived exception
             // was sliced by passing by value in catch

Modified: trunk/boost/archive/basic_binary_iprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_iprimitive.hpp (original)
+++ trunk/boost/archive/basic_binary_iprimitive.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -156,7 +156,7 @@
         static_cast<Elem *>(address),
         s
     );
- if(scount != static_cast<std::streamsize>(s))
+ if(scount != s)
         boost::serialization::throw_exception(
             archive_exception(archive_exception::stream_error)
         );
@@ -180,6 +180,6 @@
 } // namespace archive
 } // namespace boost
 
-#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
+#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
 
 #endif // BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP

Modified: trunk/boost/archive/basic_binary_oprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_binary_oprimitive.hpp (original)
+++ trunk/boost/archive/basic_binary_oprimitive.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -178,6 +178,6 @@
 } //namespace boost
 } //namespace archive
 
-#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
+#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
 
 #endif // BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP

Modified: trunk/boost/archive/basic_text_iprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_text_iprimitive.hpp (original)
+++ trunk/boost/archive/basic_text_iprimitive.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -16,11 +16,11 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-// archives stored as text - note these ar templated on the basic
+// archives stored as text - note these are templated on the basic
 // stream templates to accommodate wide (and other?) kind of characters
 //
-// note the fact that on libraries without wide characters, ostream is
-// is not a specialization of basic_ostream which in fact is not defined
+// Note the fact that on libraries without wide characters, ostream is
+// not a specialization of basic_ostream which in fact is not defined
 // in such cases. So we can't use basic_ostream<IStream::char_type> but rather
 // use two template parameters
 
@@ -43,13 +43,12 @@
 #include <boost/archive/dinkumware.hpp>
 #endif
 
-#include <boost/serialization/throw_exception.hpp>
 #include <boost/limits.hpp>
 #include <boost/io/ios_state.hpp>
 #include <boost/scoped_ptr.hpp>
 
+#include <boost/serialization/throw_exception.hpp>
 #include <boost/archive/archive_exception.hpp>
-
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
 namespace boost {
@@ -139,6 +138,6 @@
 } // namespace archive
 } // namespace boost
 
-#include <boost/archive/detail/abi_suffix.hpp> // pop pragams
+#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
 
 #endif // BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP

Modified: trunk/boost/archive/basic_text_oprimitive.hpp
==============================================================================
--- trunk/boost/archive/basic_text_oprimitive.hpp (original)
+++ trunk/boost/archive/basic_text_oprimitive.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -49,6 +49,7 @@
 #include <boost/io/ios_state.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/serialization/throw_exception.hpp>
+
 #include <boost/archive/archive_exception.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header

Modified: trunk/boost/archive/basic_xml_oarchive.hpp
==============================================================================
--- trunk/boost/archive/basic_xml_oarchive.hpp (original)
+++ trunk/boost/archive/basic_xml_oarchive.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -28,7 +28,6 @@
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
-
 namespace boost {
 namespace archive {
 

Modified: trunk/boost/archive/codecvt_null.hpp
==============================================================================
--- trunk/boost/archive/codecvt_null.hpp (original)
+++ trunk/boost/archive/codecvt_null.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -21,6 +21,7 @@
 #include <cwchar> // for mbstate_t
 #include <boost/config.hpp>
 #include <boost/archive/detail/auto_link_archive.hpp>
+#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
 #if defined(BOOST_NO_STDC_NAMESPACE)
     using ::codecvt;
@@ -80,4 +81,6 @@
 } // namespace archive
 } // namespace boost
 
+#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas
+
 #endif //BOOST_ARCHIVE_CODECVT_NULL_HPP

Modified: trunk/boost/archive/detail/iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/iserializer.hpp (original)
+++ trunk/boost/archive/detail/iserializer.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -147,6 +147,12 @@
     void *x,
     const unsigned int file_version
 ) const {
+ // trap case where the program cannot handle the current version
+ if(file_version > version())
+ boost::serialization::throw_exception(archive::archive_exception(
+ boost::archive::archive_exception::unsupported_class_version
+ ));
+
     // make sure call is routed through the higest interface that might
     // be specialized by the user.
     boost::serialization::serialize_adl(
@@ -474,6 +480,9 @@
         typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type value_type;
         
         // convert integers to correct enum to load
+ // 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) / (
             static_cast<char *>(static_cast<void *>(&t[1]))
             - static_cast<char *>(static_cast<void *>(&t[0]))

Modified: trunk/boost/archive/impl/basic_binary_oprimitive.ipp
==============================================================================
--- trunk/boost/archive/impl/basic_binary_oprimitive.ipp (original)
+++ trunk/boost/archive/impl/basic_binary_oprimitive.ipp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -71,7 +71,7 @@
 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
 basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s)
 {
- std::size_t l = static_cast<unsigned int>(s.size());
+ std::size_t l = static_cast<std::size_t>(s.size());
     this->This()->save(l);
     save_binary(s.data(), l);
 }

Modified: trunk/boost/archive/iterators/dataflow.hpp
==============================================================================
--- trunk/boost/archive/iterators/dataflow.hpp (original)
+++ trunk/boost/archive/iterators/dataflow.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -43,7 +43,7 @@
     enum state_enum {
         is_false = false,
         is_true = true,
- is_indeterminant,
+ is_indeterminant
     } m_state;
     // convert to bool
     operator bool (){
@@ -53,6 +53,7 @@
     // assign from bool
     tri_state & operator=(bool rhs) {
         m_state = rhs ? is_true : is_false;
+ return *this;
     }
     tri_state(bool rhs) :
         m_state(rhs ? is_true : is_false)

Modified: trunk/boost/archive/iterators/head_iterator.hpp
==============================================================================
--- trunk/boost/archive/iterators/head_iterator.hpp (original)
+++ trunk/boost/archive/iterators/head_iterator.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -48,11 +48,11 @@
 
     reference_type dereference_impl(){
         if(! m_end){
- while(! m_predicate(* base_reference()))
- ++ base_reference();
+ while(! m_predicate(* this->base_reference()))
+ ++ this->base_reference();
             m_end = true;
         }
- return * base_reference();
+ return * this->base_reference();
     }
 
     reference_type dereference() const {

Modified: trunk/boost/archive/tmpdir.hpp
==============================================================================
--- trunk/boost/archive/tmpdir.hpp (original)
+++ trunk/boost/archive/tmpdir.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -18,7 +18,7 @@
 
 #include <cstdlib> // getenv
 #include <cstddef> // NULL
-#include <cassert>
+//#include <cassert>
 
 #include <boost/config.hpp>
 #ifdef BOOST_NO_STDC_NAMESPACE

Modified: trunk/boost/archive/xml_archive_exception.hpp
==============================================================================
--- trunk/boost/archive/xml_archive_exception.hpp (original)
+++ trunk/boost/archive/xml_archive_exception.hpp 2009-03-23 12:59:07 EDT (Mon, 23 Mar 2009)
@@ -37,7 +37,7 @@
         xml_archive_tag_name_error
     } exception_code;
     exception_code code;
- xml_archive_exception(exception_code c)
+ xml_archive_exception(exception_code)
     {}
     virtual const char *what( ) const throw( )
     {


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