A class for conducting with bitwise operations on registers. More...
#include <BitWizard.h>
Public Member Functions | |
BitWizard () | |
The constructor for the BitWizard class. Doesn't do anything. | |
bool | getBit (const BitMinion::BitIndexEnumType &bitIndex, const T ®isterValue) const |
Gets a specific bit from the provided register. | |
T | getBits (const BitMinion::BitIndexEnumType &bitIndex, const BitMinion::BitCountMaskEnumType &bitMask, const T ®isterValue) const |
Get a group of bits from the provided register. | |
void | setBit (const bool &bitValue, const BitMinion::BitIndexEnumType &bitIndex, T ®isterValue) |
Sets a specific bit in the provided register. | |
void | setBits (const T &bitsValue, const BitMinion::BitIndexEnumType &bitIndex, const BitMinion::BitCountMaskEnumType &bitMask, T ®isterValue) |
Set a group of bits in the provided register. | |
bool | testBit (const bool &bitValue, const BitMinion::BitIndexEnumType &bitIndex, const T ®isterValue) const |
Checks a specific bit against a provided value in the provided register. | |
void | toggleBit (const BitMinion::BitIndexEnumType &bitIndex, T ®isterValue) |
Toggles a specific bit in the provided register. | |
virtual | ~BitWizard () |
The destructor for the BitWizard class. Doesn't do anything. |
A class for conducting with bitwise operations on registers.
BitWizard is templated, and works well with values of the same type. Its functionality using mismatched (implicitly cast) values is somewhat documented, but unsupported. Each method takes a register value as an argument and operates on that register value. It does not store any values locally, so only one BitWizard is necessary for each size register you intend to work with. BitWizard is known to only work with types that support bit shifting (e.g., not float or double or Foo()).
Definition at line 135 of file BitWizard.h.
The constructor for the BitWizard class. Doesn't do anything.
Definition at line 204 of file BitWizard.h.
The destructor for the BitWizard class. Doesn't do anything.
Definition at line 209 of file BitWizard.h.
bool BitWizard< T >::getBit | ( | const BitMinion::BitIndexEnumType & | bitIndex, |
const T & | registerValue | ||
) | const [inline] |
Gets a specific bit from the provided register.
bitIndex | The index of the requested bit (big-endian). |
registerValue | The register holding the bits to get. |
Definition at line 214 of file BitWizard.h.
T BitWizard< T >::getBits | ( | const BitMinion::BitIndexEnumType & | bitIndex, |
const BitMinion::BitCountMaskEnumType & | bitMask, | ||
const T & | registerValue | ||
) | const [inline] |
Get a group of bits from the provided register.
bitIndex | The index of the least significant requested bit (big-endian). |
bitMask | The mask that corresponds with the proper number of bits to get. |
registerValue | The register from which bits are gathered. |
Definition at line 238 of file BitWizard.h.
void BitWizard< T >::setBit | ( | const bool & | bitValue, |
const BitMinion::BitIndexEnumType & | bitIndex, | ||
T & | registerValue | ||
) | [inline] |
Sets a specific bit in the provided register.
bitValue | The value to set. |
bitIndex | The index of the bit to set (big-endian). |
registerValue | The register holding the bit to set. |
Definition at line 226 of file BitWizard.h.
void BitWizard< T >::setBits | ( | const T & | bitsValue, |
const BitMinion::BitIndexEnumType & | bitIndex, | ||
const BitMinion::BitCountMaskEnumType & | bitMask, | ||
T & | registerValue | ||
) | [inline] |
Set a group of bits in the provided register.
To set three bits, put the new bit values in the 3 least significant bit positions of bitsValue, use THREE_BIT_MASK for bitMask, and set bitIndex to the least significant bit index of the 3 bits you want to change in registerValue.
setBits(0x6, BIT_TWO_INDEX, THREE_BIT_MASK, 0x20) == 0x38, that is, 0x20 (100000b) --> 0x38 (111000b)
bitsValue | The new bit values to set. Only the least significant bitMask-sized bits will be used (big-endian). |
bitIndex | The index of the least significant bit to set (big-endian). |
bitMask | The mask that corresponds with the proper number of bits to set. |
registerValue | The register in which bits are modified. |
Definition at line 244 of file BitWizard.h.
bool BitWizard< T >::testBit | ( | const bool & | bitValue, |
const BitMinion::BitIndexEnumType & | bitIndex, | ||
const T & | registerValue | ||
) | const [inline] |
Checks a specific bit against a provided value in the provided register.
bitValue | The value to check the bit against. |
bitIndex | The index of the bit to check (big-endian). |
registerValue | The register holding the bit to check. |
Definition at line 220 of file BitWizard.h.
void BitWizard< T >::toggleBit | ( | const BitMinion::BitIndexEnumType & | bitIndex, |
T & | registerValue | ||
) | [inline] |
Toggles a specific bit in the provided register.
If the provided bit is true, the returned bit will be false, and vice-versa.
bitIndex | The index of the bit to toggle (big-endian). |
registerValue | The register holding the bit to toggle. |
Definition at line 232 of file BitWizard.h.