UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PropertyVisitor.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
8
9class FProperty;
13
15{
16 Stop, // Stop the visit
17 StepOver, // Skip over to the next property or item
18 StepOut, // Stop iteration at this level and continue on the outer on the next property or item
19 StepInto, // Introspect the inner properties if any
20};
21
23{
24 None, // Property is not inside a container
25 StaticArrayIndex, // Property is a static array and has a valid index
26 ContainerIndex, // Property is inside a container and has a valid index
27 MapKey, // Property represents a key of the map container and has a valid index
28 MapValue, // Property represents a value of the map container and has a valid index
29};
30
32{
44
50
53
56
58
61 {
62 return A.Property == B.Property && A.PropertyInfo == B.PropertyInfo && A.Index == B.Index;
63 }
65 {
66 return !(A == B);
67 }
68
70 {
71 return HashCombine(HashCombine(GetTypeHash(A.Property), GetTypeHash(A.PropertyInfo)), GetTypeHash(A.Index));
72 }
73
75 const FProperty* Property = nullptr;
76
82 const UStruct* ParentStructType = nullptr;
83
88
91
92 /* Indicate that this property contains inner properties */
94};
95
97{
98public:
105
108
111
113 {
114 Push(Info);
115 }
116
121
124
126 {
127 Path.Push(Info);
128 if (OnPushFunc)
129 {
131 }
132 }
133
135 {
137 if (OnPopFunc)
138 {
140 }
141 return MoveTemp(Info);
142 }
143
144 int32 Num() const
145 {
146 return Path.Num();
147 }
148
150 {
151 return Path.Top();
152 }
153
155 {
156 return Path.Top();
157 }
158
160 {
161 return Path;
162 }
163
165 {
166 return A.Path == B.Path;
167 }
169 {
170 return !(A == B);
171 }
172
174 {
175 return GetTypeHash(A.Path);
176 }
177
178 COREUOBJECT_API FString ToString(const TCHAR* Separator = TEXT(".")) const;
179 COREUOBJECT_API void ToString(FStringBuilderBase& Out, const TCHAR* Separator = TEXT(".")) const;
180 COREUOBJECT_API void AppendString(FStringBuilderBase& Out, const TCHAR* Separator = TEXT(".")) const;
181
188 COREUOBJECT_API bool Contained(const FPropertyVisitorPath& OtherPath, bool* bIsEqual = nullptr) const;
189
196
199
205 {
206 return Iterator(Path);
207 }
208
214
223
224protected:
228};
229
231{
232public:
238
240 {
241 Path.Pop();
242 }
243
244protected:
246};
247
266
268{
269 enum class EScope : uint8
270 {
271 // Visits all the properties (default)
272 All,
273 // Visits only the object reference properties
275 };
276
282
289
293};
294
296{
297
298namespace Private
299{
300
301template <typename Type>
302void* ResolveVisitedPathInfo(const Type* This, void* Data, const FPropertyVisitorInfo& Info)
303{
304 return This->ResolveVisitedPathInfo(Data, Info);
305}
306
307} // namespace Private
308
313template <typename Type>
314void* ResolveVisitedPath(const Type* RootObject, void* RootData, const FPropertyVisitorPath& Path)
315{
316 void* FoundPropertyData = nullptr;
317 if (const TArray<FPropertyVisitorInfo>& PathArray = Path.GetPath();
318 PathArray.Num() > 0)
319 {
322 {
323 const FPropertyVisitorInfo& PreviousInfo = PathArray[PathIndex - 1];
325 }
326 }
327 return FoundPropertyData;
328}
329
334template <typename Type>
336{
337 void* FoundInnerData = nullptr;
338
339 FPropertyVisitorData VisitorData(Data, /*ParentStructData*/nullptr);
340
342 This->Visit(Context, [&FoundInnerData, &Info, InnerPathDepth = Path.Num() + 1](const FPropertyVisitorContext& Context)
343 {
344 const FPropertyVisitorPath& InnerPath = Context.Path;
345 const FPropertyVisitorData& InnerVisitorData = Context.Data;
346
347 if (InnerPath.Num() < InnerPathDepth)
348 {
349 return EPropertyVisitorControlFlow::StepInto;
350 }
351
352 void* InnerData = InnerVisitorData.PropertyData;
353
354 if (Info == InnerPath.Top())
355 {
358 }
360 });
361 return FoundInnerData;
362}
363template <typename Type>
364void* ResolveVisitedPathInfo_Generic(Type* This, void* Data, const FPropertyVisitorInfo& Info)
365{
367 return ResolveVisitedPathInfo_Generic(This, Path, Data, Info);
368}
369
370UE_DEPRECATED(5.7, "Visit is deprecated, please use Visit with context instead.")
372
375
377COREUOBJECT_API FString PathToString(TArrayView<const FPropertyVisitorInfo> Path, const TCHAR* Separator = TEXT("."));
378COREUOBJECT_API void PathToString(TArrayView<const FPropertyVisitorInfo> Path, FStringBuilderBase& Out, const TCHAR* Separator = TEXT("."));
379COREUOBJECT_API void PathAppendString(TArrayView<const FPropertyVisitorInfo> Path, FStringBuilderBase& Out, const TCHAR* Separator = TEXT("."));
380
387COREUOBJECT_API bool PathIsContainedWithin(TArrayView<const FPropertyVisitorInfo> Path, TArrayView<const FPropertyVisitorInfo> OtherPath, bool* bIsEqual = nullptr);
388
390COREUOBJECT_API FArchiveSerializedPropertyChain PathToSerializedPropertyChain(TArrayView<const FPropertyVisitorInfo> Path);
391
392} // namespace PropertyVisitorHelpers
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EPropertyVisitorControlFlow
Definition PropertyVisitor.h:15
EPropertyVisitorInfoType
Definition PropertyVisitor.h:23
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UnrealType.h:6738
Definition UnrealType.h:174
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT void Push(ElementType &&Item)
Definition Array.h:1224
ElementType Pop(EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:1196
UE_NODEBUG UE_FORCEINLINE_HINT ElementType & Top() UE_LIFETIMEBOUND
Definition Array.h:1248
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition Array.h:64
Definition Object.h:95
Definition Class.h:480
Definition OverriddenPropertySet.cpp:45
void * ResolveVisitedPathInfo(const Type *This, void *Data, const FPropertyVisitorInfo &Info)
Definition PropertyVisitor.h:302
Definition PropertyVisitor.h:296
void * ResolveVisitedPath(const Type *RootObject, void *RootData, const FPropertyVisitorPath &Path)
Definition PropertyVisitor.h:314
void * ResolveVisitedPathInfo_Generic(Type *This, FPropertyVisitorPath &Path, void *Data, const FPropertyVisitorInfo &Info)
Definition PropertyVisitor.h:335
U16 Index
Definition radfft.cpp:71
Definition ArchiveSerializedPropertyChain.h:9
Definition UnrealType.h:6865
Definition PropertyVisitor.h:268
FPropertyVisitorContext VisitPropertyData(void *InPropertyData) const
Definition PropertyVisitor.h:284
EScope
Definition PropertyVisitor.h:270
FPropertyVisitorPath & Path
Definition PropertyVisitor.h:290
const FPropertyVisitorData Data
Definition PropertyVisitor.h:291
const EScope Scope
Definition PropertyVisitor.h:292
FPropertyVisitorContext(FPropertyVisitorPath &InPath, const FPropertyVisitorData &InData, const EScope InScope=EScope::All)
Definition PropertyVisitor.h:277
Definition PropertyVisitor.h:249
FPropertyVisitorData(void *InPropertyData, void *InParentStructData)
Definition PropertyVisitor.h:250
void * ParentStructData
Definition PropertyVisitor.h:264
FPropertyVisitorData VisitPropertyData(void *InPropertyData) const
Definition PropertyVisitor.h:256
void * PropertyData
Definition PropertyVisitor.h:262
Definition PropertyVisitor.h:32
friend uint32 GetTypeHash(const FPropertyVisitorInfo &A)
Definition PropertyVisitor.h:69
FPropertyVisitorInfo(FPropertyVisitorInfo &&)=default
COREUOBJECT_API bool Identical(const FPropertyVisitorInfo &Other) const
Definition PropertyVisitor.cpp:13
const FProperty * Property
Definition PropertyVisitor.h:75
EPropertyVisitorInfoType PropertyInfo
Definition PropertyVisitor.h:90
FPropertyVisitorInfo(const FProperty *InProperty, const UStruct *InParentStructType)
Definition PropertyVisitor.h:45
FPropertyVisitorInfo & operator=(FPropertyVisitorInfo &&)=default
friend bool operator!=(const FPropertyVisitorInfo &A, const FPropertyVisitorInfo &B)
Definition PropertyVisitor.h:64
bool bContainsInnerProperties
Definition PropertyVisitor.h:93
const UStruct * ParentStructType
Definition PropertyVisitor.h:82
FPropertyVisitorInfo(const FProperty *InProperty, int32 InIndex=INDEX_NONE, EPropertyVisitorInfoType InPropertyInfo=EPropertyVisitorInfoType::None, const UStruct *InParentStructType=nullptr)
Definition PropertyVisitor.h:33
friend bool operator==(const FPropertyVisitorInfo &A, const FPropertyVisitorInfo &B)
Definition PropertyVisitor.h:60
FPropertyVisitorInfo(const FPropertyVisitorInfo &)=default
FPropertyVisitorInfo & operator=(const FPropertyVisitorInfo &)=default
Definition PropertyVisitor.h:97
FPropertyVisitorPath(TFunction< void(const FPropertyVisitorInfo &)> InOnPushFunc, TFunction< void(const FPropertyVisitorInfo &)> InOnPopFunc)
Definition PropertyVisitor.h:100
FPropertyVisitorInfo Pop()
Definition PropertyVisitor.h:134
TFunction< void(const FPropertyVisitorInfo &)> OnPushFunc
Definition PropertyVisitor.h:226
TArray< FPropertyVisitorInfo >::TConstIterator Iterator
Definition PropertyVisitor.h:198
COREUOBJECT_API void AppendString(FStringBuilderBase &Out, const TCHAR *Separator=TEXT(".")) const
Definition PropertyVisitor.cpp:80
int32 Num() const
Definition PropertyVisitor.h:144
FPropertyVisitorPath & operator=(FPropertyVisitorPath &&)=default
friend bool operator!=(const FPropertyVisitorPath &A, const FPropertyVisitorPath &B)
Definition PropertyVisitor.h:168
COREUOBJECT_API void * GetPropertyDataPtr(UObject *Object) const
Definition PropertyVisitor.cpp:90
COREUOBJECT_API FArchiveSerializedPropertyChain ToSerializedPropertyChain() const
Definition PropertyVisitor.cpp:96
COREUOBJECT_API bool Contained(const FPropertyVisitorPath &OtherPath, bool *bIsEqual=nullptr) const
Definition PropertyVisitor.cpp:85
friend uint32 GetTypeHash(const FPropertyVisitorPath &A)
Definition PropertyVisitor.h:173
FPropertyVisitorPath(const FPropertyVisitorInfo &Info)
Definition PropertyVisitor.h:112
FPropertyVisitorPath(FPropertyVisitorPath &&)=default
FPropertyVisitorPath & operator=(const FPropertyVisitorPath &)=default
FPropertyVisitorPath(const FPropertyVisitorPath &)=default
void Push(const FPropertyVisitorInfo &Info)
Definition PropertyVisitor.h:125
FPropertyVisitorInfo & Top()
Definition PropertyVisitor.h:149
const FPropertyVisitorInfo & Top() const
Definition PropertyVisitor.h:154
static COREUOBJECT_API Iterator InvalidIterator()
Definition PropertyVisitor.cpp:26
FPropertyVisitorPath(TArrayView< const FPropertyVisitorInfo > InPath)
Definition PropertyVisitor.h:117
TFunction< void(const FPropertyVisitorInfo &)> OnPopFunc
Definition PropertyVisitor.h:227
const TArray< FPropertyVisitorInfo > & GetPath() const
Definition PropertyVisitor.h:159
FPropertyVisitorPath()=default
friend bool operator==(const FPropertyVisitorPath &A, const FPropertyVisitorPath &B)
Definition PropertyVisitor.h:164
Iterator GetRootIterator() const
Definition PropertyVisitor.h:204
TArray< FPropertyVisitorInfo > Path
Definition PropertyVisitor.h:225
Definition PropertyVisitor.h:231
FPropertyVisitorScope(FPropertyVisitorPath &InPath, const FPropertyVisitorInfo &Info)
Definition PropertyVisitor.h:233
FPropertyVisitorPath & Path
Definition PropertyVisitor.h:245
~FPropertyVisitorScope()
Definition PropertyVisitor.h:239