/* Copyright 2023 Joaquin M Lopez Munoz. * Distributed under 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 https://www.boost.org/libs/unordered for library home page. */ #ifndef BOOST_UNORDERED_DETAIL_SERIALIZE_FCA_CONTAINER_HPP #define BOOST_UNORDERED_DETAIL_SERIALIZE_FCA_CONTAINER_HPP #include #if defined(BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0) #define BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER \ #include BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #undef BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #define BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER \ #include BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #undef BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #define BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER \ #include BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #undef BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #define BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER \ #include BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #undef BOOST_UNORDERED_BLOCK_BOOSTDEP_HEADER #include #include #else #include #include #endif namespace boost{ namespace unordered{ namespace detail{ /* Support for boost::unordered_[multi](map|set) loading from legacy archives. * Until Boost 1.84, serialization of these containers was provided from * Boost.Serialization via boost/serialization/boost_unordered_(map|set).hpp, * from that release on support is native in Boost.Unordered. To enable legacy * archive loading, BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0 * must be defined (it implies header dependency from Boost.Serialization). */ #if defined(BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0) template struct archive_input; template< typename Archive,typename K,typename T,typename H,typename P,typename A > struct archive_input >: boost::serialization::stl::archive_input_unordered_map< Archive, boost::unordered_map > {}; template< typename Archive,typename K,typename T,typename H,typename P,typename A > struct archive_input >: boost::serialization::stl::archive_input_unordered_multimap< Archive, boost::unordered_multimap > {}; template< typename Archive,typename K,typename H,typename P,typename A > struct archive_input >: boost::serialization::stl::archive_input_unordered_set< Archive, boost::unordered_set > {}; template< typename Archive,typename K,typename H,typename P,typename A > struct archive_input >: boost::serialization::stl::archive_input_unordered_multiset< Archive, boost::unordered_multiset > {}; #else struct legacy_archive_exception:std::runtime_error { legacy_archive_exception():std::runtime_error( "Legacy archive detected, define " "BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0 to load"){} }; #endif template struct load_or_save_fca_container; template struct load_or_save_fca_container /* save */ { template void operator()(Archive& ar,Container& x,unsigned int version)const { serialize_container(ar,x,version); } }; template struct load_or_save_fca_container /* load */ { template void operator()(Archive& ar,Container& x,unsigned int version)const { if(version==0){ #if defined(BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0) boost::serialization::stl::load_unordered_collection< Archive,Container,archive_input >(ar,x); #else throw_exception(legacy_archive_exception()); #endif } else{ serialize_container(ar,x,version); } } }; template void serialize_fca_container(Archive& ar,Container& x,unsigned int version) { load_or_save_fca_container()( ar,x,version); } } /* namespace detail */ } /* namespace unordered */ } /* namespace boost */ #endif