UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PrimaryAssetId.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7#include "HAL/Platform.h"
11#include "Templates/TypeHash.h"
12#include "UObject/NameTypes.h"
14#include "UObject/UnrealNames.h"
15
16#include "PrimaryAssetId.generated.h"
17
18class FCbWriter;
19class FOutputDevice;
20class UObject;
21
26USTRUCT(BlueprintType)
28{
30
31
32 FPrimaryAssetType() = default;
33 FPrimaryAssetType(FName InName) : Name(InName) {}
34 FPrimaryAssetType(EName InName) : Name(FName(InName)) {}
35 FPrimaryAssetType(const WIDECHAR* InName) : Name(FName(InName)) {}
36 FPrimaryAssetType(const ANSICHAR* InName) : Name(FName(InName)) {}
37
42
44 operator FName&() { return Name; }
45 operator const FName&() const { return Name; }
46
48 FName GetName() const
49 {
50 return Name;
51 }
52
54 {
55 return Name == Other.Name;
56 }
57
59 {
60 return Name != Other.Name;
61 }
62
64 bool IsValid() const
65 {
66 return Name != NAME_None;
67 }
68
70 FString ToString() const
71 {
72 return Name.ToString();
73 }
74
76 void AppendString(FStringBuilderBase& Builder) const
77 {
78 Name.AppendString(Builder);
79 }
80
82 bool ExportTextItem(FString& ValueStr, FPrimaryAssetType const& DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope) const;
83 bool ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText);
84 bool SerializeFromMismatchedTag(struct FPropertyTag const& Tag, FStructuredArchive::FSlot Slot);
85
86 friend inline uint32 GetTypeHash(const FPrimaryAssetType& Key)
87 {
88 return GetTypeHash(Key.Name);
89 }
90
92 {
93 return Name.LexicalLess(Other.Name);
94 }
95
96 bool FastLess(const FPrimaryAssetType& Other) const
97 {
98 return Name.FastLess(Other.Name);
99 }
100
101private:
103 UPROPERTY(EditAnywhere, SaveGame, BlueprintReadWrite, Category = PrimaryAssetType, meta=(AllowPrivateAccess))
104 FName Name;
105};
106
107template<>
120
124USTRUCT(BlueprintType)
126{
128
129
131 UPROPERTY(EditAnywhere, SaveGame, BlueprintReadWrite, Category = PrimaryAssetId)
132 FPrimaryAssetType PrimaryAssetType;
135 UPROPERTY(EditAnywhere, SaveGame, BlueprintReadWrite, Category = PrimaryAssetId)
136 FName PrimaryAssetName;
137
139 static COREUOBJECT_API const FName PrimaryAssetTypeTag;
140 static COREUOBJECT_API const FName PrimaryAssetNameTag;
142 static COREUOBJECT_API const FName PrimaryAssetDisplayNameTag;
143
144 FPrimaryAssetId() = default;
146 : PrimaryAssetType(InAssetType), PrimaryAssetName(InAssetName)
147 {}
148
149 static COREUOBJECT_API FPrimaryAssetId ParseTypeAndName(const TCHAR* TypeAndName, uint32 Len);
150 static COREUOBJECT_API FPrimaryAssetId ParseTypeAndName(FName TypeAndName);
152 {
153 return ParseTypeAndName(*TypeAndName, static_cast<uint32>(TypeAndName.Len()));
154 }
155
156 explicit FPrimaryAssetId(const FString& TypeAndName)
157 : FPrimaryAssetId(ParseTypeAndName(TypeAndName))
158 {}
159
164
166 bool IsValid() const
167 {
168 return PrimaryAssetType != NAME_None && PrimaryAssetName != NAME_None;
169 }
170
172 FString ToString() const
173 {
174 TStringBuilder<256> Builder;
175 AppendString(Builder);
176 return FString::ConstructFromPtrSize(Builder.GetData(), Builder.Len());
177 }
178
180 void AppendString(FStringBuilderBase& Builder) const
181 {
182 if (IsValid())
183 {
184 PrimaryAssetType.AppendString(Builder);
185 Builder << TEXT(":");
186 PrimaryAssetName.AppendString(Builder);
187 }
188 }
189
191 static FPrimaryAssetId FromString(const FString& String)
192 {
193 return FPrimaryAssetId(String);
194 }
195
197 {
198 return PrimaryAssetType == Other.PrimaryAssetType && PrimaryAssetName == Other.PrimaryAssetName;
199 }
200
202 {
203 return PrimaryAssetType != Other.PrimaryAssetType || PrimaryAssetName != Other.PrimaryAssetName;
204 }
205
207 {
208 Ar << Other.PrimaryAssetType;
209 Ar << Other.PrimaryAssetName;
210 return Ar;
211 }
212
214 bool ExportTextItem(FString& ValueStr, FPrimaryAssetId const& DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope) const;
215 bool ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText);
216 bool SerializeFromMismatchedTag(struct FPropertyTag const& Tag, FStructuredArchive::FSlot Slot);
217
218 friend inline uint32 GetTypeHash(const FPrimaryAssetId& Key)
219 {
220 uint32 Hash = 0;
221
222 Hash = HashCombine(Hash, GetTypeHash(Key.PrimaryAssetType));
223 Hash = HashCombine(Hash, GetTypeHash(Key.PrimaryAssetName));
224 return Hash;
225 }
226
227private:
229};
230
231template<>
244
#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::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void SerializeForLog(FCbWriter &Writer, const FIoStatus &Status)
Definition IoStatus.cpp:107
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
COREUOBJECT_API FStringBuilderBase & operator<<(FStringBuilderBase &Builder, const FPrimaryAssetId &Id)
Definition PrimaryAssetId.cpp:136
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
EName
Definition UnrealNames.h:16
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition CompactBinaryWriter.h:68
Definition NameTypes.h:617
Definition OutputDevice.h:133
Definition StructuredArchiveSlots.h:52
CharType * GetData() UE_LIFETIMEBOUND
Definition StringBuilder.h:120
int32 Len() const
Definition StringBuilder.h:114
Definition StringBuilder.h:509
Definition Object.h:95
Definition PrimaryAssetId.h:126
FPrimaryAssetId(const FString &TypeAndName)
Definition PrimaryAssetId.h:156
bool IsValid() const
Definition PrimaryAssetId.h:166
void AppendString(FStringBuilderBase &Builder) const
Definition PrimaryAssetId.h:180
bool operator!=(const FPrimaryAssetId &Other) const
Definition PrimaryAssetId.h:201
static FPrimaryAssetId FromString(const FString &String)
Definition PrimaryAssetId.h:191
static FPrimaryAssetId ParseTypeAndName(const FString &TypeAndName)
Definition PrimaryAssetId.h:151
friend FArchive & operator<<(FArchive &Ar, FPrimaryAssetId &Other)
Definition PrimaryAssetId.h:206
FPrimaryAssetId & operator=(FPrimaryAssetId &&)=default
friend uint32 GetTypeHash(const FPrimaryAssetId &Key)
Definition PrimaryAssetId.h:218
FPrimaryAssetId & operator=(const FPrimaryAssetId &)=default
FPrimaryAssetId(const FPrimaryAssetId &)=default
FString ToString() const
Definition PrimaryAssetId.h:172
FPrimaryAssetId(FPrimaryAssetId &&)=default
bool operator==(const FPrimaryAssetId &Other) const
Definition PrimaryAssetId.h:196
Definition PrimaryAssetId.h:28
bool FastLess(const FPrimaryAssetType &Other) const
Definition PrimaryAssetId.h:96
FPrimaryAssetType(FPrimaryAssetType &&)=default
FPrimaryAssetType & operator=(FPrimaryAssetType &&)=default
FPrimaryAssetType(const ANSICHAR *InName)
Definition PrimaryAssetId.h:36
bool LexicalLess(const FPrimaryAssetType &Other) const
Definition PrimaryAssetId.h:91
friend uint32 GetTypeHash(const FPrimaryAssetType &Key)
Definition PrimaryAssetId.h:86
bool operator==(const FPrimaryAssetType &Other) const
Definition PrimaryAssetId.h:53
FPrimaryAssetType(EName InName)
Definition PrimaryAssetId.h:34
FString ToString() const
Definition PrimaryAssetId.h:70
FPrimaryAssetType & operator=(const FPrimaryAssetType &)=default
bool IsValid() const
Definition PrimaryAssetId.h:64
FPrimaryAssetType(const FPrimaryAssetType &)=default
void AppendString(FStringBuilderBase &Builder) const
Definition PrimaryAssetId.h:76
FPrimaryAssetType(const WIDECHAR *InName)
Definition PrimaryAssetId.h:35
bool operator!=(const FPrimaryAssetType &Other) const
Definition PrimaryAssetId.h:58
FName GetName() const
Definition PrimaryAssetId.h:48
Definition PropertyTag.h:38
Definition StructOpsTypeTraits.h:11
@ WithStructuredSerializeFromMismatchedTag
Definition StructOpsTypeTraits.h:29
@ WithZeroConstructor
Definition StructOpsTypeTraits.h:14
@ WithIdenticalViaEquality
Definition StructOpsTypeTraits.h:18
@ WithCopy
Definition StructOpsTypeTraits.h:17
@ WithExportTextItem
Definition StructOpsTypeTraits.h:20
@ WithImportTextItem
Definition StructOpsTypeTraits.h:21
Definition StructOpsTypeTraits.h:46