Chris@102: #ifndef BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_SAVE_IMP_HPP Chris@102: #define BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_SAVE_IMP_HPP Chris@102: Chris@102: // MS compatible compilers support #pragma once Chris@102: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@102: // hash_collections_save_imp.hpp: serialization for stl collections Chris@102: Chris@102: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@102: // (C) Copyright 2014 Jim Bell Chris@102: // Use, modification and distribution is subject to the Boost Software Chris@102: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: Chris@102: // See http://www.boost.org for updates, documentation, and revision history. Chris@102: Chris@102: // helper function templates for serialization of collections Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost{ Chris@102: namespace serialization { Chris@102: namespace stl { Chris@102: Chris@102: ////////////////////////////////////////////////////////////////////// Chris@102: // implementation of serialization for STL containers Chris@102: // Chris@102: Chris@102: template Chris@102: inline void save_unordered_collection(Archive & ar, const Container &s) Chris@102: { Chris@102: collection_size_type count(s.size()); Chris@102: const collection_size_type bucket_count(s.bucket_count()); Chris@102: const item_version_type item_version( Chris@102: version::value Chris@102: ); Chris@102: Chris@102: #if 0 Chris@102: /* should only be necessary to create archives of previous versions Chris@102: * which is not currently supported. So for now comment this out Chris@102: */ Chris@102: boost::archive::library_version_type library_version( Chris@102: ar.get_library_version() Chris@102: ); Chris@102: // retrieve number of elements Chris@102: ar << BOOST_SERIALIZATION_NVP(count); Chris@102: ar << BOOST_SERIALIZATION_NVP(bucket_count); Chris@102: if(boost::archive::library_version_type(3) < library_version){ Chris@102: // record number of elements Chris@102: // make sure the target type is registered so we can retrieve Chris@102: // the version when we load Chris@102: ar << BOOST_SERIALIZATION_NVP(item_version); Chris@102: } Chris@102: #else Chris@102: ar << BOOST_SERIALIZATION_NVP(count); Chris@102: ar << BOOST_SERIALIZATION_NVP(bucket_count); Chris@102: ar << BOOST_SERIALIZATION_NVP(item_version); Chris@102: #endif Chris@102: Chris@102: typename Container::const_iterator it = s.begin(); Chris@102: while(count-- > 0){ Chris@102: // note borland emits a no-op without the explicit namespace Chris@102: boost::serialization::save_construct_data_adl( Chris@102: ar, Chris@102: &(*it), Chris@102: boost::serialization::version< Chris@102: typename Container::value_type Chris@102: >::value Chris@102: ); Chris@102: ar << boost::serialization::make_nvp("item", *it++); Chris@102: } Chris@102: } Chris@102: Chris@102: } // namespace stl Chris@102: } // namespace serialization Chris@102: } // namespace boost Chris@102: Chris@102: #endif //BOOST_SERIALIZATION_UNORDERED_COLLECTIONS_SAVE_IMP_HPP