qlibs::bitfield class contains a setof functions for creating and manipulating bit fields also known as bit arrays. These are series of zeroes and ones spread across an array of storage units, such as unsigned long integers.
Structure
Bit arrays are stored in the qlibs::bitfield class. This class has two elements: an array of unsigned long integers called field
for storing the bits and an integer size
for storing the number of bits in the array.
Functions
Instance setup
Single-bit
Multiple-bits
Dump
Working with bitfields
#include <iostream>
#include <qlibs.h>
int main( int argc, char *argv[] )
{
uint16_t rWord;
vPort.
setup( vPortArea );
rWord =
static_cast<uint16_t
>( vPort.
readUINTn( 20, 16 );
std::cout << std::hex << vPortArea[0] << ", "
<< vPortArea[1] << ", "
<< vPortArea[2] << ", "
<< vPortArea[3] << ", "
<< vPortArea[4] << ", "
<< vPortArea[5] << ", "
<< std::endl ;
return EXIT_SUCCESS;
}
A BitField object.
Definition bitfield.hpp:36
uint32_t readUINTn(const size_t index, const size_t xBits) const noexcept
Reads an unsigned 32-bit value from the BitField.
Definition bitfield.cpp:113
bool clearAll(void) noexcept
Clear all the bits in the BitField.
Definition bitfield.cpp:25
bool setup(void *const area, const size_t area_size) noexcept
Setup a initialize a BitField instance.
Definition bitfield.cpp:8
bool writeBit(const size_t index, const bool value) noexcept
Writes one bit in a bitfield.
Definition bitfield.cpp:95
bool writeUINTn(const size_t index, const size_t xBits, uint32_t value) noexcept
Writes an unsigned n-bit value from the BitField.
Definition bitfield.cpp:134
uint8_t[4U *(((N - 1U)/32U)+1U)] bitArea
Variable that allocates block of bytes to hold N bits for a BitField .
Definition bitfield.hpp:31
The qLibs++ library namespace.
Definition fp16.cpp:4