diff --git a/src/basic_iarchive.cpp b/src/basic_iarchive.cpp index 6bce3643..5a3773eb 100644 --- a/src/basic_iarchive.cpp +++ b/src/basic_iarchive.cpp @@ -51,6 +51,7 @@ class basic_iarchive_impl { friend class basic_iarchive; version_type m_archive_library_version; unsigned int m_flags; + const basic_iarchive * m_this; ////////////////////////////////////////////////////////////////////// // information about each serialized object loaded @@ -161,9 +162,10 @@ class basic_iarchive_impl { const basic_iserializer * pending_bis; version_type pending_version; - basic_iarchive_impl(unsigned int flags) : + basic_iarchive_impl(const basic_iarchive * parent, unsigned int flags) : m_archive_library_version(BOOST_ARCHIVE_VERSION()), m_flags(flags), + m_this(parent), moveable_objects_start(0), moveable_objects_end(0), moveable_objects_recent(0), @@ -212,10 +214,7 @@ class basic_iarchive_impl { const basic_pointer_iserializer * load_pointer( basic_iarchive & ar, void * & t, - const basic_pointer_iserializer * bpis, - const basic_pointer_iserializer * (*finder)( - const boost::serialization::extended_type_info & type - ) + const basic_pointer_iserializer * bpis ); }; @@ -396,10 +395,7 @@ inline const basic_pointer_iserializer * basic_iarchive_impl::load_pointer( basic_iarchive &ar, void * & t, - const basic_pointer_iserializer * bpis_ptr, - const basic_pointer_iserializer * (*finder)( - const boost::serialization::extended_type_info & type_ - ) + const basic_pointer_iserializer * bpis_ptr ){ class_id_type cid; load(ar, cid); @@ -427,7 +423,7 @@ basic_iarchive_impl::load_pointer( boost::serialization::throw_exception( archive_exception(archive_exception::unregistered_class) ); - bpis_ptr = (*finder)(*eti); + bpis_ptr = m_this->find(*eti); } assert(NULL != bpis_ptr); class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer()); @@ -503,7 +499,7 @@ basic_iarchive::next_object_pointer(void *t){ BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive::basic_iarchive(unsigned int flags) : - pimpl(new basic_iarchive_impl(flags)) + pimpl(new basic_iarchive_impl(this, flags)) {} BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) @@ -537,12 +533,9 @@ basic_iarchive::load_object( BOOST_ARCHIVE_DECL(const basic_pointer_iserializer *) basic_iarchive::load_pointer( void * &t, - const basic_pointer_iserializer * bpis_ptr, - const basic_pointer_iserializer * (*finder)( - const boost::serialization::extended_type_info & type_ - ) + const basic_pointer_iserializer * bpis_ptr ){ - return pimpl->load_pointer(*this, t, bpis_ptr, finder); + return pimpl->load_pointer(*this, t, bpis_ptr); } BOOST_ARCHIVE_DECL(void) diff --git a/src/basic_serializer_map.cpp b/src/basic_serializer_map.cpp index c6c24486..fccf827a 100644 --- a/src/basic_serializer_map.cpp +++ b/src/basic_serializer_map.cpp @@ -12,7 +12,7 @@ # pragma warning (disable : 4786) // too long name, harmless warning #endif -#include // for NULL +#include #define BOOST_ARCHIVE_SOURCE #include @@ -25,61 +25,38 @@ namespace boost { namespace archive { namespace detail { -#if 0 -BOOST_ARCHIVE_DECL(bool) -type_info_pointer_compare::operator()( +bool +basic_serializer_map::type_info_pointer_compare::operator()( const basic_serializer * lhs, const basic_serializer * rhs ) const { return *lhs < *rhs; } -class basic_serializer_arg : public basic_serializer { -public: - basic_serializer_arg(const serialization::extended_type_info & eti) : - basic_serializer(eti) - {} -}; -#endif - -} // namespace detail -} // namespace archive -} // namespace boost - -#if 0 -BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) -basic_serializer_map::basic_serializer_map(bool & deleted) : - m_deleted(deleted) -{ - m_deleted = false; -} - -BOOST_ARCHIVE_DECL(const basic_serializer *) -basic_serializer_map::tfind( - const boost::serialization::extended_type_info & eti -) const { - const basic_serializer_arg bs(eti); - map_type::const_iterator it; - boost::serialization::singleton::lease l; - it = l->m_map.find(& bs); - if(it == l->m_map.end()) - return NULL; - return *it; -} - -BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) -basic_serializer_map::~basic_serializer_map(){ - m_deleted = true; -} - BOOST_ARCHIVE_DECL(bool) basic_serializer_map::insert(const basic_serializer * bs){ - boost::serialization::singleton::lease l; - return l->m_map.insert(bs).second; + return m_map.insert(bs).second; } BOOST_ARCHIVE_DECL(void) basic_serializer_map::erase(basic_serializer * bs){ - boost::serialization::singleton::lease l; - l->m_map.erase(bs); + map_type::iterator it; + it = m_map.find(bs); + assert(it != m_map.end()); + if(*it == bs) + m_map.erase(it); } -#endif + +BOOST_ARCHIVE_DECL(const basic_serializer *) +basic_serializer_map::find( + const boost::serialization::extended_type_info & eti +) const { + const basic_serializer_arg bs(eti); + map_type::const_iterator it; + it = m_map.find(& bs); + assert(it != m_map.end()); + return *it; +} + +} // namespace detail +} // namespace archive +} // namespace boost diff --git a/src/binary_iarchive.cpp b/src/binary_iarchive.cpp index 964cc8b5..8c8603e1 100644 --- a/src/binary_iarchive.cpp +++ b/src/binary_iarchive.cpp @@ -15,7 +15,6 @@ #include #include -#include namespace boost { namespace archive { @@ -32,7 +31,6 @@ template class binary_iarchive_impl< std::istream::char_type, std::istream::traits_type >; -template class detail::archive_pointer_iserializer ; // explicitly instantiate for this type of stream template class basic_binary_iprimitive< @@ -46,7 +44,6 @@ template class binary_iarchive_impl< std::istream::char_type, std::istream::traits_type >; -template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost diff --git a/src/binary_oarchive.cpp b/src/binary_oarchive.cpp index ca863afd..4a4b4e91 100644 --- a/src/binary_oarchive.cpp +++ b/src/binary_oarchive.cpp @@ -15,7 +15,6 @@ #include #include -#include namespace boost { namespace archive { @@ -32,7 +31,6 @@ template class binary_oarchive_impl< std::ostream::char_type, std::ostream::traits_type >; -template class detail::archive_pointer_oserializer ; } // namespace archive } // namespace boost diff --git a/src/binary_wiarchive.cpp b/src/binary_wiarchive.cpp index 0da042cd..b2da8947 100644 --- a/src/binary_wiarchive.cpp +++ b/src/binary_wiarchive.cpp @@ -19,7 +19,6 @@ #include #include -#include namespace boost { namespace archive { @@ -36,7 +35,6 @@ template class binary_iarchive_impl< wchar_t, std::char_traits >; -template class detail::archive_pointer_iserializer ; // explicitly instantiate for this type of text stream template class basic_binary_iprimitive< @@ -50,7 +48,6 @@ template class binary_iarchive_impl< wchar_t, std::char_traits >; -template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost diff --git a/src/binary_woarchive.cpp b/src/binary_woarchive.cpp index 8c72ee02..d1ae54a2 100644 --- a/src/binary_woarchive.cpp +++ b/src/binary_woarchive.cpp @@ -19,7 +19,6 @@ #include #include -#include namespace boost { namespace archive { @@ -36,7 +35,6 @@ template class binary_oarchive_impl< wchar_t, std::char_traits >; -template class detail::archive_pointer_oserializer ; } // namespace archive } // namespace boost diff --git a/src/polymorphic_iarchive.cpp b/src/polymorphic_iarchive.cpp index 93f6bd37..205929d8 100644 --- a/src/polymorphic_iarchive.cpp +++ b/src/polymorphic_iarchive.cpp @@ -16,14 +16,3 @@ #define BOOST_ARCHIVE_SOURCE #include - -// explicitly instantiate for this type of text stream -#include - -namespace boost { -namespace archive { - -template class detail::archive_pointer_iserializer ; - -} // namespace serialization -} // namespace boost diff --git a/src/polymorphic_oarchive.cpp b/src/polymorphic_oarchive.cpp index 0e04e1f0..3b1cf14c 100644 --- a/src/polymorphic_oarchive.cpp +++ b/src/polymorphic_oarchive.cpp @@ -16,14 +16,3 @@ #define BOOST_ARCHIVE_SOURCE #include - -// explicitly instantiate for this type of text stream -#include - -namespace boost { -namespace archive { - -template class detail::archive_pointer_oserializer ; - -} // namespace archive -} // namespace boost diff --git a/src/text_iarchive.cpp b/src/text_iarchive.cpp index 129cfdb4..67f580ee 100644 --- a/src/text_iarchive.cpp +++ b/src/text_iarchive.cpp @@ -14,18 +14,15 @@ // explicitly instantiate for this type of text stream #include #include -#include namespace boost { namespace archive { template class basic_text_iarchive ; template class text_iarchive_impl ; -template class detail::archive_pointer_iserializer ; template class basic_text_iarchive ; template class text_iarchive_impl ; -template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost diff --git a/src/text_oarchive.cpp b/src/text_oarchive.cpp index 1d802844..38ba6598 100644 --- a/src/text_oarchive.cpp +++ b/src/text_oarchive.cpp @@ -18,7 +18,6 @@ // explicitly instantiate for this type of text stream #include #include -#include namespace boost { namespace archive { @@ -26,7 +25,6 @@ namespace archive { //template class basic_text_oprimitive ; template class basic_text_oarchive ; template class text_oarchive_impl ; -template class detail::archive_pointer_oserializer ; } // namespace serialization } // namespace boost diff --git a/src/text_wiarchive.cpp b/src/text_wiarchive.cpp index da47a9b5..39f2e61f 100644 --- a/src/text_wiarchive.cpp +++ b/src/text_wiarchive.cpp @@ -20,18 +20,15 @@ // explicitly instantiate for this type of text stream #include #include -#include namespace boost { namespace archive { template class basic_text_iarchive ; template class text_wiarchive_impl ; -template class detail::archive_pointer_iserializer ; template class basic_text_iarchive ; template class text_wiarchive_impl ; -template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost diff --git a/src/text_woarchive.cpp b/src/text_woarchive.cpp index 455872c4..b5ed44b4 100644 --- a/src/text_woarchive.cpp +++ b/src/text_woarchive.cpp @@ -18,14 +18,12 @@ #include #include -#include namespace boost { namespace archive { template class basic_text_oarchive ; template class text_woarchive_impl ; -template class detail::archive_pointer_oserializer ; } // namespace archive } // namespace boost diff --git a/src/xml_iarchive.cpp b/src/xml_iarchive.cpp index bf293347..347210b0 100644 --- a/src/xml_iarchive.cpp +++ b/src/xml_iarchive.cpp @@ -27,18 +27,15 @@ // explicitly instantiate for this type of xml stream #include -#include #include namespace boost { namespace archive { template class basic_xml_iarchive ; -template class detail::archive_pointer_iserializer ; template class xml_iarchive_impl ; template class basic_xml_iarchive ; -template class detail::archive_pointer_iserializer ; template class xml_iarchive_impl ; } // namespace archive diff --git a/src/xml_oarchive.cpp b/src/xml_oarchive.cpp index cf9456b5..343fba0a 100644 --- a/src/xml_oarchive.cpp +++ b/src/xml_oarchive.cpp @@ -16,7 +16,6 @@ #include #include -#include #include namespace boost { @@ -24,7 +23,6 @@ namespace archive { // explicitly instantiate for this type of xml stream template class basic_xml_oarchive ; -template class detail::archive_pointer_oserializer ; template class xml_oarchive_impl ; } // namespace archive diff --git a/src/xml_wiarchive.cpp b/src/xml_wiarchive.cpp index c91473e1..d0090e67 100644 --- a/src/xml_wiarchive.cpp +++ b/src/xml_wiarchive.cpp @@ -33,18 +33,15 @@ // explicitly instantiate for this type of xml stream #include #include -#include namespace boost { namespace archive { template class basic_xml_iarchive ; template class xml_wiarchive_impl ; -template class detail::archive_pointer_iserializer ; template class basic_xml_iarchive ; template class xml_wiarchive_impl ; -template class detail::archive_pointer_iserializer ; } // namespace archive } // namespace boost diff --git a/src/xml_woarchive.cpp b/src/xml_woarchive.cpp index 527da3ef..135ee2d5 100644 --- a/src/xml_woarchive.cpp +++ b/src/xml_woarchive.cpp @@ -21,44 +21,12 @@ #include #include -#include namespace boost { namespace archive { -#if 0 -BOOST_WARCHIVE_DECL(std::wostream &) -operator<<(std::wostream &os, const char *t){ - for(;;){ - wchar_t wc; - int result = std::mbtowc(&wc, t, 10 /* max number */); - if(0 < result) - os.put(wc); - else - if(0 == result) - break; - else - boost::serialization::throw_exception( - iterators::dataflow_exception( - iterators::dataflow_exception::invalid_conversion - ) - ); - } - return os; -} - -BOOST_WARCHIVE_DECL(std::wostream &) -operator<<(std::wostream &os, const char t){ - wchar_t wc; - std::mbtowc(&wc, &t, 1); - os.put(wc); - return os; -} -#endif - template class basic_xml_oarchive ; template class xml_woarchive_impl ; -template class detail::archive_pointer_oserializer ; } // namespace archive } // namespace boost