| 1 | #ifndef BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP |
| 2 | #define BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP |
| 3 | |
| 4 | // MS compatible compilers support #pragma once |
| 5 | #if defined(_MSC_VER) |
| 6 | # pragma once |
| 7 | #endif |
| 8 | |
| 9 | #if defined(_MSC_VER) && (_MSC_VER <= 1020) |
| 10 | # pragma warning (disable : 4786) // too long name, harmless warning |
| 11 | #endif |
| 12 | |
| 13 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
| 14 | // collections_load_imp.hpp: serialization for loading stl collections |
| 15 | |
| 16 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
| 17 | // Use, modification and distribution is subject to the Boost Software |
| 18 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 19 | // http://www.boost.org/LICENSE_1_0.txt) |
| 20 | |
| 21 | // See http://www.boost.org for updates, documentation, and revision history. |
| 22 | |
| 23 | // helper function templates for serialization of collections |
| 24 | |
| 25 | #include <boost/assert.hpp> |
| 26 | #include <cstddef> // size_t |
| 27 | #include <boost/config.hpp> // msvc 6.0 needs this for warning suppression |
| 28 | #if defined(BOOST_NO_STDC_NAMESPACE) |
| 29 | namespace std{ |
| 30 | using ::size_t; |
| 31 | } // namespace std |
| 32 | #endif |
| 33 | #include <boost/detail/workaround.hpp> |
| 34 | |
| 35 | #include <boost/serialization/access.hpp> |
| 36 | #include <boost/serialization/nvp.hpp> |
| 37 | #include <boost/serialization/detail/stack_constructor.hpp> |
| 38 | #include <boost/serialization/collection_size_type.hpp> |
| 39 | #include <boost/serialization/item_version_type.hpp> |
| 40 | #include <boost/serialization/detail/is_default_constructible.hpp> |
| 41 | #include <boost/utility/enable_if.hpp> |
| 42 | #include <boost/move/utility_core.hpp> |
| 43 | |
| 44 | namespace boost{ |
| 45 | namespace serialization { |
| 46 | namespace stl { |
| 47 | |
| 48 | ////////////////////////////////////////////////////////////////////// |
| 49 | // implementation of serialization for STL containers |
| 50 | // |
| 51 | |
| 52 | template< |
| 53 | class Archive, |
| 54 | class T |
| 55 | > |
| 56 | typename boost::enable_if< |
| 57 | typename detail::is_default_constructible< |
| 58 | typename T::value_type |
| 59 | >, |
| 60 | void |
| 61 | >::type |
| 62 | collection_load_impl( |
| 63 | Archive & ar, |
| 64 | T & t, |
| 65 | collection_size_type count, |
| 66 | item_version_type /*item_version*/ |
| 67 | ){ |
| 68 | t.resize(count); |
| 69 | typename T::iterator hint; |
| 70 | hint = t.begin(); |
| 71 | while(count-- > 0){ |
| 72 | ar >> boost::serialization::make_nvp("item" , *hint++); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | template< |
| 77 | class Archive, |
| 78 | class T |
| 79 | > |
| 80 | typename boost::disable_if< |
| 81 | typename detail::is_default_constructible< |
| 82 | typename T::value_type |
| 83 | >, |
| 84 | void |
| 85 | >::type |
| 86 | collection_load_impl( |
| 87 | Archive & ar, |
| 88 | T & t, |
| 89 | collection_size_type count, |
| 90 | item_version_type item_version |
| 91 | ){ |
| 92 | t.clear(); |
| 93 | while(count-- > 0){ |
| 94 | detail::stack_construct<Archive, typename T::value_type> u(ar, item_version); |
| 95 | ar >> boost::serialization::make_nvp("item" , u.reference()); |
| 96 | t.push_back(boost::move(u.reference())); |
| 97 | ar.reset_object_address(& t.back() , u.address()); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | } // namespace stl |
| 102 | } // namespace serialization |
| 103 | } // namespace boost |
| 104 | |
| 105 | #endif //BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP |
| 106 | |