XII Release 0.1.0
Loading...
Searching...
No Matches
xiiStaticBitfield< T > Class Template Reference

Public Types

using StorageType = T
 
using ConstIterator = xiiBitIterator<StorageType, true, xiiUInt32>
 

Public Member Functions

 xiiStaticBitfield ()
 Initializes the bitfield to all zero.
 
bool IsAnyBitSet () const
 Returns true, if the bitfield is not zero.
 
bool IsNoBitSet () const
 Returns true, if the bitfield is all zero.
 
bool AreAllBitsSet () const
 Returns true, if the bitfield is not empty and all bits are set to one.
 
void SetBit (xiiUInt32 uiBit)
 Sets the given bit to 1.
 
void ClearBit (xiiUInt32 uiBit)
 Clears the given bit to 0.
 
void SetBitValue (xiiUInt32 uiBit, bool bValue)
 Sets the given bit to 1 or 0 depending on the given value.
 
bool IsBitSet (xiiUInt32 uiBit) const
 Returns true, if the given bit is set to 1.
 
void ClearAllBits ()
 Clears all bits to 0. Same as Clear().
 
void SetAllBits ()
 Sets all bits to 1.
 
void SetBitRange (xiiUInt32 uiFirstBit, xiiUInt32 uiNumBits)
 Sets the range starting at uiFirstBit up to (and including) uiLastBit to 1.
 
void ClearBitRange (xiiUInt32 uiFirstBit, xiiUInt32 uiNumBits)
 Clears the range starting at uiFirstBit up to (and including) uiLastBit to 0.
 
xiiUInt32 GetLowestBitSet () const
 Returns the index of the lowest bit that is set. Returns the max index+1 in case no bit is set, at all.
 
xiiUInt32 GetHighestBitSet () const
 Returns the index of the highest bit that is set. Returns the max index+1 in case no bit is set, at all.
 
xiiUInt32 GetNumBitsSet () const
 Returns the count of how many bits are set in total.
 
GetValue () const
 Returns the raw uint that stores all bits.
 
void SetValue (T value)
 Sets the raw uint that stores all bits.
 
void Swap (xiiStaticBitfield< T > &other)
 Swaps two bitfields.
 
XII_ALWAYS_INLINE void operator|= (const xiiStaticBitfield< T > &rhs)
 Modifies this to also contain the bits from rhs.
 
XII_ALWAYS_INLINE void operator&= (const xiiStaticBitfield< T > &rhs)
 Modifies this to only contain the bits that were set in this and rhs.
 
xiiResult Serialize (xiiStreamWriter &ref_writer) const
 
xiiResult Deserialize (xiiStreamReader &ref_reader)
 
ConstIterator GetIterator () const
 Returns a constant iterator to the very first set bit. Note that due to the way iterating through bits is accelerated, changes to the bitfield while iterating through the bits has undefined behaviour.
 
ConstIterator GetEndIterator () const
 Returns an invalid iterator. Needed to support range based for loops.
 

Static Public Member Functions

static constexpr xiiUInt32 GetStorageTypeBitCount ()
 
static xiiStaticBitfield< T > MakeFromMask (StorageType bits)
 

Friends

template<typename U>
xiiStaticBitfield< U > operator| (xiiStaticBitfield< U > lhs, xiiStaticBitfield< U > rhs)
 
template<typename U>
xiiStaticBitfield< U > operator& (xiiStaticBitfield< U > lhs, xiiStaticBitfield< U > rhs)
 
template<typename U>
xiiStaticBitfield< U > operator^ (xiiStaticBitfield< U > lhs, xiiStaticBitfield< U > rhs)
 
template<typename U>
bool operator== (xiiStaticBitfield< U > lhs, xiiStaticBitfield< U > rhs)
 

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