From a48627576062246c0dcaa1c5c3c3d21b075f6d9c Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Fri, 17 Jun 2005 05:51:05 +0000 Subject: [PATCH] fixup helpers [SVN r29644] --- src/basic_archive_impl.cpp | 48 ++++++++++++++++ src/basic_iarchive.cpp | 108 ++++++++---------------------------- src/basic_oarchive.cpp | 110 +++++++------------------------------ 3 files changed, 91 insertions(+), 175 deletions(-) create mode 100644 src/basic_archive_impl.cpp diff --git a/src/basic_archive_impl.cpp b/src/basic_archive_impl.cpp new file mode 100644 index 00000000..89232451 --- /dev/null +++ b/src/basic_archive_impl.cpp @@ -0,0 +1,48 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_archive.cpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// 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. +#include +#include + +#define BOOST_ARCHIVE_SOURCE +#include +#include + +namespace boost { +namespace archive { +namespace detail { + +void +BOOST_DECL_ARCHIVE +basic_archive_impl::lookup_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + helper_iterator it; + const helper_type ht(sph, eti); + it = m_helpers.find(ht); + if(it == m_helpers.end()) + sph.reset(); + else + sph = it->m_helper; +} + +void +BOOST_DECL_ARCHIVE +basic_archive_impl::insert_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + const helper_type ht(sph, eti); + std::pair result = m_helpers.insert(ht); +} + +} // namespace detail +} // namespace serialization +} // namespace boost \ No newline at end of file diff --git a/src/basic_iarchive.cpp b/src/basic_iarchive.cpp index 17b189a7..fed103eb 100644 --- a/src/basic_iarchive.cpp +++ b/src/basic_iarchive.cpp @@ -33,11 +33,11 @@ namespace std{ #include #include #include +#include #include #include #include -#include using namespace boost::serialization; @@ -48,7 +48,8 @@ namespace detail { class basic_iserializer; class basic_pointer_iserializer; -class basic_iarchive_impl +class basic_iarchive_impl : + public basic_archive_impl { friend class basic_iarchive; @@ -192,36 +193,6 @@ class basic_iarchive_impl const basic_iserializer * pending_bis; version_type pending_version; - ////////////////////////////////////////////////////////////////////// - // list of serialization helpers - // at least one compiler sunpro 5.3 erroneously doesn't give access to embedded structs - struct helper_compare; - friend struct helper_compare; - - struct helper_type { - boost::serialization::basic_helper * m_helper; - const boost::serialization::extended_type_info * m_eti; - helper_type( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * const eti - ) : - m_helper(h), - m_eti(eti) - {} - }; - - struct helper_compare { - bool operator()(const helper_type & lhs, const helper_type & rhs) const { - return * lhs.m_eti < * rhs.m_eti; - } - }; - - typedef std::set::iterator helper_iterator; - typedef std::set::const_iterator - helper_const_iterator; - - std::set m_helpers; - basic_iarchive_impl(unsigned int flags) : m_archive_library_version(ARCHIVE_VERSION()), m_flags(flags), @@ -230,16 +201,7 @@ class basic_iarchive_impl pending_bis(NULL), pending_version(0) {} - ~basic_iarchive_impl(){ - // delete helpers - for( - helper_iterator it = m_helpers.begin(); - it != m_helpers.end(); - ++it - ){ - delete it->m_helper; - } - } + ~basic_iarchive_impl(){} void set_library_version(unsigned int archive_library_version){ m_archive_library_version = archive_library_version; } @@ -285,23 +247,6 @@ class basic_iarchive_impl const boost::serialization::extended_type_info & type ) ); - boost::serialization::basic_helper * lookup_helper( - const boost::serialization::extended_type_info * const eti - ){ - helper_iterator it; - const helper_type ht(NULL, eti); - it = m_helpers.find(ht); - return (it == m_helpers.end()) ? NULL : it->m_helper; - } - boost::serialization::basic_helper* insert_helper( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * const eti - ){ - std::pair result = m_helpers.insert( - helper_type(h, eti) - ); - return (*result.first).m_helper; - } }; inline void @@ -620,6 +565,24 @@ basic_iarchive::register_basic_serializer(const basic_iserializer & bis){ pimpl->register_type(bis); } +void +BOOST_DECL_ARCHIVE +basic_iarchive::lookup_basic_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + pimpl->lookup_helper(eti, sph); +} + +void +BOOST_DECL_ARCHIVE +basic_iarchive::insert_basic_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + pimpl->insert_helper(eti, sph); +} + void BOOST_DECL_ARCHIVE basic_iarchive::delete_created_pointers() @@ -639,33 +602,6 @@ basic_iarchive::get_flags() const{ return pimpl->m_flags; } -#if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MWERKS__) - BOOST_DECL_ARCHIVE - boost::serialization::basic_helper * -#else - boost::serialization::basic_helper * - BOOST_DECL_ARCHIVE -#endif -basic_iarchive::lookup_helper( - const boost::serialization::extended_type_info * const eti -){ - return pimpl->lookup_helper(eti); -} - -#if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MWERKS__) - BOOST_DECL_ARCHIVE - boost::serialization::basic_helper * -#else - boost::serialization::basic_helper * - BOOST_DECL_ARCHIVE -#endif -basic_iarchive::insert_helper( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * const eti -){ - return pimpl->insert_helper(h, eti); -} - } // namespace detail } // namespace archive } // namespace boost diff --git a/src/basic_oarchive.cpp b/src/basic_oarchive.cpp index 3e900399..e4a1b1d3 100644 --- a/src/basic_oarchive.cpp +++ b/src/basic_oarchive.cpp @@ -25,10 +25,9 @@ #include #include #include +#include #include -#include - #ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable : 4251 4231 4660 4275) @@ -46,7 +45,8 @@ namespace detail { class basic_oserializer; class basic_pointer_oserializer; -class basic_oarchive_impl +class basic_oarchive_impl : + public basic_archive_impl { friend class basic_oarchive; @@ -136,37 +136,6 @@ class basic_oarchive_impl // keyed on object id std::set stored_pointers; - ////////////////////////////////////////////////////////////////////// - // list of serialization helpers - // at least one compiler sunpro 5.3 erroneously doesn't give access to embedded structs - struct helper_compare; - friend struct helper_compare; - - struct helper_type { - boost::serialization::basic_helper * m_helper; - const boost::serialization::extended_type_info * m_eti; - helper_type( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * eti - ) : - m_helper(h), - m_eti(eti) - {} - }; - - struct helper_compare { - bool operator()(const helper_type & lhs, const helper_type & rhs) const { - return * lhs.m_eti < * rhs.m_eti; - } - }; - - typedef std::set::iterator - helper_iterator; - typedef std::set::const_iterator - helper_const_iterator; - - std::set m_helpers; - // address of the most recent object serialized as a poiner // whose data itself is now pending serialization const void * pending_object; @@ -178,17 +147,6 @@ class basic_oarchive_impl pending_bos(NULL) {} - ~basic_oarchive_impl(){ - // delete helpers - for( - helper_iterator it = m_helpers.begin(); - it != m_helpers.end(); - ++it - ){ - delete it->m_helper; - } - } - const cobject_type & find(const basic_oserializer & bos); const basic_oserializer * @@ -207,23 +165,6 @@ class basic_oarchive_impl const void * t, const basic_pointer_oserializer * bpos ); - boost::serialization::basic_helper * lookup_helper( - const boost::serialization::extended_type_info * const eti - ){ - helper_iterator it; - const helper_type ht(NULL, eti); - it = m_helpers.find(ht); - return (it == m_helpers.end()) ? NULL : it->m_helper; - } - basic_helper * insert_helper( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * const eti - ){ - std::pair result = m_helpers.insert( - helper_type(h, eti) - ); - return (*result.first).m_helper; - } }; ////////////////////////////////////////////////////////////////////// @@ -486,6 +427,24 @@ basic_oarchive::register_basic_serializer(const basic_oserializer & bos){ pimpl->register_type(bos); } +void +BOOST_DECL_ARCHIVE +basic_oarchive::lookup_basic_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + pimpl->lookup_helper(eti, sph); +} + +void +BOOST_DECL_ARCHIVE +basic_oarchive::insert_basic_helper( + const boost::serialization::extended_type_info * const eti, + shared_ptr & sph +){ + pimpl->insert_helper(eti, sph); +} + unsigned int BOOST_DECL_ARCHIVE basic_oarchive::get_library_version() const{ @@ -503,33 +462,6 @@ BOOST_DECL_ARCHIVE basic_oarchive::end_preamble(){ } -#if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MWERKS__) - BOOST_DECL_ARCHIVE - boost::serialization::basic_helper * -#else - boost::serialization::basic_helper * - BOOST_DECL_ARCHIVE -#endif -basic_oarchive::lookup_helper( - const boost::serialization::extended_type_info * const eti -){ - return pimpl->lookup_helper(eti); -} - -#if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MWERKS__) - BOOST_DECL_ARCHIVE - boost::serialization::basic_helper * -#else - boost::serialization::basic_helper * - BOOST_DECL_ARCHIVE -#endif -basic_oarchive::insert_helper( - boost::serialization::basic_helper * h, - const boost::serialization::extended_type_info * const eti -){ - return pimpl->insert_helper(h, eti); -} - } // namespace detail } // namespace archive } // namespace boost