Apparatus Version 1.22
ECS data-oriented workflow for Unreal Engine.
Macros | Functions
EnumClassFlags.h File Reference

Additional utilities for Unreal Engine's enum routines macros. More...

#include "EnumClassFlags.h"
Include dependency graph for EnumClassFlags.h:
This graph shows which files directly or indirectly include this file:

Macros

#define MORE_ENUM_CLASS_FLAGS(Enum, Bit)
 Operators with individual bit functionality. More...
 

Functions

template<typename EnumT , typename BitT >
EnumT & EnumSetFlag (EnumT &Flags, const BitT Bit, const bool bState=true)
 Set or clear an enum flag. More...
 
template<typename EnumT , typename BitT >
constexpr EnumT EnumWithFlagSet (const EnumT &Flags, const BitT Bit, const bool bState=true)
 Enum with a set/cleared bit. More...
 
template<typename EnumT , typename BitT >
constexpr EnumT EnumWithFlagToggled (const EnumT &Flags, const BitT Bit)
 Enum with a toggled bit. More...
 
template<typename EnumT , typename BitT >
constexpr bool EnumHasFlag (const EnumT Flags, const BitT Bit)
 Examine if the enum has a certain flag set. More...
 

Detailed Description

Additional utilities for Unreal Engine's enum routines macros.

Macro Definition Documentation

◆ MORE_ENUM_CLASS_FLAGS

#define MORE_ENUM_CLASS_FLAGS (   Enum,
  Bit 
)
Value:
using Enum##Type = __underlying_type(Enum); \
inline Enum FlagToEnum(const Bit Flag) { return (Enum)((__underlying_type(Enum))1 << (int)Flag); } \
inline Enum& operator-=(Enum& Lhs, const Enum Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs & ~((__underlying_type(Enum))Rhs) ); } \
inline constexpr Enum operator- (Enum Lhs, const Enum Rhs) { return (Enum)( (__underlying_type(Enum))Lhs & ~((__underlying_type(Enum))Rhs) ); } \
inline Enum& operator|=(Enum& Lhs, const Bit Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs | ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline Enum& operator&=(Enum& Lhs, const Bit Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs & ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline Enum& operator^=(Enum& Lhs, const Bit Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs ^ ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator| (Enum Lhs, const Bit Rhs) { return (Enum)( (__underlying_type(Enum))Lhs | ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator& (Enum Lhs, const Bit Rhs) { return (Enum)( (__underlying_type(Enum))Lhs & ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator^ (Enum Lhs, const Bit Rhs) { return (Enum)( (__underlying_type(Enum))Lhs ^ ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline Enum& operator+=(Enum& Lhs, const Bit Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs | (__underlying_type(Enum))1 << (int)Rhs ); } \
inline Enum& operator-=(Enum& Lhs, const Bit Rhs) { return Lhs = (Enum)( (__underlying_type(Enum))Lhs & ~((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator- (Enum Lhs, const Bit Rhs) { return (Enum)( (__underlying_type(Enum))Lhs & ~((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator+ (Enum Lhs, const Bit Rhs) { return (Enum)( (__underlying_type(Enum))Lhs | ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator| (const Bit Lhs, const Bit Rhs) { return (Enum)( ((__underlying_type(Enum))1 << (int)Lhs) | ((__underlying_type(Enum))1 << (int)Rhs) ); } \
inline constexpr Enum operator& (const Bit Lhs, const Bit Rhs) { return (Enum)( ((__underlying_type(Enum))1 << (int)Lhs) & ((__underlying_type(Enum))1 << (int)Rhs) ); }
FBitMask operator&(const FBitMask &MaskA, const FBitMask &MaskB)
Logically-conjunct the bits in masks.
Definition: BitMask.h:1155
FBitMask operator|(const FBitMask &MaskA, const FBitMask &MaskB)
Logically-disjunct the bits in masks.
Definition: BitMask.h:1175
EFlagmark & operator&=(EFlagmark &Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
constexpr EFlagmark operator-(EFlagmark Lhs, const EFlagmark Rhs)
Definition: Flagmark.h:464
EFlagmark & operator-=(EFlagmark &Lhs, const EFlagmark Rhs)
Definition: Flagmark.h:464
constexpr EFlagmark operator^(EFlagmark Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
constexpr EFlagmark operator+(EFlagmark Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
EFlagmark & operator|=(EFlagmark &Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
EFlagmark & operator+=(EFlagmark &Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
EFlagmark & operator^=(EFlagmark &Lhs, const EFlagmarkBit Rhs)
Definition: Flagmark.h:464
EFlagmark FlagToEnum(const EFlagmarkBit Flag)
Definition: Flagmark.h:464

Operators with individual bit functionality.

Parameters
EnumThe type of enum bit flags.
BitThe type of the individual bits enum.

Function Documentation

◆ EnumHasFlag()

template<typename EnumT , typename BitT >
constexpr bool EnumHasFlag ( const EnumT  Flags,
const BitT  Bit 
)
constexpr

Examine if the enum has a certain flag set.

Template Parameters
EnumTThe type of enum to set.
BitTThe bit type to set.
Parameters
FlagsThe flags to alter.
BitThe bit to change.
Returns
true The bit is set within the flags.
false The bit is cleared within the flags.

◆ EnumSetFlag()

template<typename EnumT , typename BitT >
EnumT & EnumSetFlag ( EnumT &  Flags,
const BitT  Bit,
const bool  bState = true 
)

Set or clear an enum flag.

Template Parameters
EnumTThe type of enum to set.
BitTThe bit type to set.
Parameters
FlagsThe flags to alter.
BitThe bit to change.
bStateThe state to set.

◆ EnumWithFlagSet()

template<typename EnumT , typename BitT >
constexpr EnumT EnumWithFlagSet ( const EnumT &  Flags,
const BitT  Bit,
const bool  bState = true 
)
constexpr

Enum with a set/cleared bit.

The original enum is not changed.

Template Parameters
EnumTThe type of enum to set.
BitTThe bit type to set.
Parameters
FlagsThe flags to alter.
BitThe bit to change.
bStateThe state to set.

◆ EnumWithFlagToggled()

template<typename EnumT , typename BitT >
constexpr EnumT EnumWithFlagToggled ( const EnumT &  Flags,
const BitT  Bit 
)
constexpr

Enum with a toggled bit.

The original enum is not changed.

Template Parameters
EnumTThe type of enum to toggle within.
BitTThe bit type to toggle.
Parameters
FlagsThe flags to alter.
BitThe bit to toggle.