Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64004 - in trunk/boost: archive serialization
From: ramey_at_[hidden]
Date: 2010-07-13 21:48:59


Author: ramey
Date: 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
New Revision: 64004
URL: http://svn.boost.org/trac/boost/changeset/64004

Log:
Correct rendering of version_type in text archives
Text files modified:
   trunk/boost/archive/basic_archive.hpp | 2 +-
   trunk/boost/archive/text_iarchive.hpp | 11 +++++++++++
   trunk/boost/archive/text_oarchive.hpp | 7 +++++++
   trunk/boost/archive/xml_iarchive.hpp | 13 +++++++++++++
   trunk/boost/archive/xml_oarchive.hpp | 10 +++++++++-
   trunk/boost/serialization/item_version_type.hpp | 4 ++--
   6 files changed, 43 insertions(+), 4 deletions(-)

Modified: trunk/boost/archive/basic_archive.hpp
==============================================================================
--- trunk/boost/archive/basic_archive.hpp (original)
+++ trunk/boost/archive/basic_archive.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -74,7 +74,7 @@
 
 class version_type {
 private:
- typedef uint_least8_t base_type;
+ typedef unsigned int base_type;
     base_type t;
     version_type(): t(0) {};
 public:

Modified: trunk/boost/archive/text_iarchive.hpp
==============================================================================
--- trunk/boost/archive/text_iarchive.hpp (original)
+++ trunk/boost/archive/text_iarchive.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -23,6 +23,7 @@
 #include <boost/archive/basic_text_iprimitive.hpp>
 #include <boost/archive/basic_text_iarchive.hpp>
 #include <boost/archive/detail/register_archive.hpp>
+#include <boost/serialization/item_version_type.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
@@ -51,6 +52,16 @@
     void load(T & t){
         basic_text_iprimitive<std::istream>::load(t);
     }
+ void load(version_type & t){
+ unsigned int v;
+ load(v);
+ t = version_type(v);
+ }
+ void load(boost::serialization::item_version_type & t){
+ unsigned int v;
+ load(v);
+ t = boost::serialization::item_version_type(v);
+ }
     BOOST_ARCHIVE_DECL(void)
     load(char * t);
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T

Modified: trunk/boost/archive/text_oarchive.hpp
==============================================================================
--- trunk/boost/archive/text_oarchive.hpp (original)
+++ trunk/boost/archive/text_oarchive.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -30,6 +30,7 @@
 #include <boost/archive/basic_text_oprimitive.hpp>
 #include <boost/archive/basic_text_oarchive.hpp>
 #include <boost/archive/detail/register_archive.hpp>
+#include <boost/serialization/item_version_type.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
@@ -59,6 +60,12 @@
         this->newtoken();
         basic_text_oprimitive<std::ostream>::save(t);
     }
+ void save(const version_type & t){
+ save(static_cast<const unsigned int>(t));
+ }
+ void save(const boost::serialization::item_version_type & t){
+ save(static_cast<const unsigned int>(t));
+ }
     BOOST_ARCHIVE_DECL(void)
     save(const char * t);
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T

Modified: trunk/boost/archive/xml_iarchive.hpp
==============================================================================
--- trunk/boost/archive/xml_iarchive.hpp (original)
+++ trunk/boost/archive/xml_iarchive.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -23,6 +23,7 @@
 #include <boost/archive/basic_text_iprimitive.hpp>
 #include <boost/archive/basic_xml_iarchive.hpp>
 #include <boost/archive/detail/register_archive.hpp>
+#include <boost/serialization/item_version_type.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
@@ -63,6 +64,18 @@
     void load(T & t){
         basic_text_iprimitive<std::istream>::load(t);
     }
+ void
+ load(version_type & t){
+ unsigned int v;
+ load(v);
+ t = version_type(v);
+ }
+ void
+ load(boost::serialization::item_version_type & t){
+ unsigned int v;
+ load(v);
+ t = boost::serialization::item_version_type(v);
+ }
     BOOST_ARCHIVE_DECL(void)
     load(char * t);
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T

Modified: trunk/boost/archive/xml_oarchive.hpp
==============================================================================
--- trunk/boost/archive/xml_oarchive.hpp (original)
+++ trunk/boost/archive/xml_oarchive.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -30,6 +30,7 @@
 #include <boost/archive/basic_text_oprimitive.hpp>
 #include <boost/archive/basic_xml_oarchive.hpp>
 #include <boost/archive/detail/register_archive.hpp>
+#include <boost/serialization/item_version_type.hpp>
 
 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
 
@@ -61,7 +62,14 @@
     void save(const T & t){
         basic_text_oprimitive<std::ostream>::save(t);
     }
-
+ void
+ save(const version_type & t){
+ save(static_cast<const unsigned int>(t));
+ }
+ void
+ save(const boost::serialization::item_version_type & t){
+ save(static_cast<const unsigned int>(t));
+ }
     BOOST_ARCHIVE_DECL(void)
     save(const char * t);
     #ifndef BOOST_NO_INTRINSIC_WCHAR_T

Modified: trunk/boost/serialization/item_version_type.hpp
==============================================================================
--- trunk/boost/serialization/item_version_type.hpp (original)
+++ trunk/boost/serialization/item_version_type.hpp 2010-07-13 21:48:58 EDT (Tue, 13 Jul 2010)
@@ -21,7 +21,7 @@
 
 class item_version_type {
 private:
- typedef uint_least8_t base_type;
+ typedef unsigned int base_type;
     base_type t;
     item_version_type(): t(0) {};
 public:
@@ -39,7 +39,7 @@
     operator const base_type () const {
         return t;
     }
- // used for text output
+ // used for text input
     operator base_type & () {
         return t;
     }


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