class
#include <core/reflection/traits/mask.hpp>
MaskTrait Provides mask functionality to an enum mask type.
Public types
-
using Tester = memory::
Function<bool(const void*) const > - Function pointer to test if a bit is set on the mask.
-
using Setter = memory::
Function<void(void*) const > - Function pointer to set the bit on the mask.
-
using Clearer = memory::
Function<void(void*) const > - Function pointer to clear the bit on the mask.
Public static functions
Constructors, destructors, conversion operators
- MaskTrait() defaulted
- Constructs.
- MaskTrait(MaskTrait&& other) noexcept
- Move constructs.
- Bit(std::string name, Tester tester, Setter setter, Clearer clearer)
- Constructs.
- Iterator(const Bit* bit)
- Constructs.
- Iterator(const Iterator& iterator) defaulted
- Copy constructs.
- SetIterator(const Bit* bit, const void* instance)
- Constructs.
- SetIterator(const SetIterator& other) defaulted
- Copy constructs.
- View(const MaskTrait& trait, void* instance)
- Constructs.
- ConstView(const MaskTrait& trait, const void* instance)
- Constructs.
Public functions
- void addBit(std::string name, Tester tester, Setter setter, Clearer clearer)
- Adds a bit to the type.
- auto withBit(std::string name, Tester tester, Setter setter, Clearer clearer) && -> MaskTrait&&
- Adds a bit to the type.
-
template<auto B>auto withBit(std::string name) && -> MaskTrait&&
- Adds a bit to the type.
- auto contains(const std::string& name) const -> bool
- Checks if a bit with the given name exists.
- auto at(const std::string& name) const -> const Bit&
- Gets the bit with the specified name.
- auto begin() const -> Iterator
- Gets an iterator to the first bit of the type.
- auto size() const -> std::size_t
- Returns how many bits there are in the trait.
- auto view(void* instance) const -> View
- Returns a view of the given mask instance.
- auto view(const void* instance) const -> ConstView
- Returns a view of the given mask instance.
- auto test(const void* value) const -> bool
- Tests if the given value has the bit set.
- void set(void* value) const
- Sets the bit on the given value.
- void clear(void* value) const
- Clears the bit on the given value.
- auto name() const -> const std::string&
- Gets the name of the bit.
- auto next() const -> const Bit*
- Returns the next bit in the linked list.
- auto operator=(const Iterator&) -> Iterator& defaulted
- Copy assigns.
- auto operator==(const Iterator&) const -> bool defaulted
- Compares with another iterator.
- auto operator*() const -> const Bit&
- Accesses the bit referenced by this iterator.
- auto operator->() const -> const Bit*
- Accesses the bit referenced by this iterator.
- auto operator++() -> Iterator&
- Advances the iterator.
- auto operator==(const SetIterator& other) const -> bool defaulted
- Compares two iterators.
- auto operator*() const -> const Bit&
- Accesses the bit referenced by this iterator.
- auto operator->() const -> const Bit*
- Accesses the bit referenced by this iterator.
- auto operator++() -> SetIterator&
- Advances the iterator.
- auto test(const Bit& bit) const -> bool
- Checks if the given bit is set on the mask.
- auto test(const std::string& name) const -> bool
- Checks if the given bit is set on the mask.
- void set(const Bit& bit) const
- Sets the given bit on the mask.
- void set(const std::string& name) const
- Sets the given bit on the mask.
- void clear(const Bit& bit) const
- Clears the given bit on the mask.
- void clear(const std::string& name) const
- Clears the given bit on the mask.
- auto begin() const -> SetIterator
- Gets an iterator to the first set bit.
- auto end() const -> SetIterator
- Gets an iterator representing the end of the set bits.
- auto test(const Bit& bit) const -> bool
- Checks if the given bit is set on the mask.
- auto test(const std::string& name) const -> bool
- Checks if the given bit is set on the mask.
- auto begin() const -> SetIterator
- Gets an iterator to the first set bit.
- auto end() const -> SetIterator
- Gets an iterator representing the end of the set bits.
Function documentation
cubos:: core:: reflection:: MaskTrait:: Iterator(const Iterator& iterator) defaulted
Copy constructs.
Parameters | |
---|---|
iterator | Iterator. |
cubos:: core:: reflection:: MaskTrait:: SetIterator(const Bit* bit,
const void* instance)
Constructs.
Parameters | |
---|---|
bit | Bit to start from. |
instance | Mask instance. |
cubos:: core:: reflection:: MaskTrait:: SetIterator(const SetIterator& other) defaulted
Copy constructs.
Parameters | |
---|---|
other | Other iterator. |
void cubos:: core:: reflection:: MaskTrait:: addBit(std::string name,
Tester tester,
Setter setter,
Clearer clearer)
Adds a bit to the type.
Parameters | |
---|---|
name | Bit name. |
tester | Function to test if a bit is set on the mask. |
setter | Function to set a bit on the mask. |
clearer | Function to clear a bit on the mask. |
MaskTrait&& cubos:: core:: reflection:: MaskTrait:: withBit(std::string name,
Tester tester,
Setter setter,
Clearer clearer) &&
Adds a bit to the type.
Parameters | |
---|---|
name | Bit name. |
tester | Function to test if a bit is set on the mask. |
setter | Function to set a bit on the mask. |
clearer | Function to clear a bit on the mask. |
Returns | Trait. |
bool cubos:: core:: reflection:: MaskTrait:: contains(const std::string& name) const
Checks if a bit with the given name exists.
Parameters | |
---|---|
name | Bit name. |
Returns | Whether the bit exists. |
std::size_t cubos:: core:: reflection:: MaskTrait:: size() const
Returns how many bits there are in the trait.
Returns | Bit count. |
---|
bool cubos:: core:: reflection:: MaskTrait:: test(const void* value) const
Tests if the given value has the bit set.
Parameters | |
---|---|
value | Pointer to value. |
Returns | Whether the value has the bit set. |
void cubos:: core:: reflection:: MaskTrait:: set(void* value) const
Sets the bit on the given value.
Parameters | |
---|---|
value | Pointer to value. |
void cubos:: core:: reflection:: MaskTrait:: clear(void* value) const
Clears the bit on the given value.
Parameters | |
---|---|
value | Pointer to value. |
const std::string& cubos:: core:: reflection:: MaskTrait:: name() const
Gets the name of the bit.
Returns | Bit name. |
---|
bool cubos:: core:: reflection:: MaskTrait:: operator==(const Iterator&) const defaulted
Compares with another iterator.
Returns | Whether both point to the same variant. |
---|
const Bit* cubos:: core:: reflection:: MaskTrait:: operator->() const
Accesses the bit referenced by this iterator.
Returns | Pointer to the bit. |
---|
Iterator& cubos:: core:: reflection:: MaskTrait:: operator++()
Advances the iterator.
Returns | Reference to this. |
---|
bool cubos:: core:: reflection:: MaskTrait:: operator==(const SetIterator& other) const defaulted
Compares two iterators.
Parameters | |
---|---|
other | Other iterator. |
Returns | Whether the iterators point to the same bit. |
const Bit* cubos:: core:: reflection:: MaskTrait:: operator->() const
Accesses the bit referenced by this iterator.
Returns | Bit. |
---|
SetIterator& cubos:: core:: reflection:: MaskTrait:: operator++()
Advances the iterator.
Returns | Reference to this. |
---|
bool cubos:: core:: reflection:: MaskTrait:: test(const std::string& name) const
Checks if the given bit is set on the mask.
Parameters | |
---|---|
name | Bit name. |
Returns | Whether the bit is set. |
Aborts if the bit does not exist.
void cubos:: core:: reflection:: MaskTrait:: set(const std::string& name) const
Sets the given bit on the mask.
Parameters | |
---|---|
name | Bit name. |
Aborts if the bit does not exist.
void cubos:: core:: reflection:: MaskTrait:: clear(const std::string& name) const
Clears the given bit on the mask.
Parameters | |
---|---|
name | Bit name. |
Aborts if the bit does not exist.
SetIterator cubos:: core:: reflection:: MaskTrait:: begin() const
Gets an iterator to the first set bit.
Returns | Iterator. |
---|
SetIterator cubos:: core:: reflection:: MaskTrait:: end() const
Gets an iterator representing the end of the set bits.
Returns | Iterator. |
---|
bool cubos:: core:: reflection:: MaskTrait:: test(const std::string& name) const
Checks if the given bit is set on the mask.
Parameters | |
---|---|
name | Bit name. |
Returns | Whether the bit is set. |
Aborts if the bit does not exist.
SetIterator cubos:: core:: reflection:: MaskTrait:: begin() const
Gets an iterator to the first set bit.
Returns | Iterator. |
---|
SetIterator cubos:: core:: reflection:: MaskTrait:: end() const
Gets an iterator representing the end of the set bits.
Returns | Iterator. |
---|