56 return HasValidWord();
59 void ReadAllProperty(
const UStruct* ReferenceClass,
void* TargetObject,
UObject* DefaultObjectOuter =
nullptr)
override;
74 bool ReadProperty(
const UStruct* ReferenceClass,
void* TargetObject,
UObject* DefaultObjectOuter =
nullptr);
88 bool ReadPurePropertyBlock(
void* TargetObject,
const UStruct* ReferenceClass,
bool bBlockStartAlreadyRead =
false,
UObject* DefaultObjectOuter =
nullptr);
99 static FString ConstructConfigFile(
const UStruct* ReferenceType,
void* SourceObject);
110 bool IsNextWordString()
const;
113 bool IsActualWordString()
const;
121 bool FindNextWord(
const FString& ExpectedStuff);
128 bool FindNextWordAndCheckIfBlockStart(
const FString& BlockName);
135 bool FindNextWordAndCheckIfBlockEnd(
const FString& BlockName);
142 bool CheckIfBlockEnd(
const FString& BlockName);
150 bool CompareToActiveWord(
const FString& StringToCompare)
const;
157 int32 GetActiveLineNumber()
const;
172 bool GetActiveWordAsFloat(
float&
FloatValue)
const;
181 static void ConstructConfigFileInternal(
const UStruct* ReferenceType, int32 TabCount,
void* SourceObject, FString& OutString);
185 bool TryToReadPrimitiveProperty(
void* Target,
FNYProperty* PropertyBase);
187 bool TryToReadEnum(
void* TargetObject,
FNYProperty* PropertyBase);
205 template <
typename Type,
typename PropertyType>
206 bool ReadPrimitiveProperty(
void* Target,
208 std::function<Type()> OnGetAsValue,
209 const FString& TypeName,
224 template <
typename PropertyType>
225 bool ReadComplexProperty(
void* Target,
227 const UStruct* ReferenceType,
228 std::function<
void*(
void*,
const UClass*,
UObject*)> OnInitValue,
232 bool GetAsBool()
const;
233 float GetAsFloat()
const;
234 int32 GetAsInt32()
const;
235 int64 GetAsInt64()
const;
236 FName GetAsName()
const;
237 FString GetAsString()
const;
238 FText GetAsText()
const;
240 void OnInvalidValue(
const FString& PropType)
const;
242 void* OnInitObject(
void* ValuePtr,
const UClass* ChildClass,
UObject* OuterInit);
245 const UClass* SmartGetPropertyClass(
FNYProperty* Property,
const FString& TypeName);
250 FString FileName =
"";
261 bool bHasValidWord =
false;
264 bool bHasNullptr =
false;
267 bool bActiveIsString =
false;
274 std::function<Type()> OnGetAsValue,
275 const FString& TypeName,
279 PropertyType* Property = FNYReflectionHelper::CastProperty<PropertyType>(PropertyBase);
280 if (Property ==
nullptr)
284 auto* ArrayProp = FNYReflectionHelper::CastProperty<FNYArrayProperty>(PropertyBase);
287 if (ArrayProp ==
nullptr || FNYReflectionHelper::SmartCastProperty<PropertyType>(ArrayProp) ==
nullptr)
292 TArray<Type>*
Array = ArrayProp->ContainerPtrToValuePtr<TArray<Type>>(Target);
301 UE_LOG(LogDlgConfigParser,
Warning, TEXT(
"Unexpected end of file while array end was expected (config %s)"), *
FileName)
305 Array->Add(OnGetAsValue());
316 Property->SetPropertyValue_InContainer(Target, OnGetAsValue());
320 UE_LOG(LogDlgConfigParser,
Warning, TEXT(
"Unexpected end of file while %s value was expected (config %s)"), *TypeName, *
FileName)
332 const UStruct* ReferenceType,
333 std::function<
void*(
void*,
const UClass*,
UObject*)> OnInitValue,
336 PropertyType* ElementProp = FNYReflectionHelper::CastProperty<PropertyType>(Property);
337 if (ElementProp ==
nullptr)
339 auto* ArrayProp = FNYReflectionHelper::CastProperty<FNYArrayProperty>(Property);
340 if (ArrayProp ==
nullptr || FNYReflectionHelper::SmartCastProperty<PropertyType>(ArrayProp) ==
nullptr)
346 FScriptArrayHelper Helper(ArrayProp, ArrayProp->ContainerPtrToValuePtr<uint8>(Target));
347 Helper.EmptyValues();
355 const UClass* ReferenceClass = Cast<UClass>(ReferenceType);
356 if (ReferenceClass !=
nullptr)
361 void* TargetPtr = Helper.GetRawPtr(Helper.AddValue());
362 auto* ObjectPtrPtr =
static_cast<UObject**
>(TargetPtr);
363 *ObjectPtrPtr =
nullptr;
364 if (!Path.TrimStartAndEnd().IsEmpty())
366 *ObjectPtrPtr = StaticLoadObject(UObject::StaticClass(), Outer, *Path);
375 if (ReferenceClass ==
nullptr)
377 UE_LOG(LogDlgConfigParser,
Warning, TEXT(
"Failed to find class %s in config %s (:%d)"),
386 UE_LOG(LogDlgConfigParser,
Warning, TEXT(
"Unexpected end of file while %s array element end was expected (config %s)"),
387 *ReferenceType->GetName(), *
FileName)
391 UE_LOG(LogDlgConfigParser,
Warning, TEXT(
"'{' expected but %s found for %s array element (config %s :%d)"),
397 void* Value = OnInitValue(Helper.GetRawPtr(Helper.AddValue()), ReferenceClass, Outer);
398 if (!
ReadPurePropertyBlock(Value, ReferenceClass ==
nullptr ? ReferenceType : ReferenceClass, ReferenceClass ==
nullptr, Outer))
409 void* Value = OnInitValue(ElementProp->template ContainerPtrToValuePtr<void>(Target), Cast<UClass>(ReferenceType), Outer);
bool ReadComplexProperty(void *Target, FNYProperty *Property, const UStruct *ReferenceType, std::function< void *(void *, const UClass *, UObject *)> OnInitValue, UObject *Outer)