Apparatus Version 1.23
ECS data-oriented workflow for Unreal Engine.
Loading...
Searching...
No Matches
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.
 

Functions

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

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) ); }
EApparatusStatus & operator+=(EApparatusStatus &A, const EApparatusStatus B)
Accumulate a status to an existing status.
Definition: ApparatusStatus.h:410
constexpr EApparatusStatus operator+(const EApparatusStatus A, const EApparatusStatus B)
Combine two statuses deriving a new one based on them.
Definition: ApparatusStatus.h:281
FBitMask operator&(const FBitMask &MaskA, const FBitMask &MaskB)
Logically-conjunct the bits in masks.
Definition: BitMask.h:1150
FBitMask operator|(const FBitMask &MaskA, const FBitMask &MaskB)
Logically-disjunct the bits in masks.
Definition: BitMask.h:1170
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
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 
)
inlineconstexpr

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 flagmark bit to examine.
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 
)
inline

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 
)
inlineconstexpr

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 
)
inlineconstexpr

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.