UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UniversalObjectLocatorFragment.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "UObject/Class.h"
11#include "Templates/Function.h"
12#include "UniversalObjectLocatorFragment.generated.h"
13
14
34USTRUCT(BlueprintType)
36{
38
41
43 // Valid fragment delimiters are those that are allowable by RFC3986 for the query part (unreserved / pct-encoded / sub-delims / ":" / "@" / "/" / "?") excluding '&' which we use to separate fragments within a path
44 static constexpr FAsciiSet ValidFragmentDelimiters = "%!$'()*+,;=/?:@.~";
45 static constexpr FAsciiSet ValidFragmentPayloadCharacters = ValidFragmentTypeCharacters | ValidFragmentDelimiters;
46
48#if WITH_EDITORONLY_DATA
49 static constexpr SIZE_T SizeInMemory = 64;
50#else
51 static constexpr SIZE_T SizeInMemory = 32;
52#endif
53
54
62 template<typename T, typename ...ArgTypes>
64
65
73
79
82
85
89
93
99 UNIVERSALOBJECTLOCATOR_API friend uint32 GetTypeHash(const FUniversalObjectLocatorFragment& Fragment);
100public:
101
109
114 bool IsEmpty() const
115 {
116 return !FragmentType.IsValid();
117 }
118
119public:
120
125
131
137
138public:
139
145 UNIVERSALOBJECTLOCATOR_API void ToString(FStringBuilderBase& OutString) const;
146
155 UNIVERSALOBJECTLOCATOR_API FParseStringResult TryParseString(FStringView InString, const FParseStringParams& InParams);
156
165 UNIVERSALOBJECTLOCATOR_API FParseStringResult TryParseFragmentType(FStringView InString, const FParseStringParams& InParams);
166
175 UNIVERSALOBJECTLOCATOR_API FParseStringResult TryParseFragmentPayload(FStringView InString, const FParseStringParams& InParams);
176
177public:
178
185 template<typename T>
187
194 template<typename T>
196
204 template<typename T>
205 bool TryGetPayloadAs(UE::UniversalObjectLocator::TFragmentTypeHandle<T> InType, T*& OutData);
206
214 template<typename T>
215 bool TryGetPayloadAs(UE::UniversalObjectLocator::TFragmentTypeHandle<T> InType, const T*& OutData) const;
216
222 UNIVERSALOBJECTLOCATOR_API void* GetPayload();
223
229 UNIVERSALOBJECTLOCATOR_API const void* GetPayload() const;
230
237
243 UNIVERSALOBJECTLOCATOR_API UScriptStruct* GetFragmentStruct() const;
244
251
252public:
253
254 /*~ Begin TStructOpsTypeTraits implementation */
256 UNIVERSALOBJECTLOCATOR_API void AddStructReferencedObjects(FReferenceCollector& Collector);
257 UNIVERSALOBJECTLOCATOR_API bool ExportTextItem(FString& ValueStr, const FUniversalObjectLocatorFragment& DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope) const;
258 UNIVERSALOBJECTLOCATOR_API bool ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText, FArchive* InSerializingArchive = nullptr);
259 UNIVERSALOBJECTLOCATOR_API bool SerializeFromMismatchedTag(const FPropertyTag& Tag, FStructuredArchive::FSlot Slot);
260 UNIVERSALOBJECTLOCATOR_API void GetPreloadDependencies(TArray<UObject*>& OutDeps);
261 /*~ End TStructOpsTypeTraits implementation */
262
263protected:
264
265
267#if DO_CHECK
269 UNIVERSALOBJECTLOCATOR_API void CheckPayloadType(UScriptStruct* TypeToCompare) const;
270#else
271 FORCEINLINE static constexpr void CheckPayloadType(void* TypeToCompare)
272 {
273 }
274#endif
275
276protected:
277
289 {
290#if UE_UNIVERSALOBJECTLOCATOR_DEBUG
293#endif
295 void* Payload;
296 };
297
304 UNIVERSALOBJECTLOCATOR_API FAllocatedPayload AllocatePayload(size_t Size, size_t Alignment);
305
309 void DefaultConstructPayload(const UE::UniversalObjectLocator::FFragmentType& InFragmentType);
310
314 void DestroyPayload();
315
316private:
317
318 uint32 GetDebugHeaderOffset() const
319 {
320 // Special case for DebugHeaderSizeLog2==0 which signifies no offset rather than 2^0 = 1 byte.
321 // We do this using a branchless bitmask that always unsets the first bit (which can never be set, because we always return a power of 2 > 1)
322 return (1ul << DebugHeaderSizeLog2) & (~1ul);
323 }
324
325#if UE_UNIVERSALOBJECTLOCATOR_DEBUG
326 /*~ Utility symbol name to guarantee that FFragmentType can be resolved within the context of a FUniversalObjectLocatorFragment within natvis expressions */
327 struct FDebuggableFragmentType
328 {
330 };
331 struct FDebuggableFragment
332 {
334 };
335#endif
336
337 /*
338 * Payload data - implicitly aligned to a 8 byte boundary since it's the first member.
339 * Given payload type T, this is either a type-erased T() value (where bIsInline==1),
340 * or a T* to a heap allocated T (where bIsInline==0)
341 * SizeInMemory is specifically defined by the desired overall size of FUniversalObjectLocatorFragment::SizeInMemory, minus space for other members
342 */
343 uint8 Data[SizeInMemory-2];
344
347
348 /*~ 1 Byte of flags */
350 uint8 bIsInitialized : 1;
352 uint8 bIsInline : 1;
354 uint8 DebugHeaderSizeLog2 : 6;
355};
356
357template<>
370
371
372template<typename T, typename ...ArgTypes>
374 : FragmentType(InHandle)
375 , bIsInitialized(0)
376 , DebugHeaderSizeLog2(0)
377{
378 using namespace UE::UniversalObjectLocator;
379
380 checkf(InHandle, TEXT("Attempting to construct a new fragment from an invalid fragment type handle - was it registered?"));
381
382 FAllocatedPayload Allocation = AllocatePayload(sizeof(T), alignof(T));
383
384#if UE_UNIVERSALOBJECTLOCATOR_DEBUG
385 // Initialize the fragment vftable if necessary. We can do this without needing the fragment type since we know the type
386 new (Allocation.DebugVFTablePtr) TFragmentPayload<T>;
387#endif
388
389 // Placement new the payload
390 new (Allocation.Payload) T{ Forward<ArgTypes>(InArgs)... };
391}
392
393template<typename T>
395{
396 if (FragmentType.IsValid() && ensureMsgf(FragmentType == InType, TEXT("Type mismatch when accessing payload data!")))
397 {
398 return static_cast<T*>(GetPayload());
399 }
400 return nullptr;
401}
402
403template<typename T>
408
409template<typename T>
411{
412 if (FragmentType.IsValid() && FragmentType == InType)
413 {
414 OutData = static_cast<T*>(GetPayload());
415 return true;
416 }
417 return false;
418}
419
420template<typename T>
422{
423 if (FragmentType.IsValid() && FragmentType == InType)
424 {
425 OutData = static_cast<const T*>(GetPayload());
426 return true;
427 }
428 return false;
429}
430
431
433USTRUCT()
438
439
440template<typename PayloadType>
442{
444 : FUniversalObjectLocatorFragment(PayloadType::FragmentType)
445 {
446 }
447
452
453 template<typename ...ArgTypes>
455 : FUniversalObjectLocatorFragment(PayloadType::FragmentType, Forward<ArgTypes>(InArgs)...)
456 {
457 }
458
459 template<typename ...ArgTypes>
464
465 PayloadType* GetPayload()
466 {
467 CheckPayloadType(PayloadType::StaticStruct());
468 return static_cast<PayloadType*>(FUniversalObjectLocatorFragment::GetPayload());
469 }
470
471 const PayloadType* GetPayload() const
472 {
473 CheckPayloadType(PayloadType::StaticStruct());
474 return static_cast<const PayloadType*>(FUniversalObjectLocatorFragment::GetPayload());
475 }
476};
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
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
bool TryParseString(FFrameRate &OutFrameRate, const TCHAR *InString)
Definition FrameRate.cpp:343
UE_FORCEINLINE_HINT bool operator!=(const FIndexedPointer &Other) const
Definition LockFreeList.h:76
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
uint32 Size
Definition VulkanMemory.cpp:4034
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition AsciiSet.h:30
Definition OutputDevice.h:133
Definition UObjectGlobals.h:2492
Definition StructuredArchiveSlots.h:52
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition Object.h:95
Definition Class.h:1720
Definition UniversalObjectLocator.Build.cs:6
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
Type
Definition PawnAction_Move.h:11
Definition AnimInstanceLocatorFragment.cpp:19
Definition AdvancedWidgetsModule.cpp:13
Definition PropertyTag.h:38
Definition UniversalObjectLocatorFragment.h:435
Definition UniversalObjectLocatorFragment.h:289
void * DebugVFTablePtr
Definition UniversalObjectLocatorFragment.h:292
void * Payload
Definition UniversalObjectLocatorFragment.h:295
Definition UniversalObjectLocatorFragment.h:36
static FORCEINLINE constexpr void CheckPayloadType(void *TypeToCompare)
Definition UniversalObjectLocatorFragment.h:271
UNIVERSALOBJECTLOCATOR_API void * GetPayload()
Definition UniversalObjectLocatorFragment.cpp:486
UNIVERSALOBJECTLOCATOR_API FAllocatedPayload AllocatePayload(size_t Size, size_t Alignment)
Definition UniversalObjectLocatorFragment.cpp:502
T * GetPayloadAs(UE::UniversalObjectLocator::TFragmentTypeHandle< T > InType)
Definition UniversalObjectLocatorFragment.h:394
UNIVERSALOBJECTLOCATOR_API FUniversalObjectLocatorFragment()
Definition UniversalObjectLocatorFragment.cpp:120
bool TryGetPayloadAs(UE::UniversalObjectLocator::TFragmentTypeHandle< T > InType, T *&OutData)
Definition UniversalObjectLocatorFragment.h:410
bool IsEmpty() const
Definition UniversalObjectLocatorFragment.h:114
Definition StructOpsTypeTraits.h:11
@ WithAddStructReferencedObjects
Definition StructOpsTypeTraits.h:22
@ WithIdenticalViaEquality
Definition StructOpsTypeTraits.h:18
@ WithCopy
Definition StructOpsTypeTraits.h:17
@ WithExportTextItem
Definition StructOpsTypeTraits.h:20
@ WithSerializer
Definition StructOpsTypeTraits.h:23
@ WithImportTextItem
Definition StructOpsTypeTraits.h:21
Definition StructOpsTypeTraits.h:46
Definition UniversalObjectLocatorFragment.h:442
TUniversalObjectLocatorFragment(UE::UniversalObjectLocator::TFragmentTypeHandle< PayloadType > InHandle, ArgTypes &&...InArgs)
Definition UniversalObjectLocatorFragment.h:460
TUniversalObjectLocatorFragment(UE::UniversalObjectLocator::TFragmentTypeHandle< PayloadType > InHandle)
Definition UniversalObjectLocatorFragment.h:448
PayloadType * GetPayload()
Definition UniversalObjectLocatorFragment.h:465
TUniversalObjectLocatorFragment()
Definition UniversalObjectLocatorFragment.h:443
TUniversalObjectLocatorFragment(ArgTypes &&...InArgs)
Definition UniversalObjectLocatorFragment.h:454
const PayloadType * GetPayload() const
Definition UniversalObjectLocatorFragment.h:471
Definition UniversalObjectLocatorFragmentTypeHandle.h:19
bool IsValid() const
Definition UniversalObjectLocatorFragmentTypeHandle.h:36
Definition UniversalObjectLocatorFragmentType.h:70
Definition UniversalObjectLocatorStringParams.h:26
Definition UniversalObjectLocatorStringParams.h:43
Definition UniversalObjectLocatorResolveParams.h:47
Definition UniversalObjectLocatorResolveParams.h:205
Definition UniversalObjectLocatorFragmentDebugging.h:23
Definition UniversalObjectLocatorFragmentDebugging.h:35
Definition UniversalObjectLocatorFragmentTypeHandle.h:84