枚举的反射信息

下列枚举类型:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ETargetPlatform.h
#pragma once

#include "CoreMinimal.h"
#include "ETargetPlatform.generated.h"

UENUM(BlueprintType)
enum class ETargetPlatform : uint8
{
AllDesktop,
MacClient,
MacNoEditor,
MacServer,
Mac,
WindowsClient,
WindowsNoEditor,
WindowsServer,
Windows,
Android,
Android_ASTC,
Android_ATC,
Android_DXT,
Android_ETC1,
Android_ETC1a,
Android_ETC2,
Android_PVRTC,
AndroidClient,
Android_ASTCClient,
Android_ATCClient,
Android_DXTClient,
Android_ETC1Client,
Android_ETC1aClient,
Android_ETC2Client,
Android_PVRTCClient,
Android_Multi,
Android_MultiClient,
HTML5,
IOSClient,
IOS,
TVOSClient,
TVOS,
LinuxClient,
LinuxNoEditor,
LinuxServer,
Linux,
Lumin,
LuminClient
};

经过 UHT 之后的反射代码为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ETargetPlatform.generated.h
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"

PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef HOTPATCHERRUNTIME_ETargetPlatform_generated_h
#error "ETargetPlatform.generated.h already included, missing '#pragma once' in ETargetPlatform.h"
#endif
#define HOTPATCHERRUNTIME_ETargetPlatform_generated_h

#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID HotThirdPerson_Plugins_ue4_HotPackage_HotPatcher_Source_HotPatcherRuntime_Public_ETargetPlatform_h


#define FOREACH_ENUM_ETARGETPLATFORM(op) \
op(ETargetPlatform::AllDesktop) \
op(ETargetPlatform::MacClient) \
op(ETargetPlatform::MacNoEditor) \
op(ETargetPlatform::MacServer) \
op(ETargetPlatform::Mac) \
op(ETargetPlatform::WindowsClient) \
op(ETargetPlatform::WindowsNoEditor) \
op(ETargetPlatform::WindowsServer) \
op(ETargetPlatform::Windows) \
op(ETargetPlatform::Android) \
op(ETargetPlatform::Android_ASTC) \
op(ETargetPlatform::Android_ATC) \
op(ETargetPlatform::Android_DXT) \
op(ETargetPlatform::Android_ETC1) \
op(ETargetPlatform::Android_ETC1a) \
op(ETargetPlatform::Android_ETC2) \
op(ETargetPlatform::Android_PVRTC) \
op(ETargetPlatform::AndroidClient) \
op(ETargetPlatform::Android_ASTCClient) \
op(ETargetPlatform::Android_ATCClient) \
op(ETargetPlatform::Android_DXTClient) \
op(ETargetPlatform::Android_ETC1Client) \
op(ETargetPlatform::Android_ETC1aClient) \
op(ETargetPlatform::Android_ETC2Client) \
op(ETargetPlatform::Android_PVRTCClient) \
op(ETargetPlatform::Android_Multi) \
op(ETargetPlatform::Android_MultiClient) \
op(ETargetPlatform::HTML5) \
op(ETargetPlatform::IOSClient) \
op(ETargetPlatform::IOS) \
op(ETargetPlatform::TVOSClient) \
op(ETargetPlatform::TVOS) \
op(ETargetPlatform::LinuxClient) \
op(ETargetPlatform::LinuxNoEditor) \
op(ETargetPlatform::LinuxServer) \
op(ETargetPlatform::Linux) \
op(ETargetPlatform::Lumin) \
op(ETargetPlatform::LuminClient)

enum class ETargetPlatform : uint8;
template<> HOTPATCHERRUNTIME_API UEnum* StaticEnum<ETargetPlatform>();

PRAGMA_ENABLE_DEPRECATION_WARNINGS

