A wrapper template for primitive integer types that represent flag bitmasks.
More...
#include <Flags.h++>
|
| Flags (const T &flags=0) |
| Construct a new Flags object with an initial value of 0. More...
|
|
| ~Flags () |
| Destructor. More...
|
|
bool | isSet (int index) const |
| Test if the bit at the given index is set. More...
|
|
void | set (int index, bool on=true) |
| Set or clear the bit at the given index. More...
|
|
bool | anySet (const T &mask) const |
| Compare the flags to a mask, returning true if any of the bits in the mask are set in the flags. More...
|
|
bool | allSet (const T &mask) const |
| Compare the flags to a mask, returning true if all of the bits in the mask are set in the flags. More...
|
|
bool | operator[] (int index) const |
| Index operator. More...
|
|
BitRef | operator[] (int index) |
| Index operator. More...
|
|
void | clear (int flag) |
| Clear the bit at the given index. More...
|
|
void | clear () |
| Clear all of the bits. More...
|
|
| operator T () const |
| Cast operator. More...
|
|
Flags & | operator= (const T &flags) |
| Assignment operator. More...
|
|
template<typename T>
class ccxx::Flags< T >
A wrapper template for primitive integer types that represent flag bitmasks.
- Author
- Mark Lindner
◆ Flags()
Flags |
( |
const T & |
flags = 0 | ) |
|
Construct a new Flags object with an initial value of 0.
◆ ~Flags()
◆ allSet()
bool allSet |
( |
const T & |
mask | ) |
const |
Compare the flags to a mask, returning true if all of the bits in the mask are set in the flags.
- Parameters
-
- Returns
- true if the bitwise-AND of the flags and the mask is equal to the mask.
◆ anySet()
bool anySet |
( |
const T & |
mask | ) |
const |
Compare the flags to a mask, returning true if any of the bits in the mask are set in the flags.
- Parameters
-
- Returns
- true if the bitwise-AND of the flags and the mask is nonzero.
◆ clear() [1/2]
Clear the bit at the given index.
- Parameters
-
◆ clear() [2/2]
◆ isSet()
bool isSet |
( |
int |
index | ) |
const |
Test if the bit at the given index is set.
- Parameters
-
- Returns
- true if the bit is set, false otherwise.
◆ operator T()
◆ operator=()
Flags& operator= |
( |
const T & |
flags | ) |
|
◆ operator[]() [1/2]
bool operator[] |
( |
int |
index | ) |
const |
Index operator.
Equivalent to isSet().
◆ operator[]() [2/2]
BitRef operator[] |
( |
int |
index | ) |
|
Index operator.
Returns a reference to the given bit.
- Exceptions
-
◆ set()
void set |
( |
int |
index, |
|
|
bool |
on = true |
|
) |
| |
Set or clear the bit at the given index.
- Parameters
-
index | The bit index. |
on | A flag indicating whether the bit should be set or cleared. |
The documentation for this class was generated from the following file: