Agrarsense
Static Public Member Functions | Static Private Member Functions | List of all members
UEnumUtilities Class Reference

#include <EnumUtilities.h>

Inheritance diagram for UEnumUtilities:
Inheritance graph
[legend]
Collaboration diagram for UEnumUtilities:
Collaboration graph
[legend]

Static Public Member Functions

static EFoliageTypes ConvertStringToFoliageType (const FString &String)
 
static FString ConvertFoliageTypeToString (EFoliageTypes FoliageType)
 
static EPropTypes ConvertStringToPropType (const FString &String)
 
static FString ConvertPropTypeToString (EPropTypes PropType)
 
static ESensorTypes ConvertStringToSensorType (const FString &String)
 
static FString ConvertSensorTypeToString (ESensorTypes Sensortype)
 
static EVehicleTypes ConvertStringToVehicleType (const FString &String)
 
static FString ConvertVehicleTypeToString (EVehicleTypes VehicleType)
 
static EWalkerType ConvertStringToWalkerType (const FString &String)
 
static FString ConvertWalkerTypeToString (EWalkerType WalkerType)
 
static EWalkerAction ConvertStringToWalkerActionType (const FString &String)
 
static FString ConvertWalkerActionTypeToString (EWalkerAction WalkerAction)
 
static EWalkerEndAction ConvertStringToWalkerEndActionType (const FString &String)
 
static FString ConvertWalkerEndActionTypeToString (EWalkerEndAction WalkerEndAction)
 
static EQualityLevel ConvertStringToQualityLevel (const FString &String)
 
static FString ConvertQualityLevelToString (EQualityLevel QualityLevel)
 
static EAntiAliasing ConvertStringToAntiAliasingMethod (const FString &String)
 
static FString ConvertAntiAliasingMethodToString (EAntiAliasing AntiAliasingMethod)
 
template<typename TEnum >
static TMap< TEnum, FString > CreateEnumStringMap (const FString &EnumTypeName)
 
template<typename TEnum >
static TMap< FString, TEnum > CreateStringEnumMap (const FString &EnumTypeName)
 

Static Private Member Functions

template<typename TEnum >
static TEnum ConvertStringToEnum (const FString &EnumString, const FString &EnumTypeName)
 

Detailed Description

EnumUtilities is a Blueprint Function Library for converting things.

Definition at line 26 of file EnumUtilities.h.

Member Function Documentation

◆ ConvertAntiAliasingMethodToString()

FString UEnumUtilities::ConvertAntiAliasingMethodToString ( EAntiAliasing  AntiAliasingMethod)
static

Definition at line 93 of file EnumUtilities.cpp.

94{
95 return UEnum::GetDisplayValueAsText(AntiAliasingMethod).ToString();
96}

◆ ConvertFoliageTypeToString()

FString UEnumUtilities::ConvertFoliageTypeToString ( EFoliageTypes  FoliageType)
static

Definition at line 13 of file EnumUtilities.cpp.

14{
15 return UEnum::GetDisplayValueAsText(FoliageType).ToString();
16}

◆ ConvertPropTypeToString()

FString UEnumUtilities::ConvertPropTypeToString ( EPropTypes  PropType)
static

Definition at line 23 of file EnumUtilities.cpp.

24{
25 return UEnum::GetDisplayValueAsText(PropType).ToString();
26}

◆ ConvertQualityLevelToString()

FString UEnumUtilities::ConvertQualityLevelToString ( EQualityLevel  QualityLevel)
static

Definition at line 83 of file EnumUtilities.cpp.

84{
85 return UEnum::GetDisplayValueAsText(QualityLevel).ToString();
86}

Referenced by UAgrarsenseSettings::SetQualityLevel().

◆ ConvertSensorTypeToString()

FString UEnumUtilities::ConvertSensorTypeToString ( ESensorTypes  Sensortype)
static

Definition at line 33 of file EnumUtilities.cpp.

34{
35 return UEnum::GetDisplayValueAsText(Sensortype).ToString();
36}

Referenced by ASensor::CreateROSTopic(), USimulatorJsonExporter::ExportSensorToJSON(), ASensor::GetActorInformation_Implementation(), and USensorFactory::SetSensorIdentifierAndNameWithFallbacks().

◆ ConvertStringToAntiAliasingMethod()

EAntiAliasing UEnumUtilities::ConvertStringToAntiAliasingMethod ( const FString &  String)
static

Definition at line 88 of file EnumUtilities.cpp.

89{
90 return ConvertStringToEnum<EAntiAliasing>(String, TEXT("/Script/Agrarsense.EAntiAliasing"));
91}

Referenced by UAgrarsenseSettings::SetAntiAliasingMethodFromString().

◆ ConvertStringToEnum()

template<typename TEnum >
static TEnum UEnumUtilities::ConvertStringToEnum ( const FString &  EnumString,
const FString &  EnumTypeName 
)
inlinestaticprivate

Convert an FString to an enum value of type TEnum.

Parameters
EnumString- The string representation of the enum value.
EnumTypeName- The full type name of the enum in the format "/Script/[ProjectName].[ClassName]"
Returns
The enum value corresponding to the given string, or a default value if not found.

Definition at line 141 of file EnumUtilities.h.

142 {
143 UEnum* Enum = FindObject<UEnum>(nullptr, *EnumTypeName, true);
144 if (Enum)
145 {
146 int32 EnumIndex = Enum->GetIndexByName(FName(*EnumString));
147 if (EnumIndex != INDEX_NONE)
148 {
149 return static_cast<TEnum>(Enum->GetValueByIndex(EnumIndex));
150 }
151 }
152
153 return TEnum(0); // Default value if not found
154 }

◆ ConvertStringToFoliageType()

EFoliageTypes UEnumUtilities::ConvertStringToFoliageType ( const FString &  String)
static

Definition at line 8 of file EnumUtilities.cpp.

9{
10 return ConvertStringToEnum<EFoliageTypes>(String, TEXT("/Script/Agrarsense.EFoliageTypes"));
11}

Referenced by USimulatorJsonParser::ParsePropOrFoliage().

◆ ConvertStringToPropType()

EPropTypes UEnumUtilities::ConvertStringToPropType ( const FString &  String)
static

Definition at line 18 of file EnumUtilities.cpp.

19{
20 return ConvertStringToEnum<EPropTypes>(String, TEXT("/Script/Agrarsense.EPropTypes"));
21}

Referenced by USimulatorJsonParser::ParsePropOrFoliage().

◆ ConvertStringToQualityLevel()

EQualityLevel UEnumUtilities::ConvertStringToQualityLevel ( const FString &  String)
static

Definition at line 78 of file EnumUtilities.cpp.

79{
80 return ConvertStringToEnum<EQualityLevel>(String, TEXT("/Script/Agrarsense.EQualityLevel"));
81}

Referenced by UAgrarsenseSettings::ParseLaunchArguments(), and UAgrarsenseSettings::SetQualityLevelFromString().

◆ ConvertStringToSensorType()

ESensorTypes UEnumUtilities::ConvertStringToSensorType ( const FString &  String)
static

Definition at line 28 of file EnumUtilities.cpp.

29{
30 return ConvertStringToEnum<ESensorTypes>(String, TEXT("/Script/Agrarsense.ESensorTypes"));
31}

Referenced by USimulatorJsonParser::SpawnSensorToVehicle(), and USimulatorJsonParser::SpawnSensorWorld().

◆ ConvertStringToVehicleType()

EVehicleTypes UEnumUtilities::ConvertStringToVehicleType ( const FString &  String)
static

Definition at line 38 of file EnumUtilities.cpp.

39{
40 return ConvertStringToEnum<EVehicleTypes>(String, TEXT("/Script/Agrarsense.EVehicleTypes"));
41}

Referenced by USimulatorJsonParser::ParseVehicle().

◆ ConvertStringToWalkerActionType()

EWalkerAction UEnumUtilities::ConvertStringToWalkerActionType ( const FString &  String)
static

Definition at line 58 of file EnumUtilities.cpp.

59{
60 return ConvertStringToEnum<EWalkerAction>(String, TEXT("/Script/Agrarsense.EWalkerAction"));
61}

Referenced by USimulatorJsonParser::SpawnWalker().

◆ ConvertStringToWalkerEndActionType()

EWalkerEndAction UEnumUtilities::ConvertStringToWalkerEndActionType ( const FString &  String)
static

Definition at line 68 of file EnumUtilities.cpp.

69{
70 return ConvertStringToEnum<EWalkerEndAction>(String, TEXT("/Script/Agrarsense.EWalkerEndAction"));
71}

Referenced by USimulatorJsonParser::SpawnWalker().

◆ ConvertStringToWalkerType()

EWalkerType UEnumUtilities::ConvertStringToWalkerType ( const FString &  String)
static

Definition at line 48 of file EnumUtilities.cpp.

49{
50 return ConvertStringToEnum<EWalkerType>(String, TEXT("/Script/Agrarsense.EWalkerType"));
51}

Referenced by USimulatorJsonParser::SpawnWalker().

◆ ConvertVehicleTypeToString()

FString UEnumUtilities::ConvertVehicleTypeToString ( EVehicleTypes  VehicleType)
static

Definition at line 43 of file EnumUtilities.cpp.

44{
45 return UEnum::GetDisplayValueAsText(VehicleType).ToString();
46}

Referenced by AVehicle::GetActorInformation_Implementation(), and UAssetLibrary::SpawnVehicle().

◆ ConvertWalkerActionTypeToString()

FString UEnumUtilities::ConvertWalkerActionTypeToString ( EWalkerAction  WalkerAction)
static

Definition at line 63 of file EnumUtilities.cpp.

64{
65 return UEnum::GetDisplayValueAsText(WalkerAction).ToString();
66}

◆ ConvertWalkerEndActionTypeToString()

FString UEnumUtilities::ConvertWalkerEndActionTypeToString ( EWalkerEndAction  WalkerEndAction)
static

Definition at line 73 of file EnumUtilities.cpp.

74{
75 return UEnum::GetDisplayValueAsText(WalkerEndAction).ToString();
76}

◆ ConvertWalkerTypeToString()

FString UEnumUtilities::ConvertWalkerTypeToString ( EWalkerType  WalkerType)
static

Definition at line 53 of file EnumUtilities.cpp.

54{
55 return UEnum::GetDisplayValueAsText(WalkerType).ToString();
56}

Referenced by USimulatorJsonExporter::ExportWalkerToJSON(), AWalker::GetActorInformation_Implementation(), and UAssetLibrary::SpawnWalker().

◆ CreateEnumStringMap()

template<typename TEnum >
static TMap< TEnum, FString > UEnumUtilities::CreateEnumStringMap ( const FString &  EnumTypeName)
inlinestatic

Convert an enum type to a TMap<FString, TEnum>.

Definition at line 90 of file EnumUtilities.h.

91 {
92 TMap<TEnum, FString> EnumMap;
93
94 // EnumTypeName must be in the following format: "/Script/ProjectName.EnumClassName"
95 UEnum* Enum = FindObject<UEnum>(nullptr, *EnumTypeName, true);
96 if (Enum)
97 {
98 for (int32 EnumIndex = 0; EnumIndex < Enum->NumEnums(); EnumIndex++)
99 {
100 TEnum EnumValue = static_cast<TEnum>(Enum->GetValueByIndex(EnumIndex));
101 FString EnumName = Enum->GetNameStringByIndex(EnumIndex);
102
103 EnumMap.Add(EnumValue, EnumName);
104 }
105 }
106
107 return EnumMap;
108 }

◆ CreateStringEnumMap()

template<typename TEnum >
static TMap< FString, TEnum > UEnumUtilities::CreateStringEnumMap ( const FString &  EnumTypeName)
inlinestatic

Definition at line 111 of file EnumUtilities.h.

112 {
113 TMap<FString, TEnum> EnumMap;
114
115 // EnumTypeName must be in the following format: "/Script/ProjectName.EnumClassName"
116 UEnum* Enum = FindObject<UEnum>(nullptr, *EnumTypeName, true);
117 if (Enum)
118 {
119 for (int32 EnumIndex = 0; EnumIndex < Enum->NumEnums(); EnumIndex++)
120 {
121 TEnum EnumValue = static_cast<TEnum>(Enum->GetValueByIndex(EnumIndex));
122 FString EnumName = Enum->GetNameStringByIndex(EnumIndex);
123
124 EnumMap.Add(EnumName, EnumValue);
125 }
126 }
127
128 return EnumMap;
129 }

The documentation for this class was generated from the following files: