File indexing completed on 2025-01-18 09:42:41
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_NULL_BITMAP_TRAITS_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_PROTOCOL_NULL_BITMAP_TRAITS_HPP
0010
0011 #include <boost/assert.hpp>
0012
0013 #include <cstddef>
0014 #include <cstdint>
0015
0016 namespace boost {
0017 namespace mysql {
0018 namespace detail {
0019
0020 class null_bitmap_traits
0021 {
0022 std::size_t offset_;
0023 std::size_t num_fields_;
0024
0025 constexpr std::size_t byte_pos(std::size_t field_pos) const noexcept { return (field_pos + offset_) / 8; }
0026 constexpr std::size_t bit_pos(std::size_t field_pos) const noexcept { return (field_pos + offset_) % 8; }
0027
0028 public:
0029 constexpr null_bitmap_traits(std::size_t offset, std::size_t num_fields) noexcept
0030 : offset_(offset), num_fields_{num_fields} {};
0031 constexpr std::size_t offset() const noexcept { return offset_; }
0032 constexpr std::size_t num_fields() const noexcept { return num_fields_; }
0033
0034 constexpr std::size_t byte_count() const noexcept { return (num_fields_ + 7 + offset_) / 8; }
0035 bool is_null(const std::uint8_t* null_bitmap_begin, std::size_t field_pos) const noexcept
0036 {
0037 BOOST_ASSERT(field_pos < num_fields_);
0038 return null_bitmap_begin[byte_pos(field_pos)] & (1 << bit_pos(field_pos));
0039 }
0040 void set_null(std::uint8_t* null_bitmap_begin, std::size_t field_pos) const noexcept
0041 {
0042 BOOST_ASSERT(field_pos < num_fields_);
0043 null_bitmap_begin[byte_pos(field_pos)] |= (1 << bit_pos(field_pos));
0044 }
0045 };
0046
0047 constexpr std::size_t stmt_execute_null_bitmap_offset = 0;
0048 constexpr std::size_t binary_row_null_bitmap_offset = 2;
0049
0050 }
0051 }
0052 }
0053
0054 #endif