A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
IDlgWriter.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "UObject/UnrealType.h"
6
7#include "NYReflectionTypes.h"
8
30class DLGSYSTEM_API IDlgWriter
31{
32public:
33 virtual ~IDlgWriter() {}
34
36 virtual void Write(const UStruct* StructDefinition, const void* Object) = 0;
37 virtual bool ExportToFile(const FString& FileName) = 0;
38 virtual const FString& GetAsString() const = 0;
39
41 static bool CanSkipProperty(const FNYProperty* Property)
42 {
43 if (!Property)
44 {
45 return true;
46 }
47
48#if WITH_EDITOR
49 if (Property->HasMetaData(TEXT("DlgNoExport")))
50 {
51 return true;
52 }
53#endif
54 if (Property->HasAnyPropertyFlags(SkipFlags))
55 {
56 return true;
57 }
58
59 return false;
60 }
61
63 static bool CanWriteOneLinePerItem(const FNYProperty* Property)
64 {
65#if WITH_EDITOR
66 return Property && Property->HasMetaData(TEXT("DlgLinePerItem"));
67#else
68 return false;
69#endif
70 }
71
73 static bool CanWriteIndex(const FNYProperty* Property)
74 {
75#if WITH_EDITOR
76 return Property && Property->HasMetaData(TEXT("DlgWriteIndex"));
77#else
78 return false;
79#endif
80 }
81
83 virtual bool CanSaveAsReference(const FNYProperty* Property, const UObject* Object)
84 {
85 // UClass
86 if (Property && Property->IsA<FNYClassProperty>())
87 {
88 return true;
89 }
90
91 // if outer is nullptr we assume this is something from content browser (texture, mesh, etc.)
92 if (IsValid(Object) && Object->IsValidLowLevelFast())
93 {
94 if (!IsValid(Object->GetOuter()) || Object->GetOuter()->IsA<UPackage>())
95 {
96 return true;
97 }
98 }
99
100#if WITH_EDITOR
101 return Property && Property->HasMetaData(TEXT("DlgSaveOnlyReference"));
102#else
103 return false;
104#endif
105 }
106
107 // bLogVerbose:
108 bool IsLogVerbose() const { return bLogVerbose; }
109 void SetLogVerbose(bool bValue) { bLogVerbose = bValue; }
110
111protected:
113 static constexpr int64 SkipFlags = CPF_Deprecated | CPF_Transient;
114
115 // Should this class verbose log?
116 bool bLogVerbose = false;
117};
UProperty FNYProperty
UClassProperty FNYClassProperty
virtual bool CanSaveAsReference(const FNYProperty *Property, const UObject *Object)
Definition IDlgWriter.h:83
virtual ~IDlgWriter()
Definition IDlgWriter.h:33
virtual const FString & GetAsString() const =0
virtual void Write(const UStruct *StructDefinition, const void *Object)=0
virtual bool ExportToFile(const FString &FileName)=0
static bool CanWriteOneLinePerItem(const FNYProperty *Property)
Definition IDlgWriter.h:63
static bool CanSkipProperty(const FNYProperty *Property)
Definition IDlgWriter.h:41
bool IsLogVerbose() const
Definition IDlgWriter.h:108
void SetLogVerbose(bool bValue)
Definition IDlgWriter.h:109
static bool CanWriteIndex(const FNYProperty *Property)
Definition IDlgWriter.h:73