Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
EnumRange.h File Reference
#include "CoreTypes.h"
+ Include dependency graph for EnumRange.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NEnumRangePrivate::TEnumRangeTraits< EnumType >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, RangeType >
 
struct  NEnumRangePrivate::TEnumContiguousIterator< EnumType >
 
struct  NEnumRangePrivate::TEnumValueArrayIterator< EnumType >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, 0 >
 
struct  NEnumRangePrivate::TEnumRange_Impl< EnumType, 1 >
 
struct  UE::EnumFlags::Private::TIterator< EnumType >
 
struct  UE::EnumFlags::Private::TRange< EnumType >
 
struct  TEnumRange< EnumType >
 

Namespaces

namespace  NEnumRangePrivate
 
namespace  UE
 
namespace  UE::EnumFlags
 
namespace  UE::EnumFlags::Private
 

Macros

#define ENUM_RANGE_BY_COUNT(EnumType, Count)   ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, 0, (__underlying_type(EnumType))(Count) - 1)
 
#define ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, First, Last)
 
#define ENUM_RANGE_BY_VALUES(EnumType, ...)
 

Functions

template<typename EnumType >
UE::EnumFlags::Private::TRange< EnumType > MakeFlagsRange (EnumType Flags)
 

Macro Definition Documentation

◆ ENUM_RANGE_BY_COUNT

#define ENUM_RANGE_BY_COUNT ( EnumType,
Count )   ENUM_RANGE_BY_FIRST_AND_LAST(EnumType, 0, (__underlying_type(EnumType))(Count) - 1)

Defines a contiguous enum range containing Count values, starting from zero:

Example:

enum class ECountedThing { First, Second, Third,

Count };

// Defines iteration over ECountedThing to be: First, Second, Third ENUM_RANGE_BY_COUNT(ECountedThing, ECountedThing::Count)

Definition at line 24 of file EnumRange.h.

◆ ENUM_RANGE_BY_FIRST_AND_LAST

#define ENUM_RANGE_BY_FIRST_AND_LAST ( EnumType,
First,
Last )
Value:
template <> \
{ \
enum { RangeType = 0 }; \
static constexpr __underlying_type(EnumType) Begin = (__underlying_type(EnumType))(First); \
static constexpr __underlying_type(EnumType) End = (__underlying_type(EnumType))(Last) + 1; \
};

Defines a contiguous enum range with specific start and end values:

Example:

enum class EDoubleEndedThing { Invalid,

First, Second, Third,

Count };

// Defines iteration over EDoubleEndedThing to be: First, Second, Third ENUM_RANGE_BY_FIRST_AND_LAST(EDoubleEndedThing, EDoubleEndedThing::First, EDoubleEndedThing::Third)

Definition at line 46 of file EnumRange.h.

◆ ENUM_RANGE_BY_VALUES

#define ENUM_RANGE_BY_VALUES ( EnumType,
... )
Value:
template <> \
{ \
enum { RangeType = 1 }; \
template <typename Dummy> \
static const EnumType* GetPointer(bool bLast) \
{ \
static constexpr EnumType Values[] = { __VA_ARGS__ }; \
return bLast ? Values + sizeof(Values) / sizeof(EnumType) : Values; \
} \
};

Defines a non-contiguous enum range with specific individual values:

Example:

enum class ERandomValuesThing { First = 2, Second = 3, Third = 5, Fourth = 7, Fifth = 11 };

// Defines iteration over ERandomValuesThing to be: First, Second, Third, Fourth, Fifth ENUM_RANGE_BY_VALUES(ERandomValuesThing, ERandomValuesThing::First, ERandomValuesThing::Second, ERandomValuesThing::Third, ERandomValuesThing::Fourth, ERandomValuesThing::Fifth)

Definition at line 73 of file EnumRange.h.

Function Documentation

◆ MakeFlagsRange()

template<typename EnumType >
UE::EnumFlags::Private::TRange< EnumType > MakeFlagsRange ( EnumType Flags)

Make a range for iterating over set flags in a flags enum.

Example:

EFlagThing Flags = EFlagThing::A | EFlagThing::B; for (EFlagThing Flag : MakeFlagsRange(Flags)) { // Loop is run twice, once with Flag = EFlagThing::A, once with Flag = EFlagThing::B ... }

Definition at line 250 of file EnumRange.h.