Louvre
v1.2.1-2
C++ library for Wayland compositors
|
#include <LBitset.h>
Compact way of storing and managing conditions or states. More...
Compact way of storing and managing conditions or states.
The LBitset class template is similar to std::bitset
in that it enables the compact storage of a set of conditions or states using bits.
Unlike std::bitset
, LBitset functions are designed to modify and retrieve bit states using flags rather than indices, which are ideally defined within an enum.
It is widely used in the private API of Louvre classes to optimize memory usage.
Example usage:
Public Member Functions | |
LBitset (Flag flags=0) | |
Constructor for LBitset. More... | |
void | add (Flag flags) |
Add new flags to the bitfield. More... | |
void | remove (Flag flags) |
Remove flags from the bitfield. More... | |
bool | check (Flag flags) const |
Check if at least one flag exists. More... | |
bool | checkAll (Flag flags) const |
Check if all specified flags exist. More... | |
Flag | get () const |
Get the current set of flags. More... | |
void | set (Flag flags) |
Set new flags in the bitfield. More... | |
void | setFlag (Flag flag, bool enable) |
Set or unset a specific flag in the bitfield. More... | |
|
inline |
Constructor for LBitset.
Initializes the bitset with the specified initial flags. If no flags are provided, the bitset is constructed empty without any flags.
flags | Initial flags to set (default is 0) |
|
inline |
Add new flags to the bitfield.
Sets the specified flags by combining them with the existing flags using the bitwise OR operator '|'.
flags | The flag or combination of flags to be added |
|
inline |
Remove flags from the bitfield.
Clears the specified flags by performing a bitwise AND operation with the complement of the provided flags.
flags | The flag or combination of flags to be removed |
|
inline |
Check if at least one flag exists.
Checks if at least one of the specified flags is set in the bitfield.
flags | The flag or combination of flags to be checked |
true
if at least one flag is set, otherwise false
|
inline |
Check if all specified flags exist.
Checks if all of the specified flags are set in the bitfield.
flags | The flag or combination of flags to be checked |
true
if all specified flags are set, otherwise false
|
inline |
Get the current set of flags.
Retrieves the current set of flags stored in the bitfield.
|
inline |
Set new flags in the bitfield.
Replaces the current set of flags in the bitfield with the specified flags.
flags | The new flag or combination of flags to be set |
|
inline |
Set or unset a specific flag in the bitfield.
Modifies the specified flag in the bitfield. If enable
is true
, the flag is set, otherwise, it is removed.
flag | The flag to be set or unset |
enable | If true , set the flag, if false , remove the flag |