mirror of
https://github.com/boostorg/serialization.git
synced 2026-02-09 11:22:26 +00:00
moved shared_helper to mixin of common base
updated shared_ptr serialization accordingly
This commit is contained in:
@@ -418,7 +418,6 @@ basic_iarchive_impl::load_pointer(
|
||||
const basic_pointer_iserializer * (*finder)(
|
||||
const boost::serialization::extended_type_info & type_
|
||||
)
|
||||
|
||||
){
|
||||
m_moveable_objects.is_pointer = true;
|
||||
serialization::state_saver<bool> w(m_moveable_objects.is_pointer);
|
||||
@@ -452,7 +451,7 @@ basic_iarchive_impl::load_pointer(
|
||||
bpis_ptr = (*finder)(*eti);
|
||||
}
|
||||
BOOST_ASSERT(NULL != bpis_ptr);
|
||||
class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer());
|
||||
// class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer());
|
||||
BOOST_VERIFY(register_type(bpis_ptr->get_basic_serializer()) == cid);
|
||||
int i = cid;
|
||||
cobject_id_vector[i].bpis_ptr = bpis_ptr;
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// shared_ptr_helper.hpp: serialization for boost shared pointern
|
||||
|
||||
// (C) Copyright 2004-2009 Robert Ramey, Martin Ecker and Takatoshi Kondo
|
||||
// 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 <map>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#define BOOST_ARCHIVE_SOURCE
|
||||
// include this to prevent linker errors when the
|
||||
// same modules are marked export and import.
|
||||
#define BOOST_SERIALIZATION_SOURCE
|
||||
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
#include <boost/serialization/void_cast.hpp>
|
||||
#include <boost/serialization/extended_type_info.hpp>
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive{
|
||||
namespace detail {
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// a common class for holding various types of shared pointers
|
||||
|
||||
// returns pointer to object and an indicator whether this is a
|
||||
// new entry (true) or a previous one (false)
|
||||
BOOST_ARCHIVE_DECL(shared_ptr<void>)
|
||||
shared_ptr_helper::get_od(
|
||||
const void * t,
|
||||
const boost::serialization::extended_type_info * true_type,
|
||||
const boost::serialization::extended_type_info * this_type
|
||||
){
|
||||
// get void pointer to the most derived type
|
||||
// this uniquely identifies the object referred to
|
||||
const void * od = void_downcast(
|
||||
*true_type,
|
||||
*this_type,
|
||||
t
|
||||
);
|
||||
if(NULL == od)
|
||||
boost::serialization::throw_exception(
|
||||
archive_exception(
|
||||
archive_exception::unregistered_cast,
|
||||
true_type->get_debug_info(),
|
||||
this_type->get_debug_info()
|
||||
)
|
||||
);
|
||||
|
||||
// make tracking array if necessary
|
||||
if(NULL == m_pointers)
|
||||
m_pointers = new collection_type;
|
||||
|
||||
//shared_ptr<const void> sp(od, null_deleter());
|
||||
shared_ptr<const void> sp(od, null_deleter());
|
||||
collection_type::iterator i = m_pointers->find(sp);
|
||||
|
||||
if(i == m_pointers->end()){
|
||||
shared_ptr<void> np;
|
||||
return np;
|
||||
}
|
||||
od = void_upcast(
|
||||
*true_type,
|
||||
*this_type,
|
||||
i->get()
|
||||
);
|
||||
if(NULL == od)
|
||||
boost::serialization::throw_exception(
|
||||
archive_exception(
|
||||
archive_exception::unregistered_cast,
|
||||
true_type->get_debug_info(),
|
||||
this_type->get_debug_info()
|
||||
)
|
||||
);
|
||||
|
||||
return shared_ptr<void>(
|
||||
const_pointer_cast<void>(*i),
|
||||
const_cast<void *>(od)
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_DECL(void)
|
||||
shared_ptr_helper::append(const boost::shared_ptr<const void> &sp){
|
||||
// make tracking array if necessary
|
||||
if(NULL == m_pointers)
|
||||
m_pointers = new collection_type;
|
||||
|
||||
collection_type::iterator i = m_pointers->find(sp);
|
||||
|
||||
if(i == m_pointers->end()){
|
||||
std::pair<collection_type::iterator, bool> result;
|
||||
result = m_pointers->insert(sp);
|
||||
BOOST_ASSERT(result.second);
|
||||
}
|
||||
}
|
||||
|
||||
// #ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
|
||||
BOOST_ARCHIVE_DECL(void)
|
||||
shared_ptr_helper::append(const boost_132::shared_ptr<const void> & t){
|
||||
if(NULL == m_pointers_132)
|
||||
m_pointers_132 = new std::list<boost_132::shared_ptr<const void> >;
|
||||
m_pointers_132->push_back(t);
|
||||
}
|
||||
// #endif
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
shared_ptr_helper::shared_ptr_helper() :
|
||||
m_pointers(NULL)
|
||||
#ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
|
||||
, m_pointers_132(NULL)
|
||||
#endif
|
||||
{}
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
shared_ptr_helper::~shared_ptr_helper(){
|
||||
if(NULL != m_pointers)
|
||||
delete m_pointers;
|
||||
#ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP
|
||||
if(NULL != m_pointers_132)
|
||||
delete m_pointers_132;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
@@ -31,24 +31,23 @@ xml_archive_exception::xml_archive_exception(
|
||||
) :
|
||||
archive_exception(other_exception, e1, e2)
|
||||
{
|
||||
unsigned int length = 0;
|
||||
switch(c){
|
||||
case xml_archive_parsing_error:
|
||||
length = archive_exception::append(length, "unrecognized XML syntax");
|
||||
archive_exception::append(0, "unrecognized XML syntax");
|
||||
break;
|
||||
case xml_archive_tag_mismatch:
|
||||
length = archive_exception::append(length, "XML start/end tag mismatch");
|
||||
archive_exception::append(0, "XML start/end tag mismatch");
|
||||
if(NULL != e1){
|
||||
length = archive_exception::append(length, " - ");
|
||||
length = archive_exception::append(length, e1);
|
||||
archive_exception::append(0, " - ");
|
||||
archive_exception::append(0, e1);
|
||||
}
|
||||
break;
|
||||
case xml_archive_tag_name_error:
|
||||
length = archive_exception::append(length, "Invalid XML tag name");
|
||||
archive_exception::append(0, "Invalid XML tag name");
|
||||
break;
|
||||
default:
|
||||
BOOST_ASSERT(false);
|
||||
length = archive_exception::append(length, "programming error");
|
||||
archive_exception::append(0, "programming error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user