Go to the source code of this file.
|
class | ot::Flags< T > |
| This class is used to manage flags. Don't forget to add OT_ADD_FLAG_FUNCTIONS and the bottom of your header. The type should be an enumeration where every value represents a single bit in a 32/64 bit value. e.g: enum enumName { enumValue1 = 0x01, // 0001 enumValue2 = 0x02, // 0010 enumValue3 = 0x04, // 0100 ... };. More...
|
|
|
#define | OT_ADD_FLAG_FUNCTIONS_IMPL(___prefix, ___castType, ___enumName) |
| Adds bitwise operations for the provided enum. Use conveinience OT_ADD_FLAG_FUNCTIONS or OT_ADD_PRIVATE_FLAG_FUNCTIONS.
|
|
#define | OT_ADD_FLAG_FUNCTIONS(___enumName) OT_ADD_FLAG_FUNCTIONS_IMPL(, long, ___enumName) |
| Will add the default bitwise operations for the provided 32 bit bitfield. Use this at the bottom of the file where the enum and flags are defined.
|
|
#define | OT_ADD_PRIVATE_FLAG_FUNCTIONS(___enumName) OT_ADD_FLAG_FUNCTIONS_IMPL(friend , long, ___enumName) |
| Will add the default bitwise operations for the provided private 32 bit bitfield. Use this at the bottom of the class where the enum and flags are defined.
|
|
◆ OT_ADD_FLAG_FUNCTIONS
Will add the default bitwise operations for the provided 32 bit bitfield. Use this at the bottom of the file where the enum and flags are defined.
class MyClass {
public:
enum MyEnum {
...
}
typedef ot::Flags<MyEnum> MyFlags;
};
OT_ADD_FLAG_FUNCTIONS(MyClass::MyEnum)
◆ OT_ADD_FLAG_FUNCTIONS_IMPL
#define OT_ADD_FLAG_FUNCTIONS_IMPL |
( |
| ___prefix, |
|
|
| ___castType, |
|
|
| ___enumName ) |
Value:___prefix constexpr ___enumName operator | (___enumName _lhv, ___enumName _rhv) { return static_cast<___enumName>(static_cast<___castType>(_lhv) | static_cast<___castType>(_rhv)); }; \
___prefix constexpr ___enumName operator & (___enumName _lhv, ___enumName _rhv) { return static_cast<___enumName>(static_cast<___castType>(_lhv) & static_cast<___castType>(_rhv)); }; \
___prefix constexpr ___enumName operator ~ (___enumName _lhv) { return static_cast<___enumName>(~(static_cast<___castType>(_lhv))); };
Adds bitwise operations for the provided enum. Use conveinience OT_ADD_FLAG_FUNCTIONS or OT_ADD_PRIVATE_FLAG_FUNCTIONS.
◆ OT_ADD_PRIVATE_FLAG_FUNCTIONS
Will add the default bitwise operations for the provided private 32 bit bitfield. Use this at the bottom of the class where the enum and flags are defined.
class MyClass {
private:
enum MyEnum {
...
}
typedef ot::Flags<MyEnum> MyFlags;
OT_ADD_PRIVATE_FLAG_FUNCTIONS(MyClass::MyEnum)
};