Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::core::bit_view< BlockBits > Struct Template Reference

Provides packed access to fixed-width unsigned values stored in a byte span. More...

#include <bit_utils.h>

Public Member Functions

void set (uint32_t bitPosition, uint8_t value) noexcept
 Stores a packed value at the specified bit position.
 
uint8_t get (uint32_t bitPosition) const noexcept
 Reads a packed value from the specified bit position.
 

Public Attributes

std::span< uint8_t > m_data
 Bytes containing the packed values.
 

Static Public Attributes

static constexpr uint32_t MaxValue = (1 << BlockBits) - 1
 Largest value representable by one packed block.
 

Detailed Description

template<uint32_t BlockBits>
struct gaia::core::bit_view< BlockBits >

Provides packed access to fixed-width unsigned values stored in a byte span.

Template Parameters
BlockBitsNumber of bits occupied by each value.

Member Function Documentation

◆ get()

template<uint32_t BlockBits>
uint8_t gaia::core::bit_view< BlockBits >::get ( uint32_t  bitPosition) const
inlinenoexcept

Reads a packed value from the specified bit position.

Parameters
bitPositionBit offset of the value within m_data.
Returns
The decoded value.

◆ set()

template<uint32_t BlockBits>
void gaia::core::bit_view< BlockBits >::set ( uint32_t  bitPosition,
uint8_t  value 
)
inlinenoexcept

Stores a packed value at the specified bit position.

Parameters
bitPositionBit offset of the value within m_data.
valueValue to store. It must not exceed MaxValue.

The documentation for this struct was generated from the following file: