Base module
Bitwise
Container for smart management of bitwise integer flags.
Bitwise
#include <icy/bitwise.h>Container for smart management of bitwise integer flags.
Public Attributes
| Return | Name | Description |
|---|---|---|
unsigned | data | Backing storage for the flag bits. |
data
unsigned dataBacking storage for the flag bits.
Public Methods
| Return | Name | Description |
|---|---|---|
Bitwise inline | Constructs a Bitwise with optional initial flags. | |
void | reset virtual inline | Clears all flags (sets data to 0). |
void | set virtual inline | Sets the given flag only if it is not already set. |
void | add virtual inline | Unconditionally sets (OR) the given flag bits. |
void | remove virtual inline | Clears the given flag bits. |
void | toggle virtual inline | Toggles (XOR) the given flag bits. |
bool | has virtual const inline | Returns true if all bits in flag are set. |
Bitwise
inline
inline Bitwise(unsigned flags)Constructs a Bitwise with optional initial flags.
Parameters
flagsInitial flag value (default: 0).
reset
virtual inline
virtual inline void reset()Clears all flags (sets data to 0).
set
virtual inline
virtual inline void set(unsigned flag)Sets the given flag only if it is not already set.
Parameters
flagThe flag bit(s) to set.
add
virtual inline
virtual inline void add(unsigned flag)Unconditionally sets (OR) the given flag bits.
Parameters
flagThe flag bit(s) to add.
remove
virtual inline
virtual inline void remove(unsigned flag)Clears the given flag bits.
Parameters
flagThe flag bit(s) to remove.
toggle
virtual inline
virtual inline void toggle(unsigned flag)Toggles (XOR) the given flag bits.
Parameters
flagThe flag bit(s) to toggle.
has
virtual const inline
virtual inline bool has(unsigned flag) constReturns true if all bits in flag are set.
Parameters
flagThe flag bit(s) to test.
Returns
true if every bit in flag is present in data.
