X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fmultiprecision%2Fcpp_int%2Fserialize.hpp;h=bd32108ba80f58b16248ed3c94a4e0257cbc0646;hb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;hp=042a9f89f7e543eb2ee2ab85d168e88f2924eae4;hpb=a0324939f9d0e1905d5df8f57442f09dc70af83d;p=ceph.git diff --git a/ceph/src/boost/boost/multiprecision/cpp_int/serialize.hpp b/ceph/src/boost/boost/multiprecision/cpp_int/serialize.hpp index 042a9f89f..bd32108ba 100644 --- a/ceph/src/boost/boost/multiprecision/cpp_int/serialize.hpp +++ b/ceph/src/boost/boost/multiprecision/cpp_int/serialize.hpp @@ -1,35 +1,38 @@ /////////////////////////////////////////////////////////////// // Copyright 2013 John Maddock. 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_ +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt #ifndef BOOST_MP_CPP_INT_SERIALIZE_HPP #define BOOST_MP_CPP_INT_SERIALIZE_HPP namespace boost { -namespace archive{ +namespace archive { class binary_oarchive; class binary_iarchive; -} +} // namespace archive namespace serialization { namespace mp = boost::multiprecision; -namespace cpp_int_detail{ +namespace cpp_int_detail { using namespace boost::multiprecision; using namespace boost::multiprecision::backends; template -struct is_binary_archive : public mpl::false_ {}; +struct is_binary_archive : public mpl::false_ +{}; template <> -struct is_binary_archive : public mpl::true_ {}; +struct is_binary_archive : public mpl::true_ +{}; template <> -struct is_binary_archive : public mpl::true_ {}; +struct is_binary_archive : public mpl::true_ +{}; // // We have 8 serialization methods to fill out (and test), they are all permutations of: @@ -44,26 +47,27 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&, // Non-trivial. // Non binary. - bool s; - ar & s; + using boost::make_nvp; + bool s; + ar& make_nvp("sign", s); std::size_t limb_count; std::size_t byte_count; - ar & byte_count; + ar& make_nvp("byte-count", byte_count); limb_count = byte_count / sizeof(limb_type) + ((byte_count % sizeof(limb_type)) ? 1 : 0); val.resize(limb_count, limb_count); limb_type* pl = val.limbs(); - for(std::size_t i = 0; i < limb_count; ++i) + for (std::size_t i = 0; i < limb_count; ++i) { pl[i] = 0; - for(std::size_t j = 0; (j < sizeof(limb_type)) && byte_count; ++j) + for (std::size_t j = 0; (j < sizeof(limb_type)) && byte_count; ++j) { unsigned char byte; - ar & byte; + ar& make_nvp("byte", byte); pl[i] |= static_cast(byte) << (j * CHAR_BIT); --byte_count; } } - if(s != val.sign()) + if (s != val.sign()) val.negate(); val.normalize(); } @@ -74,20 +78,21 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&, // Non-trivial. // Non binary. - bool s = val.sign(); - ar & s; - limb_type* pl = val.limbs(); + using boost::make_nvp; + bool s = val.sign(); + ar& make_nvp("sign", s); + limb_type* pl = val.limbs(); std::size_t limb_count = val.size(); std::size_t byte_count = limb_count * sizeof(limb_type); - ar & byte_count; + ar& make_nvp("byte-count", byte_count); - for(std::size_t i = 0; i < limb_count; ++i) + for (std::size_t i = 0; i < limb_count; ++i) { limb_type l = pl[i]; - for(std::size_t j = 0; j < sizeof(limb_type); ++j) + for (std::size_t j = 0; j < sizeof(limb_type); ++j) { unsigned char byte = static_cast((l >> (j * CHAR_BIT)) & ((1u << CHAR_BIT) - 1)); - ar & byte; + ar& make_nvp("byte", byte); } } } @@ -97,19 +102,20 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&, // Load. // Trivial. // Non binary. - bool s; + using boost::make_nvp; + bool s; typename Int::local_limb_type l = 0; - ar & s; - std::size_t byte_count; - ar & byte_count; - for(std::size_t i = 0; i < byte_count; ++i) + ar& make_nvp("sign", s); + std::size_t byte_count; + ar& make_nvp("byte-count", byte_count); + for (std::size_t i = 0; i < byte_count; ++i) { unsigned char b; - ar & b; + ar& make_nvp("byte", b); l |= static_cast(b) << (i * CHAR_BIT); } *val.limbs() = l; - if(s != val.sign()) + if (s != val.sign()) val.negate(); } template @@ -118,15 +124,16 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, m // Store. // Trivial. // Non binary. - bool s = val.sign(); + using boost::make_nvp; + bool s = val.sign(); typename Int::local_limb_type l = *val.limbs(); - ar & s; - std::size_t limb_count = sizeof(l); - ar & limb_count; - for(std::size_t i = 0; i < limb_count; ++i) + ar& make_nvp("sign", s); + std::size_t limb_count = sizeof(l); + ar& make_nvp("byte-count", limb_count); + for (std::size_t i = 0; i < limb_count; ++i) { unsigned char b = static_cast(static_cast(l >> (i * CHAR_BIT)) & static_cast((1u << CHAR_BIT) - 1)); - ar & b; + ar& make_nvp("byte", b); } } template @@ -135,13 +142,13 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&, // Load. // Non-trivial. // Binary. - bool s; + bool s; std::size_t c; - ar & s; - ar & c; + ar& s; + ar& c; val.resize(c, c); ar.load_binary(val.limbs(), c * sizeof(limb_type)); - if(s != val.sign()) + if (s != val.sign()) val.negate(); val.normalize(); } @@ -151,10 +158,10 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&, // Store. // Non-trivial. // Binary. - bool s = val.sign(); + bool s = val.sign(); std::size_t c = val.size(); - ar & s; - ar & c; + ar& s; + ar& c; ar.save_binary(val.limbs(), c * sizeof(limb_type)); } template @@ -164,9 +171,9 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&, // Trivial. // Binary. bool s; - ar & s; + ar& s; ar.load_binary(val.limbs(), sizeof(*val.limbs())); - if(s != val.sign()) + if (s != val.sign()) val.negate(); } template @@ -176,24 +183,24 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, m // Trivial. // Binary. bool s = val.sign(); - ar & s; + ar& s; ar.save_binary(val.limbs(), sizeof(*val.limbs())); } -} +} // namespace cpp_int_detail -template -void serialize(Archive & ar, mp::cpp_int_backend& val, const unsigned int /*version*/) +template +void serialize(Archive& ar, mp::cpp_int_backend& val, const unsigned int /*version*/) { - typedef typename Archive::is_saving save_tag; + typedef typename Archive::is_saving save_tag; typedef mpl::bool_ >::value> trivial_tag; - typedef typename cpp_int_detail::is_binary_archive::type binary_tag; + typedef typename cpp_int_detail::is_binary_archive::type binary_tag; // Just dispatch to the correct method: cpp_int_detail::do_serialize(ar, val, save_tag(), trivial_tag(), binary_tag()); } -}} // namespaces +} // namespace serialization +} // namespace boost #endif // BOOST_MP_CPP_INT_SERIALIZE_HPP -