? archive/diffs Index: archive/basic_archive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/basic_archive.hpp,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -b -d -u -r1.11 -r1.11.4.1 --- archive/basic_archive.hpp 12 Aug 2005 17:11:28 -0000 1.11 +++ archive/basic_archive.hpp 24 Sep 2005 13:44:04 -0000 1.11.4.1 @@ -10,6 +10,7 @@ // basic_archive.hpp: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// size_type modification (C) Copyright 2005 Matthias Troyer. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -37,6 +38,7 @@ BOOST_STRONG_TYPEDEF(int, class_id_reference_type) BOOST_STRONG_TYPEDEF(unsigned int, object_id_type) BOOST_STRONG_TYPEDEF(unsigned int, object_reference_type) +BOOST_STRONG_TYPEDEF(std::size_t, container_size_type) struct tracking_type { typedef bool value_type; @@ -121,6 +123,7 @@ BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type) BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::container_size_type, primitive_type) /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // Make sure that the export.hpp header isn't included before any archive header Index: archive/basic_binary_iarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/basic_binary_iarchive.hpp,v retrieving revision 1.7 retrieving revision 1.7.6.2 diff -b -d -u -r1.7 -r1.7.6.2 --- archive/basic_binary_iarchive.hpp 16 Jul 2005 05:15:32 -0000 1.7 +++ archive/basic_binary_iarchive.hpp 9 Oct 2005 14:57:06 -0000 1.7.6.2 @@ -17,6 +17,7 @@ // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// size_type modifications (C) Copyright 2005 Matthias Troyer. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -62,7 +63,7 @@ protected: #endif // intermediate level to support override of operators - // fot templates in the absence of partial function + // for templates in the absence of partial function // template ordering template void load_override(T & t, BOOST_PFTO int) @@ -109,6 +110,12 @@ * this->This() >> x; t = (0 != x); } + void load_override(container_size_type & t, int){ + // upto 2G objects + unsigned int x; + * this->This() >> x; + t = container_size_type(x); + } BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) load_override(class_name_type & t, int); Index: archive/basic_binary_iprimitive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/basic_binary_iprimitive.hpp,v retrieving revision 1.7 retrieving revision 1.7.6.2 diff -b -d -u -r1.7 -r1.7.6.2 --- archive/basic_binary_iprimitive.hpp 2 Jul 2005 05:52:14 -0000 1.7 +++ archive/basic_binary_iprimitive.hpp 9 Oct 2005 14:57:06 -0000 1.7.6.2 @@ -17,6 +17,7 @@ // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -99,6 +100,14 @@ public: void load_binary(void *address, std::size_t count); + + // fast loading of arrays of fundamental types + template + void load_array(T *address, std::size_t count) + { + load_binary(address, count*sizeof(T)); + } + }; template Index: archive/basic_binary_oarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/basic_binary_oarchive.hpp,v retrieving revision 1.8 retrieving revision 1.8.6.2 diff -b -d -u -r1.8 -r1.8.6.2 --- archive/basic_binary_oarchive.hpp 16 Jul 2005 05:15:32 -0000 1.8 +++ archive/basic_binary_oarchive.hpp 9 Oct 2005 14:57:06 -0000 1.8.6.2 @@ -10,6 +10,7 @@ // basic_binary_oarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// size_type modifications (C) Copyright 2005 Matthias Troyer. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -102,6 +103,11 @@ char x = t.t; * this->This() << x; } + void save_override(const container_size_type & t, int){ + // for backward compatibility. a 64 bit integer would be better + unsigned int x = t.t; + * this->This() << x; + } // explicitly convert to char * to avoid compile ambiguities void save_override(const class_name_type & t, int){ Index: archive/basic_binary_oprimitive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/basic_binary_oprimitive.hpp,v retrieving revision 1.8 retrieving revision 1.8.6.2 diff -b -d -u -r1.8 -r1.8.6.2 --- archive/basic_binary_oprimitive.hpp 2 Jul 2005 05:52:14 -0000 1.8 +++ archive/basic_binary_oprimitive.hpp 9 Oct 2005 14:57:06 -0000 1.8.6.2 @@ -10,6 +10,7 @@ // basic_binary_oprimitive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -96,6 +97,14 @@ ~basic_binary_oprimitive(); public: void save_binary(const void *address, std::size_t count); + + // fast saving of arrays of fundamental types + template + void save_array(T const *address, std::size_t count) + { + save_binary(address, count*sizeof(T)); + } + }; template Index: archive/binary_iarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/binary_iarchive.hpp,v retrieving revision 1.11 retrieving revision 1.11.6.3 diff -b -d -u -r1.11 -r1.11.6.3 --- archive/binary_iarchive.hpp 21 Apr 2005 04:51:46 -0000 1.11 +++ archive/binary_iarchive.hpp 9 Oct 2005 14:57:06 -0000 1.11.6.3 @@ -10,6 +10,7 @@ // binary_iarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,6 +21,8 @@ #include #include #include +#include +#include #include // must be the last header @@ -80,6 +83,16 @@ {} }; +// specialize has_fast_array_serialization +// the binary archive provides fast array serialization for all fundamental types + + +template +struct has_fast_array_serialization + : public is_fundamental +{}; + + } // namespace archive } // namespace boost Index: archive/binary_oarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/binary_oarchive.hpp,v retrieving revision 1.7 retrieving revision 1.7.6.3 diff -b -d -u -r1.7 -r1.7.6.3 --- archive/binary_oarchive.hpp 21 Apr 2005 04:51:46 -0000 1.7 +++ archive/binary_oarchive.hpp 9 Oct 2005 14:57:06 -0000 1.7.6.3 @@ -10,6 +10,7 @@ // binary_oarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,6 +21,8 @@ #include #include #include +#include +#include #include // must be the last header @@ -79,6 +82,17 @@ {} }; + +// specialize has_fast_array_serialization +// the binary archive provides fast array serialization for all fundamental types + + +template +struct has_fast_array_serialization + : public is_fundamental +{}; + + } // namespace archive } // namespace boost Index: archive/binary_wiarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/binary_wiarchive.hpp,v retrieving revision 1.9 retrieving revision 1.9.6.3 diff -b -d -u -r1.9 -r1.9.6.3 --- archive/binary_wiarchive.hpp 21 Apr 2005 04:51:46 -0000 1.9 +++ archive/binary_wiarchive.hpp 9 Oct 2005 14:57:06 -0000 1.9.6.3 @@ -10,6 +10,7 @@ // binary_wiarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -25,6 +26,8 @@ #include #include #include +#include +#include #include // must be the last header @@ -78,6 +81,15 @@ {} }; +// specialize has_fast_array_serialization +// the binary archive provides fast array serialization for all fundamental types + +template +struct has_fast_array_serialization + : public is_fundamental +{}; + + } // namespace archive } // namespace boost Index: archive/binary_woarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/binary_woarchive.hpp,v retrieving revision 1.5 retrieving revision 1.5.6.3 diff -b -d -u -r1.5 -r1.5.6.3 --- archive/binary_woarchive.hpp 21 Apr 2005 04:51:46 -0000 1.5 +++ archive/binary_woarchive.hpp 9 Oct 2005 14:57:06 -0000 1.5.6.3 @@ -10,6 +10,7 @@ // binary_woarchive.hpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -25,6 +26,8 @@ #include #include #include +#include +#include #include // must be the last header @@ -73,6 +76,15 @@ ~binary_woarchive(){} }; +// specialize has_fast_array_serialization +// the binary archive provides fast array serialization for all fundamental types + +template +struct has_fast_array_serialization + : public is_fundamental +{}; + + } // namespace archive } // namespace boost Index: archive/has_fast_array_serialization.hpp =================================================================== RCS file: archive/has_fast_array_serialization.hpp diff -N archive/has_fast_array_serialization.hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ archive/has_fast_array_serialization.hpp 9 Oct 2005 14:57:06 -0000 1.1.2.1 @@ -0,0 +1,37 @@ +#ifndef BOOST_ARCHIVE_FAST_ARRAY_SERIALIZATION_HPP +#define BOOST_ARCHIVE_FAST_ARRAY_SERIALIZATION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// traits.hpp: + +// (C) Copyright 2005 Matthias Troyer . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// This header is used to define archive traits to customize serialization + +#include + +namespace boost { +namespace archive { + +/// Traits class to specify whether an archive provides fast array serialization for a type + +template +struct has_fast_array_serialization + : public mpl::bool_ +{}; + + +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_FAST_ARRAY_SERIALIZATION_HPP Index: archive/polymorphic_iarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/polymorphic_iarchive.hpp,v retrieving revision 1.22 retrieving revision 1.22.4.5 diff -b -d -u -r1.22 -r1.22.4.5 --- archive/polymorphic_iarchive.hpp 12 Aug 2005 13:02:33 -0000 1.22 +++ archive/polymorphic_iarchive.hpp 9 Oct 2005 14:57:06 -0000 1.22.4.5 @@ -31,6 +31,7 @@ #include #include #include +#include #include // determine if its necessary to handle (u)int64_t specifically @@ -55,33 +56,20 @@ #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS public: #else +protected: friend class detail::interface_iarchive; friend class load_access; #endif // primitive types the only ones permitted by polymorphic archives - virtual void load(bool & t) = 0; - virtual void load(char & t) = 0; - virtual void load(signed char & t) = 0; - virtual void load(unsigned char & t) = 0; - #ifndef BOOST_NO_CWCHAR - #ifndef BOOST_NO_INTRINSIC_WCHAR_T - virtual void load(wchar_t & t) = 0; - #endif - #endif - virtual void load(short & t) = 0; - virtual void load(unsigned short & t) = 0; - virtual void load(int & t) = 0; - virtual void load(unsigned int & t) = 0; - virtual void load(long & t) = 0; - virtual void load(unsigned long & t) = 0; +#define BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(T) \ + virtual void load(T & t) =0; \ + virtual void load_array(T * p, std::size_t len) =0; - #if !defined(BOOST_NO_INTRINSIC_INT64_T) - virtual void load(boost::int64_t & t) = 0; - virtual void load(boost::uint64_t & t) = 0; - #endif - virtual void load(float & t) = 0; - virtual void load(double & t) = 0; + // declare the laod and load_array function for all primitive types +#include + +#undef BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION // string types are treated as primitives virtual void load(std::string & t) = 0; @@ -136,8 +124,15 @@ const boost::serialization::extended_type_info & type ) ) = 0; + + virtual ~polymorphic_iarchive() {} }; +template +struct has_fast_array_serialization + : public is_fundamental +{}; + } // namespace archive } // namespace boost Index: archive/polymorphic_oarchive.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/polymorphic_oarchive.hpp,v retrieving revision 1.21 retrieving revision 1.21.6.5 diff -b -d -u -r1.21 -r1.21.6.5 --- archive/polymorphic_oarchive.hpp 16 Jul 2005 05:15:32 -0000 1.21 +++ archive/polymorphic_oarchive.hpp 9 Oct 2005 14:57:06 -0000 1.21.6.5 @@ -30,6 +30,7 @@ #include #include #include +#include #include // determine if its necessary to handle (u)int64_t specifically @@ -54,32 +55,19 @@ #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS public: #else +protected: friend class detail::interface_oarchive; friend class save_access; #endif // primitive types the only ones permitted by polymorphic archives - virtual void save(const bool t) = 0; +#define BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(T) \ + virtual void save(T const t) =0; \ + virtual void save_array(T const * p, std::size_t len) =0; - virtual void save(const char t) = 0; - virtual void save(const signed char t) = 0; - virtual void save(const unsigned char t) = 0; - #ifndef BOOST_NO_CWCHAR - #ifndef BOOST_NO_INTRINSIC_WCHAR_T - virtual void save(const wchar_t t) = 0; - #endif - #endif - virtual void save(const short t) = 0; - virtual void save(const unsigned short t) = 0; - virtual void save(const int t) = 0; - virtual void save(const unsigned int t) = 0; - virtual void save(const long t) = 0; - virtual void save(const unsigned long t) = 0; - #if !defined(BOOST_NO_INTRINSIC_INT64_T) - virtual void save(const boost::int64_t t) = 0; - virtual void save(const boost::uint64_t t) = 0; - #endif - virtual void save(const float t) = 0; - virtual void save(const double t) = 0; + // declare the save and save_array function for all primitive types +#include + +#undef BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION // string types are treated as primitives virtual void save(const std::string & t) = 0; @@ -128,8 +116,16 @@ const void * t, const detail::basic_pointer_oserializer * bpos_ptr ) = 0; + + virtual ~polymorphic_oarchive() {} + }; +template +struct has_fast_array_serialization + : public is_fundamental +{}; + } // namespace archive } // namespace boost Index: archive/detail/get_data.hpp =================================================================== RCS file: archive/detail/get_data.hpp diff -N archive/detail/get_data.hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ archive/detail/get_data.hpp 29 Sep 2005 20:37:35 -0000 1.1.2.1 @@ -0,0 +1,36 @@ +// (C) Copyright 2005 Matthias Troyer +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#ifndef BOOST_ARCHIVE_DETAIL_GET_DATA_HPP +#define BOOST_ARCHIVE_DETAIL_GET_DATA_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include + +namespace boost { +namespace detail { + + template + T* get_data(std::vector& v) + { + return &(v[0]); + } + + template + const T* get_data(const std::vector& v) + { + return get_data(const_cast&>(v)); + } + +} //namespace detail +} //namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_GET_DATA_HPP Index: archive/detail/implement_polymorphic_function.hpp =================================================================== RCS file: archive/detail/implement_polymorphic_function.hpp diff -N archive/detail/implement_polymorphic_function.hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ archive/detail/implement_polymorphic_function.hpp 29 Sep 2005 20:37:35 -0000 1.1.2.1 @@ -0,0 +1,22 @@ +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(bool) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(char) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(signed char) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(unsigned char) +#ifndef BOOST_NO_CWCHAR +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(wchar_t) +#endif +#endif +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(short) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(unsigned short) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(int) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(unsigned int) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(long) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(unsigned long) +#if !defined(BOOST_NO_INTRINSIC_INT64_T) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(boost::int64_t) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(boost::uint64_t) +#endif +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(float) +BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(double) + Index: archive/detail/iserializer.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/detail/iserializer.hpp,v retrieving revision 1.27 retrieving revision 1.27.4.3 diff -b -d -u -r1.27 -r1.27.4.3 --- archive/detail/iserializer.hpp 12 Aug 2005 13:02:33 -0000 1.27 +++ archive/detail/iserializer.hpp 9 Oct 2005 14:57:06 -0000 1.27.4.3 @@ -77,6 +77,9 @@ #include #include +#include +#include + namespace boost { namespace serialization { @@ -494,21 +497,42 @@ template struct load_array_type { + + template + static void load_array_contents( + Archive &ar, + X *p, + std::size_t count, + typename boost::disable_if >::type* =0 + ){ + std::size_t i; + for(i = 0; i < count; ++i) + ar >> boost::serialization::make_nvp("item", p[i]); + } + + template + static void load_array_contents( + Archive &ar, + X *p, + std::size_t count, + typename boost::enable_if >::type* =0 + ){ + ar.load_array(p,count); + } + static void invoke(Archive &ar, T &t){ - // convert integers to correct enum to load - int current_count = sizeof(t) / ( + // consider alignment + std::size_t current_count = sizeof(t) / ( static_cast(static_cast(&t[1])) - static_cast(static_cast(&t[0])) ); - int count; + container_size_type count; ar >> BOOST_SERIALIZATION_NVP(count); if(count > current_count) boost::throw_exception(archive::archive_exception( boost::archive::archive_exception::array_size_too_short )); - int i; - for(i = 0; i < count; ++i) - ar >> boost::serialization::make_nvp("item", t[i]); + load_array_contents(ar,t,count); } }; Index: archive/detail/oserializer.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/detail/oserializer.hpp,v retrieving revision 1.29 retrieving revision 1.29.4.3 diff -b -d -u -r1.29 -r1.29.4.3 --- archive/detail/oserializer.hpp 12 Aug 2005 13:02:33 -0000 1.29 +++ archive/detail/oserializer.hpp 9 Oct 2005 14:57:06 -0000 1.29.4.3 @@ -56,6 +56,7 @@ // the following is need only for dynamic cast of polymorphic pointers #include +#include #include #include @@ -69,6 +70,9 @@ #include +#include +#include + namespace boost { namespace serialization { @@ -480,17 +484,40 @@ template struct save_array_type { + + template + static void save_array_contents( + Archive &ar, + X const *p, + std::size_t count, + typename boost::disable_if >::type* =0 + ){ + std::size_t i; + for(i = 0; i < count; ++i) + ar << boost::serialization::make_nvp("item", p[i]); + } + + template + static void save_array_contents( + Archive &ar, + X const *p, + std::size_t count, + typename boost::enable_if >::type* =0 + ){ + ar.save_array(p,count); + } + static void invoke(Archive &ar, const T &t){ save_access::end_preamble(ar); // consider alignment - int count = sizeof(t) / ( + std::size_t c = sizeof(t) / ( static_cast(static_cast(&t[1])) - static_cast(static_cast(&t[0])) ); + const container_size_type count(c); ar << BOOST_SERIALIZATION_NVP(count); - int i; - for(i = 0; i < count; ++i) - ar << boost::serialization::make_nvp("item", t[i]); + + save_array_contents(ar,t,count); } }; @@ -557,9 +584,9 @@ template inline void save(Archive & ar, T &t){ - // if your program traps here, it indicates taht your doing one of the following: + // if your program traps here, it indicates that you're doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. - // b) saving an non-const object of a type not markd "track_never) + // b) saving an non-const object of a type not marked "track_never" // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. Index: archive/detail/polymorphic_iarchive_impl.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/detail/polymorphic_iarchive_impl.hpp,v retrieving revision 1.14 retrieving revision 1.14.4.5 diff -b -d -u -r1.14 -r1.14.4.5 --- archive/detail/polymorphic_iarchive_impl.hpp 12 Aug 2005 13:02:33 -0000 1.14 +++ archive/detail/polymorphic_iarchive_impl.hpp 9 Oct 2005 14:57:06 -0000 1.14.4.5 @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #if defined(BOOST_NO_STDC_NAMESPACE) @@ -82,58 +84,45 @@ virtual void load_binary(void * t, std::size_t size){ ArchiveImplementation::load_binary(t, size); } - // primitive types the only ones permitted by polymorphic archives - virtual void load(bool & t){ - ArchiveImplementation::load(t); - } - virtual void load(char & t){ - ArchiveImplementation::load(t); - } - virtual void load(signed char & t){ - ArchiveImplementation::load(t); - } - virtual void load(unsigned char & t){ - ArchiveImplementation::load(t); - } - #ifndef BOOST_NO_CWCHAR - #ifndef BOOST_NO_INTRINSIC_WCHAR_T - virtual void load(wchar_t & t){ - ArchiveImplementation::load(t); - } - #endif - #endif - virtual void load(short & t){ - ArchiveImplementation::load(t); - } - virtual void load(unsigned short & t){ - ArchiveImplementation::load(t); - } - virtual void load(int & t){ - ArchiveImplementation::load(t); - } - virtual void load(unsigned int & t){ - ArchiveImplementation::load(t); - } - virtual void load(long & t){ - ArchiveImplementation::load(t); - } - virtual void load(unsigned long & t){ - ArchiveImplementation::load(t); - } - #if !defined(BOOST_NO_INTRINSIC_INT64_T) - virtual void load(boost::int64_t & t){ - ArchiveImplementation::load(t); - } - virtual void load(boost::uint64_t & t){ - ArchiveImplementation::load(t); + + template + void load_array_impl + ( + T * p, std::size_t len + , typename boost::enable_if >::type * =0 + ) + { + ArchiveImplementation::load_array(p,len); } - #endif - virtual void load(float & t){ - ArchiveImplementation::load(t); + + template + void load_array_impl + ( + T * p, std::size_t len, + typename boost::disable_if >::type * =0 + ) + { + while (len--) + ArchiveImplementation::load(*p++); } - virtual void load(double & t){ - ArchiveImplementation::load(t); + + // primitive types the only ones permitted by polymorphic archives + +#define BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(T) \ + virtual void load(T & t) \ + { \ + ArchiveImplementation::load(t); \ + } \ + \ + virtual void load_array(T * p, std::size_t len) \ + { \ + load_array_impl(p,len); \ } + +#include + +#undef BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION + virtual void load(std::string & t){ ArchiveImplementation::load(t); } Index: archive/detail/polymorphic_oarchive_impl.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/detail/polymorphic_oarchive_impl.hpp,v retrieving revision 1.13 retrieving revision 1.13.6.6 diff -b -d -u -r1.13 -r1.13.6.6 --- archive/detail/polymorphic_oarchive_impl.hpp 2 Jul 2005 05:52:14 -0000 1.13 +++ archive/detail/polymorphic_oarchive_impl.hpp 9 Oct 2005 14:57:06 -0000 1.13.6.6 @@ -21,6 +21,8 @@ #include #include #include // size_t +#include +#include #include #if defined(BOOST_NO_STDC_NAMESPACE) @@ -64,58 +66,45 @@ virtual void save_null_pointer(){ ArchiveImplementation::save_null_pointer(); } - // primitive types the only ones permitted by polymorphic archives - virtual void save(const bool t){ - ArchiveImplementation::save(t); - } - virtual void save(const char t){ - ArchiveImplementation::save(t); - } - virtual void save(const signed char t){ - ArchiveImplementation::save(t); - } - virtual void save(const unsigned char t){ - ArchiveImplementation::save(t); - } - #ifndef BOOST_NO_CWCHAR - #ifndef BOOST_NO_INTRINSIC_WCHAR_T - virtual void save(const wchar_t t){ - ArchiveImplementation::save(t); - } - #endif - #endif - virtual void save(const short t){ - ArchiveImplementation::save(t); - } - virtual void save(const unsigned short t){ - ArchiveImplementation::save(t); - } - virtual void save(const int t){ - ArchiveImplementation::save(t); - } - virtual void save(const unsigned int t){ - ArchiveImplementation::save(t); - } - virtual void save(const long t){ - ArchiveImplementation::save(t); - } - virtual void save(const unsigned long t){ - ArchiveImplementation::save(t); - } - #if !defined(BOOST_NO_INTRINSIC_INT64_T) - virtual void save(const boost::int64_t t){ - ArchiveImplementation::save(t); - } - virtual void save(const boost::uint64_t t){ - ArchiveImplementation::save(t); + + template + void save_array_impl + ( + T const* p, std::size_t len + , typename boost::enable_if >::type * =0 + ) + { + ArchiveImplementation::save_array(p,len); } - #endif - virtual void save(const float t){ - ArchiveImplementation::save(t); + + template + void save_array_impl + ( + T const* p, std::size_t len, + typename boost::disable_if >::type * =0 + ) + { + while (len--) + ArchiveImplementation::save(*p++); } - virtual void save(const double t){ - ArchiveImplementation::save(t); + + // primitive types the only ones permitted by polymorphic archives + +#define BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION(T) \ + virtual void save(T const t) \ + { \ + ArchiveImplementation::save(t); \ + } \ + \ + virtual void save_array(T const * p, std::size_t len) \ + { \ + save_array_impl(p,len); \ } + +#include + +#undef BOOST_ARCHIVE_IMPLEMENT_POLYMPORPHIC_FUNCTION + virtual void save(const std::string & t){ ArchiveImplementation::save(t); } Index: archive/impl/archive_pointer_iserializer.ipp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/impl/archive_pointer_iserializer.ipp,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -b -d -u -r1.6 -r1.6.6.1 --- archive/impl/archive_pointer_iserializer.ipp 11 Jul 2005 01:33:45 -0000 1.6 +++ archive/impl/archive_pointer_iserializer.ipp 1 Oct 2005 20:04:29 -0000 1.6.6.1 @@ -1,3 +1,6 @@ +#ifndef BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_ISERIALIZER_IPP +#define BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_ISERIALIZER_IPP + /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // pointer_iserializer.ipp: @@ -46,3 +49,6 @@ } // namespace detail } // namespace archive } // namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_ISERIALIZER_IPP + Index: archive/impl/archive_pointer_oserializer.ipp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/impl/archive_pointer_oserializer.ipp,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -b -d -u -r1.6 -r1.6.6.1 --- archive/impl/archive_pointer_oserializer.ipp 11 Jul 2005 01:33:45 -0000 1.6 +++ archive/impl/archive_pointer_oserializer.ipp 1 Oct 2005 20:04:29 -0000 1.6.6.1 @@ -1,3 +1,6 @@ +#ifndef BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_OSERIALIZER_IPP +#define BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_OSERIALIZER_IPP + /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // archive_pointer_oserializer.ipp: @@ -47,3 +50,5 @@ } // namespace detail } // namespace archive } // namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_ARCHIVE_POINTER_OSERIALIZER_IPP Index: archive/impl/basic_binary_iarchive.ipp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/impl/basic_binary_iarchive.ipp,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -b -d -u -r1.6 -r1.6.4.1 --- archive/impl/basic_binary_iarchive.ipp 25 Aug 2005 16:27:20 -0000 1.6 +++ archive/impl/basic_binary_iarchive.ipp 1 Oct 2005 20:04:29 -0000 1.6.4.1 @@ -1,3 +1,6 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_BINARY_IARCHIVE_IPP +#define BOOST_ARCHIVE_DETAIL_BASIC_BINARY_IARCHIVE_IPP + /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // basic_binary_iarchive.ipp: @@ -78,3 +81,5 @@ } // namespace archive } // namespace boost + +#endif Index: archive/impl/basic_binary_oarchive.ipp =================================================================== RCS file: /cvsroot/boost/boost/boost/archive/impl/basic_binary_oarchive.ipp,v retrieving revision 1.3 retrieving revision 1.3.6.2 diff -b -d -u -r1.3 -r1.3.6.2 --- archive/impl/basic_binary_oarchive.ipp 2 Jul 2005 05:52:14 -0000 1.3 +++ archive/impl/basic_binary_oarchive.ipp 2 Oct 2005 12:29:02 -0000 1.3.6.2 @@ -1,3 +1,6 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_BINARY_OARCHIVE_IPP +#define BOOST_ARCHIVE_DETAIL_BASIC_BINARY_OARCHIVE_IPP + /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // basic_binary_oarchive.ipp: @@ -44,3 +47,6 @@ } // namespace archive } // namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_BASIC_BINARY_OARCHIVE_IPP + Index: serialization/collections_load_imp.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/collections_load_imp.hpp,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -b -d -u -r1.9 -r1.9.4.1 --- serialization/collections_load_imp.hpp 12 Aug 2005 13:02:33 -0000 1.9 +++ serialization/collections_load_imp.hpp 25 Sep 2005 15:04:59 -0000 1.9.4.1 @@ -14,6 +14,7 @@ // collections_load_imp.hpp: serialization for loading stl collections // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// size_type modifications (C) Copyright 2005 Matthias Troyer. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -32,6 +33,8 @@ #include #include +#include + namespace boost{ namespace serialization { @@ -182,7 +185,7 @@ class reserve_imp { public: - void operator()(Container &s, unsigned int count) const { + void operator()(Container &s, std::size_t count) const { s.reserve(count); } }; @@ -191,7 +194,7 @@ class no_reserve_imp { public: - void operator()(Container & /* s */, unsigned int /* count */) const{} + void operator()(Container & /* s */, std::size_t /* count */) const{} }; template @@ -199,7 +202,7 @@ { s.clear(); // retrieve number of elements - unsigned int count; + boost::archive::container_size_type count; ar >> BOOST_SERIALIZATION_NVP(count); R rx; rx(s, count); @@ -213,7 +216,7 @@ inline void copy_collection(Archive & ar, Container &s) { // retrieve number of elements - unsigned int count; + boost::archive::container_size_type count; ar >> BOOST_SERIALIZATION_NVP(count); assert(count == s.size()); BOOST_DEDUCED_TYPENAME Container::iterator it = s.begin(); Index: serialization/collections_save_imp.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/collections_save_imp.hpp,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -b -d -u -r1.8 -r1.8.4.1 --- serialization/collections_save_imp.hpp 12 Aug 2005 13:02:33 -0000 1.8 +++ serialization/collections_save_imp.hpp 25 Sep 2005 15:04:59 -0000 1.8.4.1 @@ -10,6 +10,7 @@ // collections_save_imp.hpp: serialization for stl collections // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// size_type modifications (C) Copyright 2005 Matthias Troyer. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -21,6 +22,8 @@ #include #include +#include + namespace boost{ namespace serialization { namespace stl { @@ -33,8 +36,8 @@ inline void save_collection(Archive & ar, const Container &s) { // record number of elements - unsigned int count = s.size(); - ar << make_nvp("count", const_cast(count)); + boost::archive::container_size_type count (s.size()); + ar << make_nvp("count", const_cast(count)); BOOST_DEDUCED_TYPENAME Container::const_iterator it = s.begin(); while(count-- > 0){ //if(0 == (ar.get_flags() & boost::archive::no_object_creation)) Index: serialization/vector.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/serialization/vector.hpp,v retrieving revision 1.5 retrieving revision 1.5.6.3 diff -b -d -u -r1.5 -r1.5.6.3 --- serialization/vector.hpp 27 Jan 2005 17:51:49 -0000 1.5 +++ serialization/vector.hpp 9 Oct 2005 10:17:46 -0000 1.5.6.3 @@ -10,6 +10,7 @@ // vector.hpp: serialization for stl vector templates // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Fast array serialization (C) Copyright 2005 Matthias Troyer // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -25,6 +26,10 @@ #include #include +#include +#include +#include + // function specializations must be defined in the appropriate // namespace - boost::serialization #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) @@ -42,18 +47,35 @@ inline void save( Archive & ar, const STD::vector &t, - const unsigned int /* file_version */ + const unsigned int /* file_version */ , + typename boost::disable_if >::type* =0 ){ boost::serialization::stl::save_collection >( ar, t ); } +// with fast array serialization +template +inline void save( + Archive & ar, + const STD::vector &t, + const unsigned int /* file_version */, + typename boost::enable_if >::type* =0 +){ + const boost::archive::container_size_type count(t.size()); + ar << BOOST_SERIALIZATION_NVP(count); + if (count) + ar.save_array(boost::detail::get_data(t),t.size()); +} + + template inline void load( Archive & ar, STD::vector &t, - const unsigned int /* file_version */ + const unsigned int /* file_version */, + typename boost::disable_if >::type* =0 ){ boost::serialization::stl::load_collection< Archive, @@ -65,6 +87,24 @@ >(ar, t); } +template +inline void load( + Archive & ar, + STD::vector &t, + const unsigned int /* file_version */, + typename boost::enable_if >::type* =0 +){ + t.clear(); + // retrieve number of elements + boost::archive::container_size_type count; + ar >> BOOST_SERIALIZATION_NVP(count); + if (count) + { + t.resize(count); + ar.load_array(boost::detail::get_data(t),t.size()); + } +} + // split non-intrusive serialization function member into separate // non intrusive save/load member functions template @@ -87,7 +127,7 @@ const unsigned int /* file_version */ ){ // record number of elements - unsigned int count = t.size(); + boost::archive::container_size_type count = t.size(); ar << BOOST_SERIALIZATION_NVP(count); STD::vector::const_iterator it = t.begin(); while(count-- > 0){ @@ -103,7 +143,7 @@ const unsigned int /* file_version */ ){ // retrieve number of elements - unsigned int count; + boost::archive::container_size_type count; ar >> BOOST_SERIALIZATION_NVP(count); t.clear(); while(count-- > 0){