38constexpr std::size_t header_size = 2;
41typedef std::array<std::uint8_t, header_size> header;
45template <
typename Format>
47 using byte_type =
typename std::conditional<std::is_const<Format>::value, std::uint8_t
const, std::uint8_t>
::type;
48 using byte_count_type = std::uint32_t;
55 accessor_data(types::b_binary
const& binary) : accessor_data{binary.bytes, binary.size} {}
58 accessor_data(byte_type* bytes, byte_count_type size, header header_copy)
59 : bytes{bytes}, size{size}, header_copy{header_copy} {}
62 accessor_data(byte_type* bytes, byte_count_type size) : bytes{bytes}, size{size} {
63 std::memcpy(header_copy.data(), bytes, header_size);
68struct format_traits_base {
69 using element_count_type = std::size_t;
71 using byte_difference_type = std::ptrdiff_t;
72 using element_difference_type = std::ptrdiff_t;
74 using byte_reference = std::uint8_t&;
75 using const_byte_reference = std::uint8_t
const&;
77 using byte_iterator = std::uint8_t*;
78 using const_byte_iterator = std::uint8_t
const*;
83template <
typename Format>
88struct format_traits<formats::f_int8> : format_traits_base {
89 using value_type = std::int8_t;
91 using reference = std::int8_t&;
92 using const_reference = std::int8_t
const&;
93 using iterator = std::int8_t*;
94 using const_iterator = std::int8_t
const*;
96 static constexpr std::size_t element_count(std::uint32_t binary_data_length, header)
noexcept {
97 return binary_data_length - header_size;
100 static byte_iterator make_byte_iterator(iterator element, iterator)
noexcept {
101 return byte_iterator(
static_cast<void*
>(element));
104 static const_byte_iterator make_byte_iterator(const_iterator element, const_iterator)
noexcept {
105 return const_byte_iterator(
static_cast<void const*
>(element));
111struct format_traits<formats::f_float32> : format_traits_base {
112 using value_type = float;
114 using reference = elements::float32&;
115 using const_reference = elements::float32
const&;
116 using iterator = elements::float32*;
117 using const_iterator = elements::float32
const*;
119 static constexpr std::size_t element_count(std::uint32_t binary_data_length, header)
noexcept {
120 return (binary_data_length - header_size) /
sizeof(float);
123 static byte_iterator make_byte_iterator(iterator element, iterator)
noexcept {
124 return byte_iterator(
static_cast<void*
>(element));
127 static const_byte_iterator make_byte_iterator(const_iterator element, const_iterator)
noexcept {
128 return const_byte_iterator(
static_cast<void const*
>(element));
134struct format_traits<formats::f_packed_bit> : format_traits_base {
135 using value_type = bool;
137 using iterator = iterators::packed_bit_element<std::uint8_t*>;
138 using const_iterator = iterators::packed_bit_element<std::uint8_t const*>;
139 using reference = iterator::reference;
140 using const_reference = const_iterator::reference;
142 using byte_iterator = iterators::packed_bit_byte<std::uint8_t*>;
143 using const_byte_iterator = iterators::packed_bit_byte<std::uint8_t const*>;
144 using byte_reference = byte_iterator::reference;
145 using const_byte_reference = const_byte_iterator::reference;
147 using byte_difference_type = byte_iterator::difference_type;
148 using element_difference_type = iterator::difference_type;
150 static std::size_t element_count(std::uint32_t binary_data_length, header hdr)
noexcept {
151 return std::size_t{binary_data_length - header_size} * std::size_t{8u} - std::size_t{hdr[1] & 7u};
154 static byte_iterator make_byte_iterator(iterator element, iterator element_end)
noexcept {
155 return {element, element_end};
158 static constexpr const_byte_iterator make_byte_iterator(
159 const_iterator element,
160 const_iterator element_end)
noexcept {
161 return {element, element_end};
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
Declares entities in bsoncxx::v_noabi::vector::elements.
Declares entities in bsoncxx::v_noabi::vector::iterators.
Declarations related to the BSON Binary Vector subtype.
Declares entities whose ABI stability is NOT guaranteed.
type
An enumeration of each BSON type.
Definition types.hpp:43
The top-level namespace within which all bsoncxx library entities are declared.
Provides entities used to represent BSON types.