|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54936 - trunk/libs/serialization/src
From: ramey_at_[hidden]
Date: 2009-07-13 17:42:15
Author: ramey
Date: 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
New Revision: 54936
URL: http://svn.boost.org/trac/boost/changeset/54936
Log:
Simplification for pointer serialization
Correct error in exported pointers for polymorphic archives
Text files modified:
trunk/libs/serialization/src/basic_iarchive.cpp | 25 +++++----------
trunk/libs/serialization/src/basic_serializer_map.cpp | 63 ++++++++++++---------------------------
trunk/libs/serialization/src/binary_iarchive.cpp | 3 -
trunk/libs/serialization/src/binary_oarchive.cpp | 2 -
trunk/libs/serialization/src/binary_wiarchive.cpp | 3 -
trunk/libs/serialization/src/binary_woarchive.cpp | 2 -
trunk/libs/serialization/src/polymorphic_iarchive.cpp | 11 ------
trunk/libs/serialization/src/polymorphic_oarchive.cpp | 11 ------
trunk/libs/serialization/src/text_iarchive.cpp | 3 -
trunk/libs/serialization/src/text_oarchive.cpp | 2 -
trunk/libs/serialization/src/text_wiarchive.cpp | 3 -
trunk/libs/serialization/src/text_woarchive.cpp | 2 -
trunk/libs/serialization/src/xml_iarchive.cpp | 3 -
trunk/libs/serialization/src/xml_oarchive.cpp | 2 -
trunk/libs/serialization/src/xml_wiarchive.cpp | 3 -
trunk/libs/serialization/src/xml_woarchive.cpp | 32 --------------------
16 files changed, 29 insertions(+), 141 deletions(-)
Modified: trunk/libs/serialization/src/basic_iarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/basic_iarchive.cpp (original)
+++ trunk/libs/serialization/src/basic_iarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -51,6 +51,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
Modified: trunk/libs/serialization/src/basic_serializer_map.cpp
==============================================================================
--- trunk/libs/serialization/src/basic_serializer_map.cpp (original)
+++ trunk/libs/serialization/src/basic_serializer_map.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -12,7 +12,7 @@
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
-#include <stdlib.h> // for NULL
+#include <set>
#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/detail/basic_serializer.hpp>
@@ -25,61 +25,38 @@
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
+BOOST_ARCHIVE_DECL(bool)
+basic_serializer_map::insert(const basic_serializer * bs){
+ return m_map.insert(bs).second;
+}
-#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(void)
+basic_serializer_map::erase(basic_serializer * bs){
+ map_type::iterator it;
+ it = m_map.find(bs);
+ assert(it != m_map.end());
+ if(*it == bs)
+ m_map.erase(it);
}
BOOST_ARCHIVE_DECL(const basic_serializer *)
-basic_serializer_map::tfind(
+basic_serializer_map::find(
const boost::serialization::extended_type_info & eti
) const {
const basic_serializer_arg bs(eti);
map_type::const_iterator it;
- boost::serialization::singleton<basic_serializer_map>::lease l;
- it = l->m_map.find(& bs);
- if(it == l->m_map.end())
- return NULL;
+ it = m_map.find(& bs);
+ assert(it != m_map.end());
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<basic_serializer_map>::lease l;
- return l->m_map.insert(bs).second;
-}
-
-BOOST_ARCHIVE_DECL(void)
-basic_serializer_map::erase(basic_serializer * bs){
- boost::serialization::singleton<basic_serializer_map>::lease l;
- l->m_map.erase(bs);
-}
-#endif
+} // namespace detail
+} // namespace archive
+} // namespace boost
Modified: trunk/libs/serialization/src/binary_iarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/binary_iarchive.cpp (original)
+++ trunk/libs/serialization/src/binary_iarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -15,7 +15,6 @@
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
namespace boost {
namespace archive {
@@ -32,7 +31,6 @@
std::istream::char_type,
std::istream::traits_type
>;
-template class detail::archive_pointer_iserializer<naked_binary_iarchive> ;
// explicitly instantiate for this type of stream
template class basic_binary_iprimitive<
@@ -46,7 +44,6 @@
std::istream::char_type,
std::istream::traits_type
>;
-template class detail::archive_pointer_iserializer<binary_iarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/binary_oarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/binary_oarchive.cpp (original)
+++ trunk/libs/serialization/src/binary_oarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -15,7 +15,6 @@
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
namespace boost {
namespace archive {
@@ -32,7 +31,6 @@
std::ostream::char_type,
std::ostream::traits_type
>;
-template class detail::archive_pointer_oserializer<binary_oarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/binary_wiarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/binary_wiarchive.cpp (original)
+++ trunk/libs/serialization/src/binary_wiarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -19,7 +19,6 @@
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
namespace boost {
namespace archive {
@@ -36,7 +35,6 @@
wchar_t,
std::char_traits<wchar_t>
>;
-template class detail::archive_pointer_iserializer<naked_binary_wiarchive> ;
// explicitly instantiate for this type of text stream
template class basic_binary_iprimitive<
@@ -50,7 +48,6 @@
wchar_t,
std::char_traits<wchar_t>
>;
-template class detail::archive_pointer_iserializer<binary_wiarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/binary_woarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/binary_woarchive.cpp (original)
+++ trunk/libs/serialization/src/binary_woarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -19,7 +19,6 @@
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
namespace boost {
namespace archive {
@@ -36,7 +35,6 @@
wchar_t,
std::char_traits<wchar_t>
>;
-template class detail::archive_pointer_oserializer<binary_woarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/polymorphic_iarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/polymorphic_iarchive.cpp (original)
+++ trunk/libs/serialization/src/polymorphic_iarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -16,14 +16,3 @@
#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/polymorphic_iarchive.hpp>
-
-// explicitly instantiate for this type of text stream
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
-
-namespace boost {
-namespace archive {
-
-template class detail::archive_pointer_iserializer<polymorphic_iarchive> ;
-
-} // namespace serialization
-} // namespace boost
Modified: trunk/libs/serialization/src/polymorphic_oarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/polymorphic_oarchive.cpp (original)
+++ trunk/libs/serialization/src/polymorphic_oarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -16,14 +16,3 @@
#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/polymorphic_oarchive.hpp>
-
-// explicitly instantiate for this type of text stream
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
-
-namespace boost {
-namespace archive {
-
-template class detail::archive_pointer_oserializer<polymorphic_oarchive> ;
-
-} // namespace archive
-} // namespace boost
Modified: trunk/libs/serialization/src/text_iarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/text_iarchive.cpp (original)
+++ trunk/libs/serialization/src/text_iarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -14,18 +14,15 @@
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/basic_text_iarchive.ipp>
#include <boost/archive/impl/text_iarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
namespace boost {
namespace archive {
template class basic_text_iarchive<naked_text_iarchive> ;
template class text_iarchive_impl<naked_text_iarchive> ;
-template class detail::archive_pointer_iserializer<naked_text_iarchive> ;
template class basic_text_iarchive<text_iarchive> ;
template class text_iarchive_impl<text_iarchive> ;
-template class detail::archive_pointer_iserializer<text_iarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/text_oarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/text_oarchive.cpp (original)
+++ trunk/libs/serialization/src/text_oarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -18,7 +18,6 @@
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/basic_text_oarchive.ipp>
#include <boost/archive/impl/text_oarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
namespace boost {
namespace archive {
@@ -26,7 +25,6 @@
//template class basic_text_oprimitive<std::ostream> ;
template class basic_text_oarchive<text_oarchive> ;
template class text_oarchive_impl<text_oarchive> ;
-template class detail::archive_pointer_oserializer<text_oarchive> ;
} // namespace serialization
} // namespace boost
Modified: trunk/libs/serialization/src/text_wiarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/text_wiarchive.cpp (original)
+++ trunk/libs/serialization/src/text_wiarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -20,18 +20,15 @@
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/basic_text_iarchive.ipp>
#include <boost/archive/impl/text_wiarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
namespace boost {
namespace archive {
template class basic_text_iarchive<naked_text_wiarchive> ;
template class text_wiarchive_impl<naked_text_wiarchive> ;
-template class detail::archive_pointer_iserializer<naked_text_wiarchive> ;
template class basic_text_iarchive<text_wiarchive> ;
template class text_wiarchive_impl<text_wiarchive> ;
-template class detail::archive_pointer_iserializer<text_wiarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/text_woarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/text_woarchive.cpp (original)
+++ trunk/libs/serialization/src/text_woarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -18,14 +18,12 @@
#include <boost/archive/impl/basic_text_oarchive.ipp>
#include <boost/archive/impl/text_woarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
namespace boost {
namespace archive {
template class basic_text_oarchive<text_woarchive> ;
template class text_woarchive_impl<text_woarchive> ;
-template class detail::archive_pointer_oserializer<text_woarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/xml_iarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/xml_iarchive.cpp (original)
+++ trunk/libs/serialization/src/xml_iarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -27,18 +27,15 @@
// explicitly instantiate for this type of xml stream
#include <boost/archive/impl/basic_xml_iarchive.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
namespace boost {
namespace archive {
template class basic_xml_iarchive<naked_xml_iarchive> ;
-template class detail::archive_pointer_iserializer<naked_xml_iarchive> ;
template class xml_iarchive_impl<naked_xml_iarchive> ;
template class basic_xml_iarchive<xml_iarchive> ;
-template class detail::archive_pointer_iserializer<xml_iarchive> ;
template class xml_iarchive_impl<xml_iarchive> ;
} // namespace archive
Modified: trunk/libs/serialization/src/xml_oarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/xml_oarchive.cpp (original)
+++ trunk/libs/serialization/src/xml_oarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -16,7 +16,6 @@
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
#include <boost/archive/impl/xml_oarchive_impl.ipp>
namespace boost {
@@ -24,7 +23,6 @@
// explicitly instantiate for this type of xml stream
template class basic_xml_oarchive<xml_oarchive> ;
-template class detail::archive_pointer_oserializer<xml_oarchive> ;
template class xml_oarchive_impl<xml_oarchive> ;
} // namespace archive
Modified: trunk/libs/serialization/src/xml_wiarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/xml_wiarchive.cpp (original)
+++ trunk/libs/serialization/src/xml_wiarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -33,18 +33,15 @@
// explicitly instantiate for this type of xml stream
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/impl/xml_wiarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_iserializer.ipp>
namespace boost {
namespace archive {
template class basic_xml_iarchive<naked_xml_wiarchive> ;
template class xml_wiarchive_impl<naked_xml_wiarchive> ;
-template class detail::archive_pointer_iserializer<naked_xml_wiarchive> ;
template class basic_xml_iarchive<xml_wiarchive> ;
template class xml_wiarchive_impl<xml_wiarchive> ;
-template class detail::archive_pointer_iserializer<xml_wiarchive> ;
} // namespace archive
} // namespace boost
Modified: trunk/libs/serialization/src/xml_woarchive.cpp
==============================================================================
--- trunk/libs/serialization/src/xml_woarchive.cpp (original)
+++ trunk/libs/serialization/src/xml_woarchive.cpp 2009-07-13 17:42:14 EDT (Mon, 13 Jul 2009)
@@ -21,44 +21,12 @@
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/xml_woarchive_impl.ipp>
-#include <boost/archive/impl/archive_pointer_oserializer.ipp>
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<xml_woarchive> ;
template class xml_woarchive_impl<xml_woarchive> ;
-template class detail::archive_pointer_oserializer<xml_woarchive> ;
} // namespace archive
} // namespace boost
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