File indexing completed on 2025-01-18 09:42:41
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_BIT_DESERIALIZATION_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_BIT_DESERIALIZATION_HPP
0010
0011 #include <boost/mysql/field_view.hpp>
0012 #include <boost/mysql/string_view.hpp>
0013
0014 #include <boost/mysql/impl/internal/protocol/serialization.hpp>
0015
0016 #include <boost/endian/conversion.hpp>
0017
0018 #include <cstring>
0019
0020 namespace boost {
0021 namespace mysql {
0022 namespace detail {
0023
0024
0025
0026
0027
0028
0029 inline deserialize_errc deserialize_bit(string_view from, field_view& to) noexcept
0030 {
0031 std::size_t num_bytes = from.size();
0032 if (num_bytes < 1 || num_bytes > 8)
0033 {
0034 return deserialize_errc::protocol_value_error;
0035 }
0036 unsigned char temp[8]{};
0037 unsigned char* dest = temp + sizeof(temp) - num_bytes;
0038 std::memcpy(dest, from.data(), num_bytes);
0039 to = field_view(endian::load_big_u64(temp));
0040 return deserialize_errc::ok;
0041 }
0042
0043 }
0044 }
0045 }
0046
0047 #endif