Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:30

0001 #ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED
0002 #define BOOST_CORE_SERIALIZATION_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 // Copyright 2023 Peter Dimov
0011 // Distributed under the Boost Software License, Version 1.0.
0012 // https://www.boost.org/LICENSE_1_0.txt
0013 //
0014 // Utilities needed to implement serialization support
0015 // without including a Boost.Serialization header
0016 
0017 #include <boost/core/nvp.hpp>
0018 #include <cstddef>
0019 
0020 namespace boost
0021 {
0022 
0023 namespace serialization
0024 {
0025 
0026 // Forward declarations (needed for specializations)
0027 
0028 template<class T> struct version;
0029 
0030 class access;
0031 
0032 // Our own version_type replacement. This has to be in
0033 // the `serialization` namespace, because its only purpose
0034 // is to add `serialization` as an associated namespace.
0035 
0036 struct core_version_type
0037 {
0038     unsigned int version_;
0039 
0040     core_version_type( unsigned int version ): version_( version ) {}
0041     operator unsigned int () const { return version_; }
0042 };
0043 
0044 } // namespace serialization
0045 
0046 namespace core
0047 {
0048 
0049 // nvp
0050 
0051 using serialization::nvp;
0052 using serialization::make_nvp;
0053 
0054 // split_free
0055 
0056 namespace detail
0057 {
0058 
0059 template<bool IsSaving> struct load_or_save_f;
0060 
0061 template<> struct load_or_save_f<true>
0062 {
0063     template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
0064     {
0065         save( a, t, serialization::core_version_type( v ) );
0066     }
0067 };
0068 
0069 template<> struct load_or_save_f<false>
0070 {
0071     template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
0072     {
0073         load( a, t, serialization::core_version_type( v ) );
0074     }
0075 };
0076 
0077 } // namespace detail
0078 
0079 template<class A, class T> inline void split_free( A& a, T& t, unsigned int v )
0080 {
0081     detail::load_or_save_f< A::is_saving::value >()( a, t, v );
0082 }
0083 
0084 // split_member
0085 
0086 namespace detail
0087 {
0088 
0089 template<bool IsSaving, class Access = serialization::access> struct load_or_save_m;
0090 
0091 template<class Access> struct load_or_save_m<true, Access>
0092 {
0093     template<class A, class T> void operator()( A& a, T const& t, unsigned int v ) const
0094     {
0095         Access::member_save( a, t, v );
0096     }
0097 };
0098 
0099 template<class Access> struct load_or_save_m<false, Access>
0100 {
0101     template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
0102     {
0103         Access::member_load( a, t, v );
0104     }
0105 };
0106 
0107 } // namespace detail
0108 
0109 template<class A, class T> inline void split_member( A& a, T& t, unsigned int v )
0110 {
0111     detail::load_or_save_m< A::is_saving::value >()( a, t, v );
0112 }
0113 
0114 // load_construct_data_adl
0115 
0116 template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v )
0117 {
0118     load_construct_data( ar, t, serialization::core_version_type( v ) );
0119 }
0120 
0121 // save_construct_data_adl
0122 
0123 template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v )
0124 {
0125     save_construct_data( ar, t, serialization::core_version_type( v ) );
0126 }
0127 
0128 } // namespace core
0129 } // namespace boost
0130 
0131 #endif  // #ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED