![]() |
CopperSpice API
2.0.0
|
Provides a type safe mechanism for representing bitwise-or combinations of enum values. More...
Public Typedefs | |
using | enum_type = E |
Public Methods | |
constexpr | QFlags () |
constexpr | QFlags (const QFlags &other) |
constexpr | QFlags (E value) |
constexpr | QFlags (EmptyFlag_Type) |
constexpr | QFlags (std::initializer_list< E > list) |
constexpr | QFlags (std::nullptr_t) |
constexpr | operator int_type () const |
constexpr bool | operator! () const |
constexpr QFlags | operator& (E value) const |
constexpr QFlags | operator& (sint_type mask) const |
constexpr QFlags | operator& (uint_type mask) const |
QFlags & | operator&= (sint_type mask) |
QFlags & | operator&= (uint_type mask) |
QFlags & | operator= (const QFlags &other) |
constexpr QFlags | operator^ (E value) const |
constexpr QFlags | operator^ (QFlags other) const |
QFlags & | operator^= (E value) |
QFlags & | operator^= (QFlags other) |
constexpr QFlags | operator| (E value) const |
constexpr QFlags | operator| (QFlags other) const |
QFlags & | operator|= (E value) |
QFlags & | operator|= (QFlags other) |
constexpr QFlags | operator~ () const |
bool | testFlag (E value) const |
The QFlags class provides a type safe mechanism for representing bitwise-or combinations of enum values. The QFlags<E> class is a template class where E is an enum type.
The traditional C++ approach for storing bitwise-or combinations of enum values is to use an int
or uint
variable. The draw back with this approach is the inability to type check the bitwise-or combination of enum values.
QFlags only allows enum values to be combined with other values from the same enum. For example, QDir::Filters is a typedef for QFlags<QDir::Filter>. This allows code to safely bitwise OR any of the enum values in QDir::Filter.
When values do not belong to the same enum a bitwise OR or bitwise AND will result in a compiler warning.
They can be safely combined by using the cs_enum_cast() prior to the bitwise operation. This function will convert an enum value to an quint64 value.
To use QFlags with your own enum types add the using as shown below and call the Q_DECLARE_OPERATORS_FOR_FLAGS() macro. This allows using MyClass::Options
to store combinations of MyClass::Option
values.
QFlags< E >::enum_type |
Equivalent to the E template type.
|
inlineconstexpr |
Constructs a QFlags object with no flags set.
|
inlineconstexpr |
Constructs a QFlags object with no flags set.
|
inlineconstexpr |
Constructs a QFlags object with no flags set.
|
inlineconstexpr |
Constructs a QFlags object using the values in list.
|
inlineconstexpr |
Constructs a QFlags object storing the given value.
|
inlineconstexpr |
Copy constructs a new QFlags from other.
|
inlineconstexpr |
Returns the value stored in the QFlags object as an integer.
|
inlineconstexpr |
Returns true if no flag is set, otherwise returns false.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise AND operation on this object and value.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise AND operation on this object and mask.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise AND operation on this object and mask.
|
inline |
Performs a bitwise AND operation with mask and stores the result in this QFlags object. Returns a reference to this object.
|
inline |
Performs a bitwise AND operation with mask and stores the result in this QFlags object. Returns a reference to this object.
|
inline |
Copy assigns from other and returns a reference to this object.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise XOR operation on this object and value.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise XOR operation on this object and other.
|
inline |
Performs a bitwise XOR operation with value and stores the result in this QFlags object. Returns a reference to this object.
|
inline |
Performs a bitwise XOR operation with other and stores the result in this QFlags object. Returns a reference to this object.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise OR operation on this object and value.
|
inlineconstexpr |
Returns a QFlags object containing the result of the bitwise OR operation on this object and other.
|
inline |
Performs a bitwise OR operation with value and stores the result in this QFlags object. Returns a reference to this object.
|
inline |
Performs a bitwise OR operation with other and stores the result in this QFlags object. Returns a reference to this object.
|
inlineconstexpr |
Returns a QFlags object that contains the bitwise negation of this object.
|
inline |
Returns true if the value is set, otherwise false.