123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #ifndef BOOST_PROPERTY_TREE_PTREE_SERIALIZATION_HPP_INCLUDED
- #define BOOST_PROPERTY_TREE_PTREE_SERIALIZATION_HPP_INCLUDED
- #include <boost/property_tree/ptree.hpp>
- #include <boost/serialization/nvp.hpp>
- #include <boost/serialization/collections_save_imp.hpp>
- #include <boost/serialization/detail/stack_constructor.hpp>
- #include <boost/serialization/split_free.hpp>
- #include <boost/serialization/utility.hpp>
- namespace boost { namespace property_tree
- {
-
-
-
- template<class Archive, class K, class D, class C>
- inline void save(Archive &ar,
- const basic_ptree<K, D, C> &t,
- const unsigned int file_version)
- {
- using namespace boost::serialization;
- stl::save_collection<Archive, basic_ptree<K, D, C> >(ar, t);
- ar << make_nvp("data", t.data());
- }
- namespace detail
- {
- template <class Archive, class K, class D, class C>
- inline void load_children(Archive &ar,
- basic_ptree<K, D, C> &t)
- {
- namespace bsl = boost::serialization;
- namespace bsa = boost::archive;
- typedef basic_ptree<K, D, C> tree;
- typedef typename tree::value_type value_type;
-
- bsl::collection_size_type count;
- ar >> BOOST_SERIALIZATION_NVP(count);
- bsl::item_version_type item_version(0);
- const bsa::library_version_type library_version(
- ar.get_library_version()
- );
- if(bsa::library_version_type(3) < library_version){
- ar >> BOOST_SERIALIZATION_NVP(item_version);
- }
-
-
-
- t.clear();
- while(count-- > 0){
- bsl::detail::stack_construct<Archive, value_type>
- u(ar, item_version);
- ar >> bsl::make_nvp("item", u.reference());
- t.push_back(u.reference());
- ar.reset_object_address(& t.back() , & u.reference());
- }
- }
- }
-
- template<class Archive, class K, class D, class C>
- inline void load(Archive &ar,
- basic_ptree<K, D, C> &t,
- const unsigned int file_version)
- {
- namespace bsl = boost::serialization;
- detail::load_children(ar, t);
- ar >> bsl::make_nvp("data", t.data());
- }
-
- template<class Archive, class K, class D, class C>
- inline void serialize(Archive &ar,
- basic_ptree<K, D, C> &t,
- const unsigned int file_version)
- {
- using namespace boost::serialization;
- split_free(ar, t, file_version);
- }
- } }
- #endif
|