cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore::TBitField< T > Class Template Reference

Container to handle specific bitfields. More...

#include <TBitField.h>

Public Member Functions

 TBitField ()=default
 The default class constructor.
 TBitField (T init)
 The class constructor with the initial value.
 ~TBitField ()=default
 The class destructor.
T getMask () const
 Returns the current bit-mask.
bool constexpr getBit (size_t pos) const noexcept
 Will return the bit at the given position.
void setBit (size_t pos, bool on)
 Will set the bit at the given position to the given state.
void setBit (size_t pos)
 Will set the bit at the given position to true.
void clearBit (size_t pos)
 Will clear the bit at the given postion to false.
void clear ()
 Will clear all bits, they will set to false.
size_t maxBits () const
 Returns the upper limit for bit positions.

Detailed Description

template<class T>
class cppcore::TBitField< T >

Container to handle specific bitfields.

Definition at line 37 of file TBitField.h.

Constructor & Destructor Documentation

◆ TBitField() [1/2]

template<class T>
cppcore::TBitField< T >::TBitField ( )
default

The default class constructor.

◆ TBitField() [2/2]

template<class T>
cppcore::TBitField< T >::TBitField ( T init)
inlineexplicit

The class constructor with the initial value.

Parameters
[in]initThe init value.

Definition at line 83 of file TBitField.h.

◆ ~TBitField()

template<class T>
cppcore::TBitField< T >::~TBitField ( )
default

The class destructor.

Member Function Documentation

◆ clear()

template<class T>
void cppcore::TBitField< T >::clear ( )
inline

Will clear all bits, they will set to false.

Definition at line 121 of file TBitField.h.

◆ clearBit()

template<class T>
void cppcore::TBitField< T >::clearBit ( size_t pos)
inline

Will clear the bit at the given postion to false.

Parameters
[in]posThe bit position for write.

Definition at line 115 of file TBitField.h.

References maxBits().

Referenced by setBit().

◆ getBit()

template<class T>
bool constexpr cppcore::TBitField< T >::getBit ( size_t pos) const
inlineconstexprnoexcept

Will return the bit at the given position.

Parameters
[in]posThe bit position for readout.
Returns
true for bit is set, false for not.

Definition at line 93 of file TBitField.h.

References maxBits().

◆ getMask()

template<class T>
T cppcore::TBitField< T >::getMask ( ) const
inline

Returns the current bit-mask.

Returns
The bitmask.

Definition at line 88 of file TBitField.h.

◆ maxBits()

template<class T>
size_t cppcore::TBitField< T >::maxBits ( ) const
inline

Returns the upper limit for bit positions.

Returns
The upper position limit.

Definition at line 126 of file TBitField.h.

Referenced by clearBit(), getBit(), setBit(), and setBit().

◆ setBit() [1/2]

template<class T>
void cppcore::TBitField< T >::setBit ( size_t pos)
inline

Will set the bit at the given position to true.

Parameters
[in]posThe bit position for write.

Definition at line 109 of file TBitField.h.

References maxBits().

◆ setBit() [2/2]

template<class T>
void cppcore::TBitField< T >::setBit ( size_t pos,
bool on )
inline

Will set the bit at the given position to the given state.

Parameters
[in]posThe bit position for write.
[in]onThe bit state to set.

Definition at line 99 of file TBitField.h.

References clearBit(), maxBits(), and setBit().

Referenced by setBit().


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