Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:35

0001 // Copyright Sebastian Ramacher, 2007.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
0007 #define BOOST_PTR_CONTAINER_DETAIL_SERIALIZE_PTR_MAP_ADAPTER_HPP
0008 
0009 #include <boost/ptr_container/ptr_map_adapter.hpp>
0010 #include <boost/ptr_container/detail/serialize_xml_names.hpp>
0011 #include <boost/core/serialization.hpp>
0012 
0013 namespace boost
0014 {
0015 
0016 namespace serialization
0017 {
0018 
0019 template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
0020 void save(Archive& ar, const ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
0021 {
0022     typedef ptr_container_detail::ptr_map_adapter_base<T, VoidPtrMap, CloneAllocator,Ordered> container;
0023     typedef BOOST_DEDUCED_TYPENAME container::const_iterator const_iterator;
0024 
0025     ar << boost::serialization::make_nvp( ptr_container_detail::count(),
0026                                           ptr_container_detail::serialize_as_const(c.size()) );
0027 
0028     const_iterator i = c.begin(), e = c.end();
0029     for(; i != e; ++i)
0030     {
0031         ar << boost::serialization::make_nvp( ptr_container_detail::first(), i->first );
0032         ar << boost::serialization::make_nvp( ptr_container_detail::second(),
0033                                               ptr_container_detail::serialize_as_const(i->second) );
0034     }
0035 }
0036 
0037 template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
0038 void load(Archive& ar, ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
0039 {
0040     typedef ptr_map_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
0041     typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
0042     typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
0043     typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
0044 
0045     c.clear();
0046     size_type n;
0047     ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
0048 
0049     for(size_type i = 0u; i != n; ++i)
0050     {
0051         key_type key;
0052         T* value;
0053         ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
0054         ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
0055         std::pair<iterator, bool> p = c.insert(key, value);
0056         ar.reset_object_address(&p.first->first, &key);
0057     }
0058 }
0059 
0060 template<class Archive, class T, class VoidPtrMap, class CloneAllocator, bool Ordered>
0061 void load(Archive& ar, ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered>& c, unsigned int /*version*/)
0062 {
0063     typedef ptr_multimap_adapter<T, VoidPtrMap, CloneAllocator,Ordered> container;
0064     typedef BOOST_DEDUCED_TYPENAME container::key_type key_type;
0065     typedef BOOST_DEDUCED_TYPENAME container::size_type size_type;
0066     typedef BOOST_DEDUCED_TYPENAME container::iterator iterator;
0067 
0068     c.clear();
0069     size_type n;
0070     ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
0071 
0072     for(size_type i = 0u; i != n; ++i)
0073     {
0074         key_type key;
0075         T* value;
0076         ar >> boost::serialization::make_nvp( ptr_container_detail::first(), key );
0077         ar >> boost::serialization::make_nvp( ptr_container_detail::second(), value );
0078         iterator p = c.insert(key, value);
0079         ar.reset_object_address(&p->first, &key);
0080     }
0081 }
0082 
0083 } // namespace serialization
0084 } // namespace boost
0085 
0086 #endif