ImFusion SDK 4.3
Flags< Enum > Class Template Reference

#include <ImFusion/Core/Flags.h>

Utility class to store a type-safe combination of enum-based bit fields. More...

Detailed Description

template<typename Enum>
class ImFusion::Flags< Enum >

Utility class to store a type-safe combination of enum-based bit fields.

Template Parameters
EnumEnumeration to use for accessing individual bits. You must ensure yourself that the underlying enum values are chosen to form a proper bit field. Flags can not perform any checks on this.
// Definition of enum bitfield and function that takes Flags
enum CompareOptions {
CompareNothing = 0,
CompareFirst = 1 << 0,
CompareSecond = 1 << 1,
CompareThird = 1 << 2,
};
void setCompareFlags(Flags<CompareOptions> compareOptions);
[...]
// Use initializer list to create a CompareOptions bit field that has the first and second bit set
setCompareFlags({CompareFirst, CompareSecond});
Utility class to store a type-safe combination of enum-based bit fields.
Definition Flags.h:34

Public Types

using BaseType = typename std::underlying_type<Enum>::type
 

Public Member Functions

 Flags ()=default
 Default constructor creates an empty bitfield.
 
 Flags (Enum f)
 Constructs a Flags instance with a single bit set.
 
 Flags (BaseType val)
 Construct a Flags instance from an integer value, no range checks are performed.
 
 Flags (std::initializer_list< Enum > initializerList)
 Constructs a Flags instance from an initializer list of enum values, all given bits will be set.
 
bool testFlag (Enum flag) const
 Returns whether all bits of the given flag are set.
 
void setFlag (Enum flag, bool value=true)
 Sets all bits of the given flag to value.
 
void toggleFlag (Enum flag)
 Toggles all bits of the given flag.
 
BaseType value () const
 Returns the underlying value as integral type.
 
Flagsoperator&= (Flags f)
 
Flagsoperator&= (Enum mask)
 
Flagsoperator|= (Flags f)
 
Flagsoperator|= (Enum f)
 
Flagsoperator^= (Flags f)
 
Flagsoperator^= (Enum f)
 
 operator Enum () const
 
Flags operator| (Flags f) const
 
Flags operator| (Enum f) const
 
Flags operator^ (Flags f) const
 
Flags operator^ (Enum f) const
 
Flags operator& (Flags f) const
 
Flags operator& (Enum f) const
 
Flags operator~ () const
 
bool operator! () const
 
bool operator== (Enum f) const
 
bool operator== (const Flags< Enum > &f) const
 
bool operator!= (Enum f) const
 

Member Function Documentation

◆ testFlag()

template<typename Enum>
bool testFlag ( Enum flag) const
inline

Returns whether all bits of the given flag are set.

If flag is 0, returns whether no bit is set.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close