43#if defined(_WIN32) || \
44 (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
45 defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)
46 std::memcpy(bytes, &value,
sizeof value);
47#elif (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
48 defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)
50 std::memcpy(&u32, &value,
sizeof value);
51 u32 = __builtin_bswap32(u32);
52 std::memcpy(bytes, &u32,
sizeof value);
54#error No implementation for storing 32-bit little endian unaligned float
59 operator float() const noexcept {
61#if defined(_WIN32) || \
62 (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
63 defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN)
64 std::memcpy(&value, bytes,
sizeof value);
65#elif (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
66 defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN)
68 std::memcpy(&u32, bytes,
sizeof value);
69 u32 = __builtin_bswap32(u32);
70 std::memcpy(&value, &u32,
sizeof value);
72#error No implementation for loading 32-bit little endian unaligned float
59 operator float() const noexcept {
…}
79 return *
this = *
this + other;
84 return *
this = *
this - other;
89 return *
this = *
this * other;
94 return *
this = *
this / other;
98 std::uint8_t bytes[4];
103template <
typename Iterator>
104class packed_bit_element {
117 *
byte &= std::uint8_t(~mask);
125 packed_bit_element
const&
operator=(packed_bit_element
const& v)
const noexcept {
125 packed_bit_element
const&
operator=(packed_bit_element
const& v)
const noexcept {
…}
131 return *
this = *
this ^ other;
136 return *
this = *
this & other;
141 return *
this = *
this | other;
149 constexpr packed_bit_element(Iterator byte_iter, uint8_t bit_index) noexcept
150 :
byte{byte_iter}, mask{uint8_t(0x80u >> bit_index)} {}
104class packed_bit_element {
…};
157template <
typename Iterator>
168template <
typename Iterator>
169class packed_bit_byte {
172 constexpr operator std::uint8_t() const noexcept {
172 constexpr operator std::uint8_t() const noexcept {
…}
179 packed_bit_byte
const&
operator=(std::uint8_t
const& v)
const noexcept {
179 packed_bit_byte
const&
operator=(std::uint8_t
const& v)
const noexcept {
…}
185 packed_bit_byte
const&
operator=(packed_bit_byte
const& v)
const noexcept {
186 return *
this = std::uint8_t(v);
185 packed_bit_byte
const&
operator=(packed_bit_byte
const& v)
const noexcept {
…}
190 packed_bit_byte
const&
operator+=(std::uint8_t
const& other)
const noexcept {
191 return *
this = std::uint8_t(*
this + other);
190 packed_bit_byte
const&
operator+=(std::uint8_t
const& other)
const noexcept {
…}
195 packed_bit_byte
const&
operator-=(std::uint8_t
const& other)
const noexcept {
196 return *
this = std::uint8_t(*
this - other);
195 packed_bit_byte
const&
operator-=(std::uint8_t
const& other)
const noexcept {
…}
200 packed_bit_byte
const&
operator*=(std::uint8_t
const& other)
const noexcept {
201 return *
this = std::uint8_t(*
this * other);
200 packed_bit_byte
const&
operator*=(std::uint8_t
const& other)
const noexcept {
…}
205 packed_bit_byte
const&
operator/=(std::uint8_t
const& other)
const noexcept {
206 return *
this = *
this / other;
205 packed_bit_byte
const&
operator/=(std::uint8_t
const& other)
const noexcept {
…}
210 packed_bit_byte
const&
operator%=(std::uint8_t
const& other)
const noexcept {
211 return *
this = *
this % other;
210 packed_bit_byte
const&
operator%=(std::uint8_t
const& other)
const noexcept {
…}
215 packed_bit_byte
const&
operator^=(std::uint8_t
const& other)
const noexcept {
216 return *
this = *
this ^ other;
215 packed_bit_byte
const&
operator^=(std::uint8_t
const& other)
const noexcept {
…}
220 packed_bit_byte
const&
operator&=(std::uint8_t
const& other)
const noexcept {
221 return *
this = *
this & other;
220 packed_bit_byte
const&
operator&=(std::uint8_t
const& other)
const noexcept {
…}
225 packed_bit_byte
const&
operator|=(std::uint8_t
const& other)
const noexcept {
226 return *
this = *
this | other;
225 packed_bit_byte
const&
operator|=(std::uint8_t
const& other)
const noexcept {
…}
230 packed_bit_byte
const&
operator<<=(
unsigned other)
const noexcept {
231 return *
this = *
this << other;
235 packed_bit_byte
const&
operator>>=(
unsigned other)
const noexcept {
236 return *
this = *
this >> other;
244 constexpr packed_bit_byte(Iterator byte_iter,
uint8_t byte_mask) noexcept :
byte{byte_iter}, mask{byte_mask} {}
169class packed_bit_byte {
…};
253template <
typename Iterator>
255 std::uint8_t a_value = a;
256 std::uint8_t b_value = b;
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
float32 & operator*=(float const &other) noexcept
Operator *=, emulating normal float behavior.
Definition elements.hpp:88
float32 & operator-=(float const &other) noexcept
Operator -=, emulating normal float behavior.
Definition elements.hpp:83
float32 & operator+=(float const &other) noexcept
Operator +=, emulating normal float behavior.
Definition elements.hpp:78
float32 & operator/=(float const &other) noexcept
Operator /=, emulating normal float behavior.
Definition elements.hpp:93
float32(float value) noexcept
Construct a packed little-endian value from a float input in the local byte order.
Definition elements.hpp:42
Reference to a byte or partial byte within a vector of packed_bit elements. Allows access to each byt...
Definition elements.hpp:169
packed_bit_byte const & operator*=(std::uint8_t const &other) const noexcept
Operator *=, emulating number reference behavior.
Definition elements.hpp:200
packed_bit_byte const & operator+=(std::uint8_t const &other) const noexcept
Operator +=, emulating number reference behavior.
Definition elements.hpp:190
packed_bit_byte const & operator/=(std::uint8_t const &other) const noexcept
Operator /=, emulating number reference behavior.
Definition elements.hpp:205
packed_bit_byte const & operator=(packed_bit_byte const &v) const noexcept
Copy the referenced value from another reference of the same type.
Definition elements.hpp:185
packed_bit_byte const & operator^=(std::uint8_t const &other) const noexcept
Operator ^=, emulating number reference behavior.
Definition elements.hpp:215
packed_bit_byte const & operator&=(std::uint8_t const &other) const noexcept
Operator &=, emulating number reference behavior.
Definition elements.hpp:220
packed_bit_byte const & operator-=(std::uint8_t const &other) const noexcept
Operator -=, emulating number reference behavior.
Definition elements.hpp:195
packed_bit_byte const & operator|=(std::uint8_t const &other) const noexcept
Operator |=, emulating number reference behavior.
Definition elements.hpp:225
constexpr operator std::uint8_t() const noexcept
Read the entire byte, as a std::uint8_t.
Definition elements.hpp:172
packed_bit_byte const & operator%=(std::uint8_t const &other) const noexcept
Operator %=, emulating number reference behavior.
Definition elements.hpp:210
packed_bit_byte const & operator<<=(unsigned other) const noexcept
Operator <<=, emulating number reference behavior.
Definition elements.hpp:230
packed_bit_byte const & operator>>=(unsigned other) const noexcept
Operator >>=, emulating number reference behavior.
Definition elements.hpp:235
packed_bit_byte const & operator=(std::uint8_t const &v) const noexcept
Overwrite the usable portion of the byte, and set reserved bits to zero.
Definition elements.hpp:179
Reference to a single element in a packed_bit vector.
Definition elements.hpp:104
packed_bit_element const & operator^=(value_type const &other) const noexcept
Operator ^=, emulating bool reference behavior.
Definition elements.hpp:130
packed_bit_element const & operator=(value_type const &v) const
Set the value of the element referenced.
Definition elements.hpp:115
packed_bit_element const & operator=(packed_bit_element const &v) const noexcept
Copy the referenced value from another reference of the same type.
Definition elements.hpp:125
packed_bit_element const & operator&=(value_type const &other) const noexcept
Operator &=, emulating bool reference behavior.
Definition elements.hpp:135
bool value_type
Value type chosen to represent a single-bit element.
Definition elements.hpp:107
packed_bit_element const & operator|=(value_type const &other) const noexcept
Operator |=, emulating bool reference behavior.
Definition elements.hpp:140
Iterator for bytes within a packed_bit vector.
Definition iterators.hpp:165
Iterator for elements within a packed_bit vector.
Definition iterators.hpp:40
Forward declarations for bsoncxx::v_noabi::vector::elements.
Forward declarations for bsoncxx::v_noabi::vector::iterators.
Declares element accessor types for BSON Binary Vector.
void swap(packed_bit_element< Iterator > a, packed_bit_element< Iterator > b) noexcept
packed_bit_element is Swappable even when it's not an lvalue reference
Definition elements.hpp:158
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.