Live Config
Loading...
Searching...
No Matches
LiveConfigPropertyName.h
1// Copyright (c) 2026 Nicholas Arthur
2// Licensed under the MIT License
3#pragma once
4
5#include "CoreMinimal.h"
6#include "LiveConfigPropertyName.generated.h"
7
12USTRUCT(BlueprintType, Meta = (HasNativeMake = "/Script/LiveConfig.LiveConfigLibrary.MakeLiteralLiveConfigProperty", HasNativeBreak = "/Script/LiveConfig.LiveConfigLibrary.GetPropertyName", DisableSplitPin))
13struct LIVECONFIG_API FLiveConfigProperty
14{
15 GENERATED_BODY()
16
17 FLiveConfigProperty() : PropertyName(NAME_None) {}
18 FLiveConfigProperty(FName InPropertyName) : PropertyName(InPropertyName) {}
19 FLiveConfigProperty(FName InPropertyName, bool bRedirect);
20 // Note this version will *not* handle redirects
21 FLiveConfigProperty(const FString& InPropertyStr) : PropertyName(*InPropertyStr) {}
22 FLiveConfigProperty(const FString& InPropertyStr, bool bRedirect);
23 FLiveConfigProperty(const TCHAR* InPropertyStr) : PropertyName(InPropertyStr) {}
24
26 FName GetName() const { return PropertyName; }
27
29 FString ToString() const { return PropertyName.ToString(); }
30
32 bool IsValid() const { return PropertyName != NAME_None; }
33
35 bool operator==(const FLiveConfigProperty& Other) const { return PropertyName == Other.PropertyName; }
36 bool operator!=(const FLiveConfigProperty& Other) const { return PropertyName != Other.PropertyName; }
37
42 static FLiveConfigProperty Request(FName InPropertyName);
43
44 bool ExportTextItem(FString& ValueStr, FLiveConfigProperty const& DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope) const;
45 bool ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText);
46
47 FORCEINLINE friend uint32 GetTypeHash(const FLiveConfigProperty& Prop)
48 {
49 return GetTypeHash(Prop.GetName());
50 }
51
52 UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (Categories = "LiveConfig"))
53 FName PropertyName;
54
56 void PostSerialize(const FArchive& Ar);
57};
58
60FORCEINLINE FLiveConfigProperty operator""_LC(const char* Str,size_t)
61{
62 return FLiveConfigProperty::Request(FName(Str));
63}
64
65template<>
66struct TStructOpsTypeTraits<FLiveConfigProperty> : public TStructOpsTypeTraitsBase2<FLiveConfigProperty>
67{
68 enum
69 {
70 WithExportTextItem = true,
71 WithImportTextItem = true,
72 WithPostSerialize = true,
73 };
74};
75
Definition LiveConfigPropertyName.h:14
bool operator==(const FLiveConfigProperty &Other) const
Definition LiveConfigPropertyName.h:35
static FLiveConfigProperty Request(FName InPropertyName)
Definition LiveConfigPropertyName.cpp:24
FString ToString() const
Definition LiveConfigPropertyName.h:29
FName GetName() const
Definition LiveConfigPropertyName.h:26
bool IsValid() const
Definition LiveConfigPropertyName.h:32