TrueReality  v0.1.1912
trUtil::Bits Namespace Reference

Functions

template<class N , class B >
bool Has (N number, B bits)
 See if the "bits" are in "number". More...
 
template<class N , class B >
Add (N number, B bits)
 Add the "bits" to "number". More...
 
template<class N , class B >
Remove (N number, B bits)
 Remove the "bits" from "number". More...
 
template<class N , class B >
Toggle (N number, B bits)
 Toggle the "bits" in "number". More...
 

Function Documentation

◆ Add()

template<class N , class B >
template< class N, class B > inline N trUtil::Bits::Add ( number,
bits 
)
inline

Add the "bits" to "number".

unsigned int accum = 1;
accum = Bits::Add(accum, 7); //Has(accum, 1) and Has(accum, 7) == true

.

Template Parameters
NType of the n.
BType of the b.
Parameters
numberNumber of.
bitsThe bits.
Returns
A N.

Definition at line 80 of file Bits.h.

◆ Has()

template<class N , class B >
template< class N, class B > inline bool trUtil::Bits::Has ( number,
bits 
)
inline

See if the "bits" are in "number".

unsigned int accum = 3;
Bits::Has( accum, 1 ); //true
Bits::Has( accum, 7 ); //false

.

Template Parameters
NType of the n.
BType of the b.
Parameters
numberNumber of.
bitsThe bits.
Returns
True if it succeeds, false if it fails.

Definition at line 59 of file Bits.h.

Referenced by trUtil::Logging::Log::LogHorizRule(), and trUtil::Logging::Log::LogMessage().

Here is the caller graph for this function:

◆ Remove()

template<class N , class B >
template< class N, class B > inline N trUtil::Bits::Remove ( number,
bits 
)
inline

Remove the "bits" from "number".

unsigned int accum = 3;
accum = Bits::Remove(accum, 2); //Has(accum,3) == false, Has(accum,1) == true

.

Template Parameters
NType of the n.
BType of the b.
Parameters
numberNumber of.
bitsThe bits.
Returns
A N.

Definition at line 101 of file Bits.h.

◆ Toggle()

template<class N , class B >
template< class N, class B > inline N trUtil::Bits::Toggle ( number,
bits 
)
inline

Toggle the "bits" in "number".

unsigned int accum = 3;
unsigned int newBits;
newBits = Bits::Toggle(accum, 1); //newBits = 2
newBits = Bits::Toggle(accum, 1); //newBits = 3

.

Template Parameters
NType of the n.
BType of the b.
Parameters
numberNumber of.
bitsThe bits.
Returns
A N.

Definition at line 124 of file Bits.h.