7#include "../macros.hpp"
10#include "exception.hpp"
17hi_export_module(hikogui.utility.bits);
19hi_export
namespace hi {
inline namespace v1 {
29 auto const byte_index = index >> 3;
30 auto const bit_index = index & 7;
33 hi_axiom(byte_index < buffer.size());
34 return to_bool(std::bit_cast<uint8_t>(buffer[byte_index] >> bit_index) & 1);
64 auto const byte_index = index >> 3;
65 auto const bit_index = index & 7;
66 hi_axiom(byte_index < buffer.size());
68 auto const available_bits = 8 - bit_index;
69 auto const nr_bits =
std::min(available_bits, todo);
71 auto const mask = (1 << nr_bits) - 1;
73 auto const tmp =
static_cast<int>(buffer[byte_index] >> bit_index) & mask;
Functions for casting values between types savely.
Utilities for throwing exceptions and terminating the application.
The HikoGUI namespace.
Definition array_generic.hpp:20
std::size_t get_bits(std::span< std::byte const > buffer, std::size_t &index, std::size_t length) noexcept
Read a bits from of span of bytes Bits are ordered LSB first.
Definition bits.hpp:55
bool get_bit(std::span< std::byte const > buffer, std::size_t &index) noexcept
Read a single bit from span of bytes Bits are ordered LSB first.
Definition bits.hpp:27
DOXYGEN BUG.
Definition algorithm_misc.hpp:20