diff --git a/boost/serialization/archive_input_unordered_map.hpp b/boost/serialization/archive_input_unordered_map.hpp new file mode 100644 index 00000000..ccf806b1 --- /dev/null +++ b/boost/serialization/archive_input_unordered_map.hpp @@ -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 +#include +#include +#include +#include + +namespace boost { +namespace serialization { +namespace stl { + +// map input +template +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 t(ar, v); + ar >> boost::serialization::make_nvp("item", t.reference()); + std::pair 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 +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 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 diff --git a/boost/serialization/binary_object.hpp b/boost/serialization/binary_object.hpp new file mode 100644 index 00000000..5c9038e5 --- /dev/null +++ b/boost/serialization/binary_object.hpp @@ -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 + +#include // std::size_t +#include +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace serialization { + +struct binary_object : + public wrapper_traits > +{ + void const * m_t; + std::size_t m_size; + template + void save(Archive & ar, const unsigned int /* file_version */) const { + ar.save_binary(m_t, m_size); + } + template + void load(Archive & ar, const unsigned int /* file_version */) const { + ar.load_binary(const_cast(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 diff --git a/boost/serialization/bitset.hpp b/boost/serialization/bitset.hpp new file mode 100644 index 00000000..78f9bd74 --- /dev/null +++ b/boost/serialization/bitset.hpp @@ -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 +#include // size_t + +#include +#include +#include +#include + +namespace boost{ +namespace serialization{ + +template +inline void save( + Archive & ar, + std::bitset 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 +inline void load( + Archive & ar, + std::bitset & t, + const unsigned int /* version */ +){ + std::string bits; + ar >> BOOST_SERIALIZATION_NVP( bits ); + t = std::bitset(bits); +} + +template +inline void serialize( + Archive & ar, + std::bitset & 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 +struct tracking_level > + : mpl::int_ {} ; + +} //serialization +} //boost + +#endif // BOOST_SERIALIZATION_BITSET_HPP diff --git a/boost/serialization/unique_ptr.hpp b/boost/serialization/unique_ptr.hpp deleted file mode 100644 index 8d8703ef..00000000 --- a/boost/serialization/unique_ptr.hpp +++ /dev/null @@ -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 -#include -#include - -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 -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 -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 -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 diff --git a/boost/serialization/unordered_map.hpp b/boost/serialization/unordered_map.hpp new file mode 100644 index 00000000..4fdbddd7 --- /dev/null +++ b/boost/serialization/unordered_map.hpp @@ -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 + +#include + +#include +#include +#include +#include +#include + +namespace boost { +namespace serialization { + +template< + class Archive, + class Key, + class HashFcn, + class EqualKey, + class Allocator +> +inline void save( + Archive & ar, + const std::unordered_map &t, + const unsigned int /*file_version*/ +){ + boost::serialization::stl::save_unordered_collection< + Archive, + std::unordered_map + >(ar, t); +} + +template< + class Archive, + class Key, + class HashFcn, + class EqualKey, + class Allocator +> +inline void load( + Archive & ar, + std::unordered_map &t, + const unsigned int /*file_version*/ +){ + boost::serialization::stl::load_unordered_collection< + Archive, + std::unordered_map, + boost::serialization::stl::archive_input_unordered_map< + Archive, + std::unordered_map + > + >(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 &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 + >(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 + > + >(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 diff --git a/build.cmd b/build.cmd index 5bbc5ddb..066f8dd8 100644 --- a/build.cmd +++ b/build.cmd @@ -17,10 +17,12 @@ bcp ^ boost/archive/binary_iarchive.hpp ^ boost/archive/binary_oarchive.hpp ^ boost/serialization/array.hpp ^ + boost/serialization/bitset.hpp ^ + boost/serialization/binary_object.hpp ^ boost/serialization/vector.hpp ^ boost/serialization/set.hpp ^ boost/serialization/map.hpp ^ + boost/serialization/unordered_map.hpp ^ boost/serialization/unordered_set.hpp ^ boost/serialization/shared_ptr.hpp ^ - boost/serialization/unique_ptr.hpp ^ --boost="%1" .