UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StructUtilsTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include <type_traits>
6#include "UObject/Class.h"
8
9#define UE_API COREUOBJECT_API
10
11struct FSharedStruct;
13struct FStructView;
14struct FConstStructView;
15struct FInstancedStruct;
18
19namespace UE::StructUtils
20{
25 extern UE_API uint32 GetStructCrc32(const UScriptStruct& ScriptStruct, const uint8* StructMemory, const uint32 CRC = 0);
26 extern UE_API uint32 GetStructCrc32(const FStructView& StructView, const uint32 CRC = 0);
27 extern UE_API uint32 GetStructCrc32(const FConstStructView& StructView, const uint32 CRC = 0);
28 extern UE_API uint32 GetStructCrc32(const FSharedStruct& SharedView, const uint32 CRC = 0);
29 extern UE_API uint32 GetStructCrc32(const FConstSharedStruct& SharedView, const uint32 CRC = 0);
30
35 extern UE_API uint32 GetStructInstanceCrc32(const UScriptStruct& ScriptStruct, const uint8* StructMemory, const uint32 CRC = 0);
40
46 extern UE_API uint64 GetStructHash64(const UScriptStruct& ScriptStruct, const uint8* StructMemory);
51
52 template <typename T>
54 {
55 if constexpr (std::is_base_of_v<UObject, T>)
56 {
57 return T::StaticClass();
58 }
59 else
60 {
61 return T::StaticStruct();
62 }
63 }
64
65 template<typename T>
66 inline constexpr bool TIsSharedInstancedOrViewStruct_V = std::is_same_v<FStructView, T>
67 || std::is_same_v<FConstStructView, T>
68 || std::is_same_v<FSharedStruct, T>
69 || std::is_same_v<FConstSharedStruct, T>
70 || std::is_same_v<FInstancedStruct, T>;
71}
72
73/* Predicate useful to find a struct of a specific type in an container */
75{
77
82
83 template <typename T>
84 requires (UE::StructUtils::TIsSharedInstancedOrViewStruct_V<T>)
86 : TypePtr(Struct.GetScriptStruct())
87 {
88 }
89
90 template <typename T>
91 requires (UE::StructUtils::TIsSharedInstancedOrViewStruct_V<T>)
92 bool operator()(const T& Struct) const
93 {
94 return Struct.GetScriptStruct() == TypePtr;
95 }
96};
97
99{
100 template <typename T>
101 bool operator()(const T& A, const T& B) const
102 {
103 return (A.GetStructureSize() > B.GetStructureSize())
104 || (A.GetStructureSize() == B.GetStructureSize() && B.GetFName().FastLess(A.GetFName()));
105 }
106};
107
109{
110 template <typename T>
111 requires (UE::StructUtils::TIsSharedInstancedOrViewStruct_V<T>)
112 bool operator()(const T& A, const T& B) const
113 {
114 const UScriptStruct* AScriptStruct = A.GetScriptStruct();
115 const UScriptStruct* BScriptStruct = B.GetScriptStruct();
116 if (!AScriptStruct)
117 {
118 return true;
119 }
120 else if (!BScriptStruct)
121 {
122 return false;
123 }
125 }
126};
127
128#if WITH_EDITOR
130{
131 // Private structs used during user defined struct reinstancing.
133 {
136 private:
138 };
139
141 {
144 private:
146 };
147
150};
151#endif // WITH_EDITOR
152
153#undef UE_API
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_API
Definition SColorGradingComponentViewer.h:12
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UObjectGlobals.h:2492
Definition Object.h:95
Definition Class.h:1720
Definition UserDefinedStruct.h:61
Definition PropertyBag.cpp:61
Definition PropertyBag.cpp:61
auto * GetAsUStruct()
Definition StructUtilsTypes.h:53
constexpr bool TIsSharedInstancedOrViewStruct_V
Definition StructUtilsTypes.h:66
uint32 GetStructInstanceCrc32(const UScriptStruct &ScriptStruct, const uint8 *StructMemory, const uint32 CRC)
Definition StructUtilsTypes.cpp:58
uint64 GetStructHash64(const UScriptStruct &ScriptStruct, const uint8 *StructMemory)
Definition StructUtilsTypes.cpp:186
uint32 GetStructCrc32(const UScriptStruct &ScriptStruct, const uint8 *StructMemory, const uint32 CRC)
Definition StructUtilsTypes.cpp:69
Definition SharedStruct.h:538
Definition StructView.h:217
Definition InstancedStruct.h:32
Definition StructUtilsTypes.h:99
bool operator()(const T &A, const T &B) const
Definition StructUtilsTypes.h:101
Definition SharedStruct.h:161
Definition StructUtilsTypes.h:75
FStructTypeEqualOperator(const UScriptStruct *InTypePtr)
Definition StructUtilsTypes.h:78
FStructTypeEqualOperator(const T &Struct)
Definition StructUtilsTypes.h:85
const UScriptStruct * TypePtr
Definition StructUtilsTypes.h:76
Definition StructUtilsTypes.h:109
Definition StructView.h:24