UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PropertyPairsMap.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Map.h"
6#include "CoreTypes.h"
9#include "UObject/NameTypes.h"
10
13{
14public:
21 inline void AddProperty(FName InName, FName InValue = NAME_None)
22 {
23 Properties.Add(InName, InValue);
24 }
25
32 inline bool HasProperty(FName InName) const
33 {
34 return GetProperty(InName);
35 }
36
37 inline bool HasProperty(const TCHAR* InName) const
38 {
40 return !PropertyName.IsNone() && GetProperty(PropertyName);
41 }
42
50 inline bool GetProperty(FName InName, FName* OutValue = nullptr) const
51 {
52 if (const FName* ValuePtr = Properties.Find(InName))
53 {
54 if (OutValue)
55 {
56 *OutValue = *ValuePtr;
57 }
58 return true;
59 }
60 return false;
61 }
62
63 inline bool GetProperty(const TCHAR* InName, FName* OutValue = nullptr) const
64 {
66 return !PropertyName.IsNone() && GetProperty(PropertyName, OutValue);
67 }
68
76 {
77 return Properties.OrderIndependentCompareEqual(InOther.Properties);
78 }
79
81 {
82 return !(*this == InOther);
83 }
84
93 {
94 return InAr << InPropertyPairsMap.Properties;
95 }
96
102 template <class Func>
103 inline void ForEachProperty(Func InFunc)
104 {
106
107 for (auto [Name, Value] : Properties)
108 {
109 if (!Invoker(Name, Value))
110 {
111 return;
112 }
113 }
114 }
115
117 inline bool IsEmpty() const
118 {
119 return Properties.IsEmpty();
120 }
121
123 inline int32 Num() const
124 {
125 return Properties.Num();
126 }
127
133 inline FString ToString() const
134 {
135 TStringBuilder<1024> StringBuilder;
136
137 StringBuilder.AppendChar(TEXT('('));
138
139 if (Properties.Num())
140 {
141 for (auto [Name, Value] : Properties)
142 {
143 StringBuilder.AppendChar(TEXT('('));
144 StringBuilder.Append(Name.ToString());
145
146 if (!Value.IsNone())
147 {
148 StringBuilder.AppendChar(TEXT(','));
149 StringBuilder.Append(Value.ToString());
150 }
151
152 StringBuilder.AppendChar(TEXT(')'));
153 StringBuilder.AppendChar(TEXT(','));
154 }
155 StringBuilder.RemoveSuffix(1);
156 }
157
158 StringBuilder.AppendChar(TEXT(')'));
159
160 return StringBuilder.ToString();
161 }
162
163protected:
165};
#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
@ FNAME_Find
Definition NameTypes.h:209
Definition Archive.h:1208
Definition NameTypes.h:617
Definition PropertyPairsMap.h:13
friend FArchive & operator<<(FArchive &InAr, FPropertyPairsMap &InPropertyPairsMap)
Definition PropertyPairsMap.h:92
bool GetProperty(FName InName, FName *OutValue=nullptr) const
Definition PropertyPairsMap.h:50
bool HasProperty(const TCHAR *InName) const
Definition PropertyPairsMap.h:37
void ForEachProperty(Func InFunc)
Definition PropertyPairsMap.h:103
bool IsEmpty() const
Definition PropertyPairsMap.h:117
bool operator!=(const FPropertyPairsMap &InOther) const
Definition PropertyPairsMap.h:80
bool HasProperty(FName InName) const
Definition PropertyPairsMap.h:32
bool GetProperty(const TCHAR *InName, FName *OutValue=nullptr) const
Definition PropertyPairsMap.h:63
FString ToString() const
Definition PropertyPairsMap.h:133
void AddProperty(FName InName, FName InValue=NAME_None)
Definition PropertyPairsMap.h:21
TMap< FName, FName > Properties
Definition PropertyPairsMap.h:164
bool operator==(const FPropertyPairsMap &InOther) const
Definition PropertyPairsMap.h:75
int32 Num() const
Definition PropertyPairsMap.h:123
Definition UnrealString.h.inl:34
BuilderType & AppendChar(AppendedCharType Char)
Definition StringBuilder.h:260
const CharType * ToString() UE_LIFETIMEBOUND
Definition StringBuilder.h:135
BuilderType & Append(const OtherCharType *const String, const int32 Length)
Definition StringBuilder.h:238
void RemoveSuffix(int32 InCount)
Definition StringBuilder.h:230
Definition StringBuilder.h:509
Definition OverrideVoidReturnInvoker.h:16