产生的 gen.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "UObject/GeneratedCppIncludes.h"
#include "HotPatcherRuntime/Public/ETargetPlatform.h"
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4883)
#endif
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void EmptyLinkFunctionForGeneratedCodeETargetPlatform() {}
// Cross Module References
HOTPATCHERRUNTIME_API UEnum* Z_Construct_UEnum_HotPatcherRuntime_ETargetPlatform();
UPackage* Z_Construct_UPackage__Script_HotPatcherRuntime();
// End Cross Module References
static UEnum* ETargetPlatform_StaticEnum()
{
static UEnum* Singleton = nullptr;
if (!Singleton)
{
Singleton = GetStaticEnum(Z_Construct_UEnum_HotPatcherRuntime_ETargetPlatform, Z_Construct_UPackage__Script_HotPatcherRuntime(), TEXT("ETargetPlatform"));
}
return Singleton;
}
template<> HOTPATCHERRUNTIME_API UEnum* StaticEnum<ETargetPlatform>()
{
return ETargetPlatform_StaticEnum();
}
static FCompiledInDeferEnum Z_CompiledInDeferEnum_UEnum_ETargetPlatform(ETargetPlatform_StaticEnum, TEXT("/Script/HotPatcherRuntime"), TEXT("ETargetPlatform"), false, nullptr, nullptr);
uint32 Get_Z_Construct_UEnum_HotPatcherRuntime_ETargetPlatform_Hash() { return 2902485356U; }
UEnum* Z_Construct_UEnum_HotPatcherRuntime_ETargetPlatform()
{
#if WITH_HOT_RELOAD
UPackage* Outer = Z_Construct_UPackage__Script_HotPatcherRuntime();
static UEnum* ReturnEnum = FindExistingEnumIfHotReloadOrDynamic(Outer, TEXT("ETargetPlatform"), 0, Get_Z_Construct_UEnum_HotPatcherRuntime_ETargetPlatform_Hash(), false);
#else
static UEnum* ReturnEnum = nullptr;
#endif // WITH_HOT_RELOAD
if (!ReturnEnum)
{
static const UE4CodeGen_Private::FEnumeratorParam Enumerators[] = {
{ "ETargetPlatform::AllDesktop", (int64)ETargetPlatform::AllDesktop },
{ "ETargetPlatform::MacClient", (int64)ETargetPlatform::MacClient },
{ "ETargetPlatform::MacNoEditor", (int64)ETargetPlatform::MacNoEditor },
{ "ETargetPlatform::MacServer", (int64)ETargetPlatform::MacServer },
{ "ETargetPlatform::Mac", (int64)ETargetPlatform::Mac },
{ "ETargetPlatform::WindowsClient", (int64)ETargetPlatform::WindowsClient },
{ "ETargetPlatform::WindowsNoEditor", (int64)ETargetPlatform::WindowsNoEditor },
{ "ETargetPlatform::WindowsServer", (int64)ETargetPlatform::WindowsServer },
{ "ETargetPlatform::Windows", (int64)ETargetPlatform::Windows },
{ "ETargetPlatform::Android", (int64)ETargetPlatform::Android },
{ "ETargetPlatform::Android_ASTC", (int64)ETargetPlatform::Android_ASTC },
{ "ETargetPlatform::Android_ATC", (int64)ETargetPlatform::Android_ATC },
{ "ETargetPlatform::Android_DXT", (int64)ETargetPlatform::Android_DXT },
{ "ETargetPlatform::Android_ETC1", (int64)ETargetPlatform::Android_ETC1 },
{ "ETargetPlatform::Android_ETC1a", (int64)ETargetPlatform::Android_ETC1a },
{ "ETargetPlatform::Android_ETC2", (int64)ETargetPlatform::Android_ETC2 },
{ "ETargetPlatform::Android_PVRTC", (int64)ETargetPlatform::Android_PVRTC },
{ "ETargetPlatform::AndroidClient", (int64)ETargetPlatform::AndroidClient },
{ "ETargetPlatform::Android_ASTCClient", (int64)ETargetPlatform::Android_ASTCClient },
{ "ETargetPlatform::Android_ATCClient", (int64)ETargetPlatform::Android_ATCClient },
{ "ETargetPlatform::Android_DXTClient", (int64)ETargetPlatform::Android_DXTClient },
{ "ETargetPlatform::Android_ETC1Client", (int64)ETargetPlatform::Android_ETC1Client },
{ "ETargetPlatform::Android_ETC1aClient", (int64)ETargetPlatform::Android_ETC1aClient },
{ "ETargetPlatform::Android_ETC2Client", (int64)ETargetPlatform::Android_ETC2Client },
{ "ETargetPlatform::Android_PVRTCClient", (int64)ETargetPlatform::Android_PVRTCClient },
{ "ETargetPlatform::Android_Multi", (int64)ETargetPlatform::Android_Multi },
{ "ETargetPlatform::Android_MultiClient", (int64)ETargetPlatform::Android_MultiClient },
{ "ETargetPlatform::HTML5", (int64)ETargetPlatform::HTML5 },
{ "ETargetPlatform::IOSClient", (int64)ETargetPlatform::IOSClient },
{ "ETargetPlatform::IOS", (int64)ETargetPlatform::IOS },
{ "ETargetPlatform::TVOSClient", (int64)ETargetPlatform::TVOSClient },
{ "ETargetPlatform::TVOS", (int64)ETargetPlatform::TVOS },
{ "ETargetPlatform::LinuxClient", (int64)ETargetPlatform::LinuxClient },
{ "ETargetPlatform::LinuxNoEditor", (int64)ETargetPlatform::LinuxNoEditor },
{ "ETargetPlatform::LinuxServer", (int64)ETargetPlatform::LinuxServer },
{ "ETargetPlatform::Linux", (int64)ETargetPlatform::Linux },
{ "ETargetPlatform::Lumin", (int64)ETargetPlatform::Lumin },
{ "ETargetPlatform::LuminClient", (int64)ETargetPlatform::LuminClient },
};
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Enum_MetaDataParams[] = {
{ "BlueprintType", "true" },
{ "ModuleRelativePath", "Public/ETargetPlatform.h" },
};
#endif
static const UE4CodeGen_Private::FEnumParams EnumParams = {
(UObject*(*)())Z_Construct_UPackage__Script_HotPatcherRuntime,
nullptr,
"ETargetPlatform",
"ETargetPlatform",
Enumerators,
ARRAY_COUNT(Enumerators),
RF_Public|RF_Transient|RF_MarkAsNative,
UE4CodeGen_Private::EDynamicType::NotDynamic,
(uint8)UEnum::ECppForm::EnumClass,
METADATA_PARAMS(Enum_MetaDataParams, ARRAY_COUNT(Enum_MetaDataParams))
};
UE4CodeGen_Private::ConstructUEnum(ReturnEnum, EnumParams);
}
return ReturnEnum;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#ifdef _MSC_VER
#pragma warning (pop)
#endif

枚举值的名字可以通过下列方法获得:

1
FString PlatformName = StaticEnum<ETargetPlatform>()->GetNameByValue((int64)Platform).ToString();

其得到的值是具有 namespace 的,如 ETargetPlatform::WindowsNoEditor.

如果不想要 namespace 可以使用:

1
2
3
4
5
FString PlatformName;
{
FString EnumName;
StaticEnum<ETargetPlatform>()->GetNameByValue((int64)Platform).ToString().Split(TEXT("::"), &EnumName, &PlatformName,ESearchCase::CaseSensitive,ESearchDir::FromEnd);
}