Base module

Bitwise

Container for smart management of bitwise integer flags.

#include <icy/bitwise.h>

struct Bitwise

Defined in src/base/include/icy/bitwise.h:22

Public Attributes

ReturnNameDescription
unsigneddataBacking storage for the flag bits.

data

unsigned data

Defined in src/base/include/icy/bitwise.h:24

Backing storage for the flag bits.

Public Methods

ReturnNameDescription
Bitwise inlineConstructs a Bitwise with optional initial flags.
voidreset virtual inlineClears all flags (sets data to 0).
voidset virtual inlineSets the given flag only if it is not already set.
voidadd virtual inlineUnconditionally sets (OR) the given flag bits.
voidremove virtual inlineClears the given flag bits.
voidtoggle virtual inlineToggles (XOR) the given flag bits.
boolhas virtual const inlineReturns true if all bits in flag are set.

Bitwise

inline

inline Bitwise(unsigned flags = 0)

Defined in src/base/include/icy/bitwise.h:28

Constructs a Bitwise with optional initial flags.

Parameters

ParameterTypeDescription
flagsunsignedInitial flag value (default: 0).

reset

virtual inline

virtual inline void reset()

Defined in src/base/include/icy/bitwise.h:34

Clears all flags (sets data to 0).


set

virtual inline

virtual inline void set(unsigned flag)

Defined in src/base/include/icy/bitwise.h:38

Sets the given flag only if it is not already set.

Parameters

ParameterTypeDescription
flagunsignedThe flag bit(s) to set.

add

virtual inline

virtual inline void add(unsigned flag)

Defined in src/base/include/icy/bitwise.h:46

Unconditionally sets (OR) the given flag bits.

Parameters

ParameterTypeDescription
flagunsignedThe flag bit(s) to add.

remove

virtual inline

virtual inline void remove(unsigned flag)

Defined in src/base/include/icy/bitwise.h:50

Clears the given flag bits.

Parameters

ParameterTypeDescription
flagunsignedThe flag bit(s) to remove.

toggle

virtual inline

virtual inline void toggle(unsigned flag)

Defined in src/base/include/icy/bitwise.h:54

Toggles (XOR) the given flag bits.

Parameters

ParameterTypeDescription
flagunsignedThe flag bit(s) to toggle.

has

virtual const inline

virtual inline bool has(unsigned flag) const

Defined in src/base/include/icy/bitwise.h:59

Returns true if all bits in flag are set.

Returns

true if every bit in flag is present in data.

Parameters

ParameterTypeDescription
flagunsignedThe flag bit(s) to test.