Go to the documentation of this file.
7 #include "tfriend_fw.hpp"
33 :
len{
len}, storage{std::move(storage)} {}
36 void set(int64_t index,
bool value);
39 void set(int64_t index) {
set(index,
true); }
41 void unset(int64_t index) {
set(index,
false); }
44 [[nodiscard]]
bool get(int64_t index)
const;
47 [[nodiscard]] std::vector<uint8_t>
get_bytes()
const {
65 std::vector<uint8_t> storage;
bool get(int64_t index) const
Get the value of the bit at the provided index.
Definition: bitfield.cpp:45
friend std::ostream & operator<<(std::ostream &os, const Bitfield &bitfield)
Definition: bitfield.cpp:52
Bitfield(std::vector< uint8_t > storage, int64_t len)
Definition: bitfield.hpp:32
Definition: bitfield.hpp:24
std::vector< uint8_t > get_bytes() const
Get the bitfield as an array of bytes.
Definition: bitfield.hpp:47
void set(int64_t index, bool value)
Set the bit to the provided index to either 1 or 0, depending on value.
Definition: bitfield.cpp:32
const int64_t len
Definition: bitfield.hpp:61
void set(int64_t index)
Set the bit to the provided index to 1.
Definition: bitfield.hpp:39
Bitfield(int64_t len)
Create a new Bitfield with the provided length (in bits).
Definition: bitfield.cpp:25
void unset(int64_t index)
Set the bit to the provided index to 0.
Definition: bitfield.hpp:41
Definition: bitfield.cpp:24