37 template <bsoncxx::detail::endian = bsoncxx::detail::endian::native>
38 void construct(
float value);
40 template <bsoncxx::detail::endian = bsoncxx::detail::endian::native>
41 float convert()
const;
49 operator float()
const noexcept;
53 return *
this = *
this + other;
58 return *
this = *
this - other;
63 return *
this = *
this * other;
68 return *
this = *
this / other;
72 std::uint8_t bytes[4];
76inline void float32::construct<bsoncxx::detail::endian::little>(
float value) {
77 std::memcpy(bytes, &value,
sizeof value);
81inline void float32::construct<bsoncxx::detail::endian::big>(
float value) {
82 auto const ptr =
reinterpret_cast<unsigned char const*
>(&value);
90inline float float32::convert<bsoncxx::detail::endian::little>()
const {
92 std::memcpy(&value, bytes,
sizeof value);
97inline float float32::convert<bsoncxx::detail::endian::big>()
const {
99 auto const ptr =
reinterpret_cast<unsigned char*
>(&value);
108 this->construct(value);
111inline float32::operator float() const noexcept {
112 return this->convert();
117template <
typename Iterator>
118class packed_bit_element {
131 *
byte &= std::uint8_t(~mask);
139 packed_bit_element
const&
operator=(packed_bit_element
const& v)
const noexcept {
145 return *
this = *
this ^ other;
150 return *
this = *
this & other;
155 return *
this = *
this | other;
163 constexpr packed_bit_element(Iterator byte_iter, uint8_t bit_index) noexcept
164 :
byte{byte_iter}, mask{uint8_t(0x80u >> bit_index)} {}
171template <
typename Iterator>
182template <
typename Iterator>
183class packed_bit_byte {
186 constexpr operator std::uint8_t()
const noexcept {
193 packed_bit_byte
const&
operator=(std::uint8_t
const& v)
const noexcept {
199 packed_bit_byte
const&
operator=(packed_bit_byte
const& v)
const noexcept {
200 return *
this = std::uint8_t(v);
204 packed_bit_byte
const&
operator+=(std::uint8_t
const& other)
const noexcept {
205 return *
this = std::uint8_t(*
this + other);
209 packed_bit_byte
const&
operator-=(std::uint8_t
const& other)
const noexcept {
210 return *
this = std::uint8_t(*
this - other);
214 packed_bit_byte
const&
operator*=(std::uint8_t
const& other)
const noexcept {
215 return *
this = std::uint8_t(*
this * other);
219 packed_bit_byte
const&
operator/=(std::uint8_t
const& other)
const noexcept {
220 return *
this = *
this / other;
224 packed_bit_byte
const&
operator%=(std::uint8_t
const& other)
const noexcept {
225 return *
this = *
this % other;
229 packed_bit_byte
const&
operator^=(std::uint8_t
const& other)
const noexcept {
230 return *
this = *
this ^ other;
234 packed_bit_byte
const&
operator&=(std::uint8_t
const& other)
const noexcept {
235 return *
this = *
this & other;
239 packed_bit_byte
const&
operator|=(std::uint8_t
const& other)
const noexcept {
240 return *
this = *
this | other;
244 packed_bit_byte
const&
operator<<=(
unsigned other)
const noexcept {
245 return *
this = *
this << other;
249 packed_bit_byte
const&
operator>>=(
unsigned other)
const noexcept {
250 return *
this = *
this >> other;
258 constexpr packed_bit_byte(Iterator byte_iter, uint8_t byte_mask) noexcept :
byte{byte_iter}, mask{byte_mask} {}
267template <
typename Iterator>
269 std::uint8_t a_value = a;
270 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:62
float32 & operator-=(float const &other) noexcept
Operator -=, emulating normal float behavior.
Definition elements.hpp:57
float32 & operator+=(float const &other) noexcept
Operator +=, emulating normal float behavior.
Definition elements.hpp:52
float32 & operator/=(float const &other) noexcept
Operator /=, emulating normal float behavior.
Definition elements.hpp:67
float32(float value) noexcept
Construct a packed little-endian value from a float input in the local byte order.
Definition elements.hpp:107
Reference to a byte or partial byte within a vector of packed_bit elements. Allows access to each byt...
Definition elements.hpp:183
packed_bit_byte const & operator*=(std::uint8_t const &other) const noexcept
Operator *=, emulating number reference behavior.
Definition elements.hpp:214
packed_bit_byte const & operator+=(std::uint8_t const &other) const noexcept
Operator +=, emulating number reference behavior.
Definition elements.hpp:204
packed_bit_byte const & operator/=(std::uint8_t const &other) const noexcept
Operator /=, emulating number reference behavior.
Definition elements.hpp:219
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:199
packed_bit_byte const & operator^=(std::uint8_t const &other) const noexcept
Operator ^=, emulating number reference behavior.
Definition elements.hpp:229
packed_bit_byte const & operator&=(std::uint8_t const &other) const noexcept
Operator &=, emulating number reference behavior.
Definition elements.hpp:234
packed_bit_byte const & operator-=(std::uint8_t const &other) const noexcept
Operator -=, emulating number reference behavior.
Definition elements.hpp:209
packed_bit_byte const & operator|=(std::uint8_t const &other) const noexcept
Operator |=, emulating number reference behavior.
Definition elements.hpp:239
packed_bit_byte const & operator%=(std::uint8_t const &other) const noexcept
Operator %=, emulating number reference behavior.
Definition elements.hpp:224
packed_bit_byte const & operator<<=(unsigned other) const noexcept
Operator <<=, emulating number reference behavior.
Definition elements.hpp:244
packed_bit_byte const & operator>>=(unsigned other) const noexcept
Operator >>=, emulating number reference behavior.
Definition elements.hpp:249
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:193
Reference to a single element in a packed_bit vector.
Definition elements.hpp:118
packed_bit_element const & operator^=(value_type const &other) const noexcept
Operator ^=, emulating bool reference behavior.
Definition elements.hpp:144
packed_bit_element const & operator=(value_type const &v) const
Set the value of the element referenced.
Definition elements.hpp:129
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:139
packed_bit_element const & operator&=(value_type const &other) const noexcept
Operator &=, emulating bool reference behavior.
Definition elements.hpp:149
bool value_type
Value type chosen to represent a single-bit element.
Definition elements.hpp:121
packed_bit_element const & operator|=(value_type const &other) const noexcept
Operator |=, emulating bool reference behavior.
Definition elements.hpp:154
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:172
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.