39template <
typename Iterator>
40class packed_bit_element {
65 constexpr bool operator==(packed_bit_element
const& other)
const noexcept {
66 return byte == other.byte && bit == other.bit;
70 constexpr bool operator!=(packed_bit_element
const& other)
const noexcept {
71 return byte != other.byte || bit != other.bit;
75 constexpr bool operator<(packed_bit_element
const& other)
const noexcept {
76 return byte < other.byte || (
byte == other.byte && bit < other.bit);
80 constexpr bool operator<=(packed_bit_element
const& other)
const noexcept {
81 return byte < other.byte || (
byte == other.byte && bit <= other.bit);
85 constexpr bool operator>(packed_bit_element
const& other)
const noexcept {
86 return byte > other.byte || (
byte == other.byte && bit > other.bit);
90 constexpr bool operator>=(packed_bit_element
const& other)
const noexcept {
91 return byte > other.byte || (
byte == other.byte && bit >= other.bit);
107 return *
this + (-other);
117 return *(*
this + other);
122 return *
this = *
this + other;
127 return *
this = *
this - other;
142 packed_bit_element prev = *
this;
149 packed_bit_element prev = *
this;
157 friend class
accessor<formats::f_packed_bit const>;
160 : byte{byte_iter}, bit{bit_index} {}
168template <
typename Iterator>
169class packed_bit_byte {
191 return {byte, (
byte + 1) == byte_end ? last_byte_mask :
value_type{0xFFu}};
195 constexpr bool operator==(packed_bit_byte
const& other)
const noexcept {
196 return byte == other.byte;
200 constexpr bool operator!=(packed_bit_byte
const& other)
const noexcept {
201 return byte != other.byte;
205 constexpr bool operator<(packed_bit_byte
const& other)
const noexcept {
206 return byte < other.byte;
210 constexpr bool operator<=(packed_bit_byte
const& other)
const noexcept {
211 return byte <= other.byte;
215 constexpr bool operator>(packed_bit_byte
const& other)
const noexcept {
216 return byte > other.byte;
220 constexpr bool operator>=(packed_bit_byte
const& other)
const noexcept {
221 return byte >= other.byte;
228 return {
byte + other, byte_end, last_byte_mask};
235 return *
this + (-other);
241 return {
byte - other.byte};
245 return *(*
this + other);
250 return *
this = *
this + other;
255 return *
this = *
this - other;
270 packed_bit_byte prev = *
this;
277 packed_bit_byte prev = *
this;
283 friend struct detail::format_traits<
formats::f_packed_bit>;
284 friend struct detail::format_traits<formats::f_packed_bit const>;
286 constexpr
packed_bit_byte(packed_bit_element<Iterator> element, packed_bit_element<Iterator> element_end)
287 : byte{element.byte},
288 byte_end{(element_end + 7u).
byte},
289 last_byte_mask{
value_type(0xFFu << (-element_end.bit & 7))} {}
291 constexpr packed_bit_byte(Iterator
byte, Iterator byte_end,
value_type last_byte_mask)
292 : byte{byte}, byte_end{byte_end}, last_byte_mask{last_byte_mask} {}
Declares bsoncxx::v_noabi::vector::accessor.
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
Accessor for the contents of a valid BSON Binary Vector.
Definition accessor.hpp:53
Reference to a byte or partial byte within a vector of packed_bit elements. Allows access to each byt...
Definition elements.hpp:183
Reference to a single element in a packed_bit vector.
Definition elements.hpp:118
Iterator for bytes within a packed_bit vector.
Definition iterators.hpp:169
packed_bit_byte & operator++() noexcept
Pre-increment.
Definition iterators.hpp:259
packed_bit_byte & operator+=(difference_type const &other) noexcept
Advance this iterator forward by the indicated number of bytes.
Definition iterators.hpp:249
constexpr bool operator==(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:195
constexpr packed_bit_byte operator-(difference_type const &other) const noexcept
Calculate a signed subtraction of a ptrdiff_t from this iterator, moving it backward or forward the i...
Definition iterators.hpp:234
packed_bit_byte operator--(int) noexcept
Post-decrement.
Definition iterators.hpp:276
constexpr reference operator*() const noexcept
Dereference the byte iterator.
Definition iterators.hpp:190
elements::packed_bit_byte< Iterator > const reference
References to individual bytes are each bsoncxx::v_noabi::elements::packed_bit_byte,...
Definition iterators.hpp:176
constexpr difference_type operator-(packed_bit_byte const &other) const noexcept
Calculate the difference in position between two byte iterators If the two iterators do not point int...
Definition iterators.hpp:240
constexpr bool operator!=(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:200
constexpr bool operator>(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:215
elements::packed_bit_byte< Iterator > const * pointer
Element pointers aren't really a useful concept here, but this is defined for compatibility with stan...
Definition iterators.hpp:180
packed_bit_byte & operator--() noexcept
Pre-decrement.
Definition iterators.hpp:264
constexpr bool operator<=(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:210
std::random_access_iterator_tag iterator_category
This is a standard random-access iterator.
Definition iterators.hpp:183
constexpr packed_bit_byte operator+(difference_type const &other) const noexcept
Calculate a signed addition of this iterator with a ptrdiff_t, moving it forward or backward the indi...
Definition iterators.hpp:227
constexpr bool operator>=(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:220
std::uint8_t value_type
Values pointed to by this iterator are unsigned bytes.
Definition iterators.hpp:172
packed_bit_byte & operator-=(difference_type const &other) noexcept
Move this iterator backward by the indicated number of bytes.
Definition iterators.hpp:254
std::ptrdiff_t difference_type
A signed byte count.
Definition iterators.hpp:186
packed_bit_byte operator++(int) noexcept
Post-increment.
Definition iterators.hpp:269
constexpr bool operator<(packed_bit_byte const &other) const noexcept
Compare two byte iterators.
Definition iterators.hpp:205
Iterator for elements within a packed_bit vector.
Definition iterators.hpp:40
constexpr difference_type operator-(packed_bit_element const &other) const noexcept
Calculate the difference in position between two bit iterators If the two iterators do not point into...
Definition iterators.hpp:112
packed_bit_element operator--(int) noexcept
Post-decrement.
Definition iterators.hpp:148
std::ptrdiff_t difference_type
A signed bit count.
Definition iterators.hpp:56
constexpr bool operator==(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:65
packed_bit_element & operator+=(difference_type const &other) noexcept
Advance this iterator forward by the indicated number of bits.
Definition iterators.hpp:121
packed_bit_element & operator--() noexcept
Pre-decrement.
Definition iterators.hpp:136
elements::packed_bit_element< Iterator > const * pointer
Element pointers aren't really a useful concept here, but this is defined for compatibility with stan...
Definition iterators.hpp:50
constexpr packed_bit_element operator-(difference_type const &other) const noexcept
Calculate a signed subtraction of a ptrdiff_t from this iterator, moving it backward or forward the i...
Definition iterators.hpp:106
elements::packed_bit_element< Iterator > const reference
References to individual bits are each bsoncxx::v_noabi::elements::packed_bit_element.
Definition iterators.hpp:46
std::random_access_iterator_tag iterator_category
This is a standard random-access iterator.
Definition iterators.hpp:53
constexpr packed_bit_element operator+(difference_type const &other) const noexcept
Calculate a signed addition of this iterator with a ptrdiff_t, moving it forward or backward the indi...
Definition iterators.hpp:97
packed_bit_element & operator-=(difference_type const &other) noexcept
Move this iterator backward by the indicated number of bits.
Definition iterators.hpp:126
packed_bit_element & operator++() noexcept
Pre-increment.
Definition iterators.hpp:131
bool value_type
Values pointed to by this iterator are single bits represented by bool.
Definition iterators.hpp:43
constexpr bool operator<=(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:80
constexpr bool operator>(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:85
constexpr bool operator!=(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:70
constexpr reference operator*() const noexcept
Dereference this bit iterator into a bit reference.
Definition iterators.hpp:60
packed_bit_element operator++(int) noexcept
Post-increment.
Definition iterators.hpp:141
constexpr bool operator<(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:75
constexpr bool operator>=(packed_bit_element const &other) const noexcept
Compare two bit iterators.
Definition iterators.hpp:90
Declares entities in bsoncxx::v_noabi::vector::elements.
Forward declarations for bsoncxx::v_noabi::vector::iterators.
Declares iterator types for BSON Binary Vector.
Declarations related to the BSON Binary Vector subtype.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all bsoncxx library entities are declared.