Add more serializable types; remove unique_ptr
This commit is contained in:
parent
d2a5baa1ad
commit
48130d3879
85
boost/serialization/archive_input_unordered_map.hpp
Normal file
85
boost/serialization/archive_input_unordered_map.hpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#ifndef BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
|
||||||
|
#define BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||||
|
// serialization/unordered_map.hpp:
|
||||||
|
// serialization for stl unordered_map templates
|
||||||
|
|
||||||
|
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||||
|
// (C) Copyright 2014 Jim Bell
|
||||||
|
// 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 <boost/config.hpp>
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||||
|
#include <boost/serialization/utility.hpp>
|
||||||
|
#include <boost/move/utility_core.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace serialization {
|
||||||
|
namespace stl {
|
||||||
|
|
||||||
|
// map input
|
||||||
|
template<class Archive, class Container>
|
||||||
|
struct archive_input_unordered_map
|
||||||
|
{
|
||||||
|
inline void operator()(
|
||||||
|
Archive &ar,
|
||||||
|
Container &s,
|
||||||
|
const unsigned int v
|
||||||
|
){
|
||||||
|
typedef typename Container::value_type type;
|
||||||
|
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.insert(boost::move(t.reference()));
|
||||||
|
// 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.
|
||||||
|
if(result.second){
|
||||||
|
ar.reset_object_address(
|
||||||
|
& (result.first->second),
|
||||||
|
& t.reference().second
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// multimap input
|
||||||
|
template<class Archive, class Container>
|
||||||
|
struct archive_input_unordered_multimap
|
||||||
|
{
|
||||||
|
inline void operator()(
|
||||||
|
Archive &ar,
|
||||||
|
Container &s,
|
||||||
|
const unsigned int v
|
||||||
|
){
|
||||||
|
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.insert(t.reference());
|
||||||
|
// 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.
|
||||||
|
ar.reset_object_address(
|
||||||
|
& result->second,
|
||||||
|
& t.reference()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // stl
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_SERIALIZATION_ARCHIVE_INPUT_UNORDERED_MAP_HPP
|
79
boost/serialization/binary_object.hpp
Normal file
79
boost/serialization/binary_object.hpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#ifndef BOOST_SERIALIZATION_BINARY_OBJECT_HPP
|
||||||
|
#define BOOST_SERIALIZATION_BINARY_OBJECT_HPP
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||||
|
// nvp.hpp: interface for serialization system.
|
||||||
|
|
||||||
|
// (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 <boost/assert.hpp>
|
||||||
|
|
||||||
|
#include <cstddef> // std::size_t
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||||
|
namespace std{
|
||||||
|
using ::size_t;
|
||||||
|
} // namespace std
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
|
#include <boost/serialization/tracking.hpp>
|
||||||
|
#include <boost/serialization/level.hpp>
|
||||||
|
#include <boost/serialization/split_member.hpp>
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
#include <boost/serialization/wrapper.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace serialization {
|
||||||
|
|
||||||
|
struct binary_object :
|
||||||
|
public wrapper_traits<nvp<const binary_object> >
|
||||||
|
{
|
||||||
|
void const * m_t;
|
||||||
|
std::size_t m_size;
|
||||||
|
template<class Archive>
|
||||||
|
void save(Archive & ar, const unsigned int /* file_version */) const {
|
||||||
|
ar.save_binary(m_t, m_size);
|
||||||
|
}
|
||||||
|
template<class Archive>
|
||||||
|
void load(Archive & ar, const unsigned int /* file_version */) const {
|
||||||
|
ar.load_binary(const_cast<void *>(m_t), m_size);
|
||||||
|
}
|
||||||
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||||
|
binary_object & operator=(const binary_object & rhs) {
|
||||||
|
m_t = rhs.m_t;
|
||||||
|
m_size = rhs.m_size;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
binary_object(const void * const t, std::size_t size) :
|
||||||
|
m_t(t),
|
||||||
|
m_size(size)
|
||||||
|
{}
|
||||||
|
binary_object(const binary_object & rhs) :
|
||||||
|
m_t(rhs.m_t),
|
||||||
|
m_size(rhs.m_size)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
// just a little helper to support the convention that all serialization
|
||||||
|
// wrappers follow the naming convention make_xxxxx
|
||||||
|
inline
|
||||||
|
const binary_object
|
||||||
|
make_binary_object(const void * t, std::size_t size){
|
||||||
|
return binary_object(t, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // boost
|
||||||
|
|
||||||
|
#endif // BOOST_SERIALIZATION_BINARY_OBJECT_HPP
|
75
boost/serialization/bitset.hpp
Normal file
75
boost/serialization/bitset.hpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*!
|
||||||
|
* \file bitset.hpp
|
||||||
|
* \brief Provides Boost.Serialization support for std::bitset
|
||||||
|
* \author Brian Ravnsgaard Riis
|
||||||
|
* \author Kenneth Riddile
|
||||||
|
* \date 16.09.2004, updated 04.03.2009
|
||||||
|
* \copyright 2004 Brian Ravnsgaard Riis
|
||||||
|
* \license Boost Software License 1.0
|
||||||
|
*/
|
||||||
|
#ifndef BOOST_SERIALIZATION_BITSET_HPP
|
||||||
|
#define BOOST_SERIALIZATION_BITSET_HPP
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
#include <cstddef> // size_t
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/serialization/split_free.hpp>
|
||||||
|
#include <boost/serialization/string.hpp>
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
|
||||||
|
namespace boost{
|
||||||
|
namespace serialization{
|
||||||
|
|
||||||
|
template <class Archive, std::size_t size>
|
||||||
|
inline void save(
|
||||||
|
Archive & ar,
|
||||||
|
std::bitset<size> const & t,
|
||||||
|
const unsigned int /* version */
|
||||||
|
){
|
||||||
|
const std::string bits = t.template to_string<
|
||||||
|
std::string::value_type,
|
||||||
|
std::string::traits_type,
|
||||||
|
std::string::allocator_type
|
||||||
|
>();
|
||||||
|
ar << BOOST_SERIALIZATION_NVP( bits );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Archive, std::size_t size>
|
||||||
|
inline void load(
|
||||||
|
Archive & ar,
|
||||||
|
std::bitset<size> & t,
|
||||||
|
const unsigned int /* version */
|
||||||
|
){
|
||||||
|
std::string bits;
|
||||||
|
ar >> BOOST_SERIALIZATION_NVP( bits );
|
||||||
|
t = std::bitset<size>(bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Archive, std::size_t size>
|
||||||
|
inline void serialize(
|
||||||
|
Archive & ar,
|
||||||
|
std::bitset<size> & t,
|
||||||
|
const unsigned int version
|
||||||
|
){
|
||||||
|
boost::serialization::split_free( ar, t, version );
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't track bitsets since that would trigger tracking
|
||||||
|
// all over the program - which probably would be a surprise.
|
||||||
|
// also, tracking would be hard to implement since, we're
|
||||||
|
// serialization a representation of the data rather than
|
||||||
|
// the data itself.
|
||||||
|
template <std::size_t size>
|
||||||
|
struct tracking_level<std::bitset<size> >
|
||||||
|
: mpl::int_<track_never> {} ;
|
||||||
|
|
||||||
|
} //serialization
|
||||||
|
} //boost
|
||||||
|
|
||||||
|
#endif // BOOST_SERIALIZATION_BITSET_HPP
|
@ -1,68 +0,0 @@
|
|||||||
#ifndef BOOST_SERIALIZATION_UNIQUE_PTR_HPP
|
|
||||||
#define BOOST_SERIALIZATION_UNIQUE_PTR_HPP
|
|
||||||
|
|
||||||
// MS compatible compilers support #pragma once
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
|
||||||
// unique_ptr.hpp:
|
|
||||||
|
|
||||||
// (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 <memory>
|
|
||||||
#include <boost/serialization/split_free.hpp>
|
|
||||||
#include <boost/serialization/nvp.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace serialization {
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// implement serialization for unique_ptr< T >
|
|
||||||
// note: this must be added to the boost namespace in order to
|
|
||||||
// be called by the library
|
|
||||||
template<class Archive, class T>
|
|
||||||
inline void save(
|
|
||||||
Archive & ar,
|
|
||||||
const std::unique_ptr< T > &t,
|
|
||||||
const unsigned int /*file_version*/
|
|
||||||
){
|
|
||||||
// only the raw pointer has to be saved
|
|
||||||
// the ref count is rebuilt automatically on load
|
|
||||||
const T * const tx = t.get();
|
|
||||||
ar << BOOST_SERIALIZATION_NVP(tx);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Archive, class T>
|
|
||||||
inline void load(
|
|
||||||
Archive & ar,
|
|
||||||
std::unique_ptr< T > &t,
|
|
||||||
const unsigned int /*file_version*/
|
|
||||||
){
|
|
||||||
T *tx;
|
|
||||||
ar >> BOOST_SERIALIZATION_NVP(tx);
|
|
||||||
// note that the reset automagically maintains the reference count
|
|
||||||
t.reset(tx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// split non-intrusive serialization function member into separate
|
|
||||||
// non intrusive save/load member functions
|
|
||||||
template<class Archive, class T>
|
|
||||||
inline void serialize(
|
|
||||||
Archive & ar,
|
|
||||||
std::unique_ptr< T > &t,
|
|
||||||
const unsigned int file_version
|
|
||||||
){
|
|
||||||
boost::serialization::split_free(ar, t, file_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace serialization
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_SERIALIZATION_UNIQUE_PTR_HPP
|
|
160
boost/serialization/unordered_map.hpp
Normal file
160
boost/serialization/unordered_map.hpp
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#ifndef BOOST_SERIALIZATION_UNORDERED_MAP_HPP
|
||||||
|
#define BOOST_SERIALIZATION_UNORDERED_MAP_HPP
|
||||||
|
|
||||||
|
// MS compatible compilers support #pragma once
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||||
|
// serialization/unordered_map.hpp:
|
||||||
|
// serialization for stl unordered_map templates
|
||||||
|
|
||||||
|
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||||
|
// (C) Copyright 2014 Jim Bell
|
||||||
|
// 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 <boost/config.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include <boost/serialization/utility.hpp>
|
||||||
|
#include <boost/serialization/unordered_collections_save_imp.hpp>
|
||||||
|
#include <boost/serialization/unordered_collections_load_imp.hpp>
|
||||||
|
#include <boost/serialization/archive_input_unordered_map.hpp>
|
||||||
|
#include <boost/serialization/split_free.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace serialization {
|
||||||
|
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void save(
|
||||||
|
Archive & ar,
|
||||||
|
const std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
|
||||||
|
const unsigned int /*file_version*/
|
||||||
|
){
|
||||||
|
boost::serialization::stl::save_unordered_collection<
|
||||||
|
Archive,
|
||||||
|
std::unordered_map<Key, HashFcn, EqualKey, Allocator>
|
||||||
|
>(ar, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void load(
|
||||||
|
Archive & ar,
|
||||||
|
std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
|
||||||
|
const unsigned int /*file_version*/
|
||||||
|
){
|
||||||
|
boost::serialization::stl::load_unordered_collection<
|
||||||
|
Archive,
|
||||||
|
std::unordered_map<Key, HashFcn, EqualKey, Allocator>,
|
||||||
|
boost::serialization::stl::archive_input_unordered_map<
|
||||||
|
Archive,
|
||||||
|
std::unordered_map<Key, HashFcn, EqualKey, Allocator>
|
||||||
|
>
|
||||||
|
>(ar, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// split non-intrusive serialization function member into separate
|
||||||
|
// non intrusive save/load member functions
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void serialize(
|
||||||
|
Archive & ar,
|
||||||
|
std::unordered_map<Key, HashFcn, EqualKey, Allocator> &t,
|
||||||
|
const unsigned int file_version
|
||||||
|
){
|
||||||
|
boost::serialization::split_free(ar, t, file_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unordered_multimap
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void save(
|
||||||
|
Archive & ar,
|
||||||
|
const std::unordered_multimap<
|
||||||
|
Key, HashFcn, EqualKey, Allocator
|
||||||
|
> &t,
|
||||||
|
const unsigned int /*file_version*/
|
||||||
|
){
|
||||||
|
boost::serialization::stl::save_unordered_collection<
|
||||||
|
Archive,
|
||||||
|
std::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
|
||||||
|
>(ar, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void load(
|
||||||
|
Archive & ar,
|
||||||
|
std::unordered_multimap<
|
||||||
|
Key, HashFcn, EqualKey, Allocator
|
||||||
|
> &t,
|
||||||
|
const unsigned int /*file_version*/
|
||||||
|
){
|
||||||
|
boost::serialization::stl::load_unordered_collection<
|
||||||
|
Archive,
|
||||||
|
std::unordered_multimap<
|
||||||
|
Key, HashFcn, EqualKey, Allocator
|
||||||
|
>,
|
||||||
|
boost::serialization::stl::archive_input_unordered_multimap<
|
||||||
|
Archive,
|
||||||
|
std::unordered_multimap<Key, HashFcn, EqualKey, Allocator>
|
||||||
|
>
|
||||||
|
>(ar, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// split non-intrusive serialization function member into separate
|
||||||
|
// non intrusive save/load member functions
|
||||||
|
template<
|
||||||
|
class Archive,
|
||||||
|
class Key,
|
||||||
|
class HashFcn,
|
||||||
|
class EqualKey,
|
||||||
|
class Allocator
|
||||||
|
>
|
||||||
|
inline void serialize(
|
||||||
|
Archive & ar,
|
||||||
|
std::unordered_multimap<
|
||||||
|
Key, HashFcn, EqualKey, Allocator
|
||||||
|
> &t,
|
||||||
|
const unsigned int file_version
|
||||||
|
){
|
||||||
|
boost::serialization::split_free(ar, t, file_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace serialization
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_SERIALIZATION_UNORDERED_MAP_HPP
|
@ -17,10 +17,12 @@ bcp ^
|
|||||||
boost/archive/binary_iarchive.hpp ^
|
boost/archive/binary_iarchive.hpp ^
|
||||||
boost/archive/binary_oarchive.hpp ^
|
boost/archive/binary_oarchive.hpp ^
|
||||||
boost/serialization/array.hpp ^
|
boost/serialization/array.hpp ^
|
||||||
|
boost/serialization/bitset.hpp ^
|
||||||
|
boost/serialization/binary_object.hpp ^
|
||||||
boost/serialization/vector.hpp ^
|
boost/serialization/vector.hpp ^
|
||||||
boost/serialization/set.hpp ^
|
boost/serialization/set.hpp ^
|
||||||
boost/serialization/map.hpp ^
|
boost/serialization/map.hpp ^
|
||||||
|
boost/serialization/unordered_map.hpp ^
|
||||||
boost/serialization/unordered_set.hpp ^
|
boost/serialization/unordered_set.hpp ^
|
||||||
boost/serialization/shared_ptr.hpp ^
|
boost/serialization/shared_ptr.hpp ^
|
||||||
boost/serialization/unique_ptr.hpp ^
|
|
||||||
--boost="%1" .
|
--boost="%1" .
|
||||||
|
Loading…
x
Reference in New Issue
Block a user