OpenBarnyard
 
Loading...
Searching...
No Matches
Toshi::TBitField< NUM_BITS > Class Template Reference

#include <TBitField.h>

Public Types

using ValueType = TUINT32
 

Public Member Functions

 TBitField ()
 
void Set (TINT a_iBitNum, TBOOL a_bSet)
 
TBOOL IsSet (TINT a_iBitNum) const
 

Static Public Attributes

static constexpr TUINT MIN_NUM_BITS = 8 * sizeof( ValueType )
 
static constexpr TUINT BIT_SUBNUM_MASK = MIN_NUM_BITS - 1
 

Detailed Description

template<TUINT NUM_BITS>
class Toshi::TBitField< NUM_BITS >

Definition at line 8 of file TBitField.h.

Member Typedef Documentation

◆ ValueType

template<TUINT NUM_BITS>
using Toshi::TBitField< NUM_BITS >::ValueType = TUINT32

Definition at line 11 of file TBitField.h.

Constructor & Destructor Documentation

◆ TBitField()

template<TUINT NUM_BITS>
Toshi::TBitField< NUM_BITS >::TBitField ( )
inline

Definition at line 16 of file TBitField.h.

17 {
18 T2_FOREACH_ARRAY( m_Values, i )
19 {
20 m_Values[ i ] = 0;
21 }
22 }
#define T2_FOREACH_ARRAY(arrName, iteratorName)
Definition T2Iterator.h:10

Member Function Documentation

◆ IsSet()

template<TUINT NUM_BITS>
TBOOL Toshi::TBitField< NUM_BITS >::IsSet ( TINT a_iBitNum) const
inline

Definition at line 36 of file TBitField.h.

37 {
38 TASSERT( a_iBitNum >= 0 );
40
41 return ( m_Values[ a_iBitNum / MIN_NUM_BITS ] & ( 1 << ( a_iBitNum % NUM_BITS ) ) ) != 0;
42 }
#define TASSERT(X,...)
Definition Defines.h:138
static constexpr TUINT MIN_NUM_BITS
Definition TBitField.h:12

◆ Set()

template<TUINT NUM_BITS>
void Toshi::TBitField< NUM_BITS >::Set ( TINT a_iBitNum,
TBOOL a_bSet )
inline

Definition at line 24 of file TBitField.h.

25 {
26 TASSERT( a_iBitNum >= 0 );
28
29 TUINT uiBit = 1 << ( a_iBitNum % NUM_BITS );
30
31 if ( a_bSet ) m_Values[ a_iBitNum / MIN_NUM_BITS ] |= uiBit;
32 else
33 m_Values[ a_iBitNum / MIN_NUM_BITS ] &= ~uiBit;
34 }

Member Data Documentation

◆ BIT_SUBNUM_MASK

template<TUINT NUM_BITS>
TUINT Toshi::TBitField< NUM_BITS >::BIT_SUBNUM_MASK = MIN_NUM_BITS - 1
staticconstexpr

Definition at line 13 of file TBitField.h.

◆ MIN_NUM_BITS

template<TUINT NUM_BITS>
TUINT Toshi::TBitField< NUM_BITS >::MIN_NUM_BITS = 8 * sizeof( ValueType )
staticconstexpr

Definition at line 12 of file TBitField.h.


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