various adjustments to

a) correct error in loading set / map for C++11+
b) more refinements of visibility
This commit is contained in:
Robert Ramey
2016-02-14 21:22:35 -08:00
parent d9ad787f70
commit 150b7e8a5f
10 changed files with 68 additions and 58 deletions

View File

@@ -17,15 +17,12 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
//#include <boost/detail/workaround.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/detail/common_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/string.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
#ifdef BOOST_MSVC
@@ -41,18 +38,18 @@ namespace detail {
} // namespace detail
/////////////////////////////////////////////////////////////////////////
// class xml_iarchive - read serialized objects from a input text stream
// class basic_xml_iarchive - read serialized objects from a input text stream
template<class Archive>
class BOOST_SYMBOL_VISIBLE basic_xml_iarchive :
public detail::common_iarchive<Archive>
{
unsigned int depth;
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
protected:
friend class detail::interface_iarchive<Archive>;
#endif
unsigned int depth;
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_start(const char *name);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
@@ -90,14 +87,15 @@ protected:
// an xml archive. So we can skip it here. Note: we MUST override
// it otherwise it will be loaded as a normal primitive w/o tag and
// leaving the archive in an undetermined state
void load_override(class_id_optional_type & /* t */){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_id_optional_type & /* t */){}
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(object_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(version_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(class_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
load_override(tracking_type & t);
// class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation

View File

@@ -18,12 +18,9 @@
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
//#include <boost/detail/workaround.hpp>
#include <boost/archive/detail/common_oarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -46,17 +43,16 @@ template<class Archive>
class BOOST_SYMBOL_VISIBLE basic_xml_oarchive :
public detail::common_oarchive<Archive>
{
// special stuff for xml output
unsigned int depth;
bool pending_preamble;
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
protected:
friend class detail::interface_oarchive<Archive>;
#endif
friend class save_access;
// special stuff for xml output
unsigned int depth;
bool indent_next;
bool pending_preamble;
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
indent();
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
@@ -106,18 +102,18 @@ protected:
// specific overrides for attributes - not name value pairs so we
// want to trap them before the above "fall through"
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_reference_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const version_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_optional_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_id_reference_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_id_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const object_reference_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const version_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const class_name_type & t);
BOOST_ARCHIVE_OR_WARCHIVE_DECL void
save_override(const tracking_type & t);

View File

@@ -251,8 +251,8 @@ BOOST_ARCHIVE_OR_WARCHIVE_DECL
basic_xml_oarchive<Archive>::basic_xml_oarchive(unsigned int flags) :
detail::common_oarchive<Archive>(flags),
depth(0),
indent_next(false),
pending_preamble(false)
pending_preamble(false),
indent_next(false)
{
}

View File

@@ -87,11 +87,27 @@ protected:
xml_oarchive_impl(std::ostream & os, unsigned int flags);
BOOST_ARCHIVE_DECL
~xml_oarchive_impl();
BOOST_ARCHIVE_DECL
public:
BOOST_ARCHIVE_DECL
void save_binary(const void *address, std::size_t count);
};
} // namespace archive
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
namespace boost {
namespace archive {
// we use the following because we can't use
// typedef xml_oarchive_impl<xml_oarchive_impl<...> > xml_oarchive;
@@ -118,6 +134,4 @@ BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
#pragma warning(pop)
#endif
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
#endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP

View File

@@ -22,10 +22,6 @@
#include <boost/serialization/utility.hpp>
#ifdef BOOST_NO_CXX11_STD_UNORDERED
#error "not supported for versions earlier than c++11
#endif
namespace boost {
namespace serialization {
namespace stl {
@@ -43,8 +39,11 @@ struct archive_input_unordered_map
detail::stack_construct<Archive, type> t(ar, v);
ar >> boost::serialization::make_nvp("item", t.reference());
std::pair<typename Container::const_iterator, bool> result =
s.emplace(t.reference());
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
s.insert(t.reference());
#else
s.emplace(t.reference());
#endif
// note: the following presumes that the map::value_type was NOT tracked
// in the archive. This is the usual case, but here there is no way
// to determine that.
@@ -70,7 +69,11 @@ struct archive_input_unordered_multimap
detail::stack_construct<Archive, type> t(ar, v);
ar >> boost::serialization::make_nvp("item", t.reference());
typename Container::const_iterator result =
s.emplace(t.reference());
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
s.insert(t.reference());
#else
s.emplace(t.reference());
#endif
// note: the following presumes that the map::value_type was NOT tracked
// in the archive. This is the usual case, but here there is no way
// to determine that.

View File

@@ -17,11 +17,6 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_SET
#error "not supported for versions earlier than c++11
#endif
namespace boost {
namespace serialization {
@@ -41,7 +36,11 @@ struct archive_input_unordered_set
// borland fails silently w/o full namespace
ar >> boost::serialization::make_nvp("item", t.reference());
std::pair<typename Container::const_iterator, bool> result =
s.emplace(t.reference());
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_SET
s.insert(t.reference());
#else
s.emplace(t.reference());
#endif
if(result.second)
ar.reset_object_address(& (* result.first), & t.reference());
}
@@ -59,8 +58,12 @@ struct archive_input_unordered_multiset
typedef typename Container::value_type type;
detail::stack_construct<Archive, type> t(ar, v);
ar >> boost::serialization::make_nvp("item", t.reference());
typename Container::const_iterator result
= s.emplace(t.reference());
typename Container::const_iterator result =
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_SET
s.insert(t.reference());
#else
s.emplace(t.reference());
#endif
ar.reset_object_address(& (* result), & t.reference());
}
};

View File

@@ -23,7 +23,7 @@
// exists for archives to be non-portable if class information for primitive
// types is included. This is addressed by the following macros.
#include <boost/config.hpp>
#include <boost/mpl/integral_c.hpp>
//#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/integral_c_tag.hpp>
#include <boost/cstdint.hpp>

View File

@@ -57,22 +57,16 @@ public:
return *(this->second);
}
// True64 compiler complains with a warning about the use of
// the name "Archive" hiding some higher level usage. I'm sure this
// is an error but I want to accomodated as it generates a long warning
// listing and might be related to a lot of test failures.
// default treatment for name-value pairs. The name is
// just discarded and only the value is serialized.
template<class Archivex>
template<class Archive>
void save(
Archivex & ar,
Archive & ar,
const unsigned int /* file_version */
) const {
ar.operator<<(const_value());
}
template<class Archivex>
template<class Archive>
void load(
Archivex & ar,
Archive & ar,
const unsigned int /* file_version */
){
ar.operator>>(value());
@@ -110,7 +104,6 @@ struct tracking_level<nvp< T > >
BOOST_STATIC_CONSTANT(int, value = tracking_level::type::value);
};
} // seralization
} // boost

View File

@@ -15,7 +15,7 @@
#ifdef BOOST_SERIALIZATION_VECTOR_VERSIONED
#if BOOST_SERIALIZATION_VECTOR_VERSION != 4
#error Boost.Serialization cannot be compatible with both 1.35 and 1.36-1.40 files
#error "Boost.Serialization cannot be compatible with both 1.35 and 1.36-1.40 files"
#endif
#else
#define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V>4)