Louvre
v2.12.0-1
C++ library for Wayland compositors
|
Compact way of storing and managing conditions or states. More...
Public Member Functions | |
constexpr | LBitset (Flag flags=0) noexcept |
Constructor for LBitset. More... | |
constexpr void | add (Flag flags) noexcept |
Add new flags to the bitfield. More... | |
constexpr void | remove (Flag flags) noexcept |
Remove flags from the bitfield. More... | |
constexpr bool | check (Flag flags) const noexcept |
Check if at least one flag exists. More... | |
constexpr bool | checkAll (Flag flags) const noexcept |
Check if all specified flags exist. More... | |
constexpr Flag | get () const noexcept |
Gets the current set of flags. More... | |
constexpr void | set (Flag flags) noexcept |
Set new flags in the bitfield. More... | |
constexpr void | setFlag (Flag flag, bool enable) noexcept |
Set or unset a specific flag in the bitfield. More... | |
constexpr LBitset< T > & | operator|= (T flags) noexcept |
Performs a bitwise OR operation with another LBitset. More... | |
constexpr LBitset< T > & | operator&= (T flags) noexcept |
Performs a bitwise AND operation with another LBitset. More... | |
constexpr LBitset< T > & | operator^= (T flags) noexcept |
Performs a bitwise XOR operation with another LBitset. 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:
|
inlineconstexprnoexcept |
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) |
|
inlineconstexprnoexcept |
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 |
|
inlineconstexprnoexcept |
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 |
|
inlineconstexprnoexcept |
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
|
inlineconstexprnoexcept |
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
|
inlineconstexprnoexcept |
Gets the current set of flags.
Retrieves the current set of flags stored in the bitfield.
|
inlineconstexprnoexcept |
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 |
|
inlineconstexprnoexcept |
Set or unset a specific flag in the bitfield.
Modifies the specified flag (or flags) 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 |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |