UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MappedName.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#include "CoreMinimal.h"
9#include "HAL/Platform.h"
10#include "Math/NumericLimits.h"
13#include "UObject/NameTypes.h"
14#include "UObject/UnrealNames.h"
15
16class FArchive;
17
22{
23 static constexpr uint32 InvalidIndex = ~uint32(0);
24 static constexpr uint32 IndexBits = 30u;
25 static constexpr uint32 IndexMask = (1u << IndexBits) - 1u;
26 static constexpr uint32 TypeMask = ~IndexMask;
27 static constexpr uint32 TypeShift = IndexBits;
28
29public:
30 enum class EType
31 {
32 Package,
34 Global
35 };
36
37 inline FMappedName() = default;
38
40 {
41 check(InIndex < (1 << TypeShift));
42 return FMappedName((uint32(InType) << TypeShift) | InIndex, InNumber);
43 }
44
46 {
47 return *reinterpret_cast<const FMappedName*>(&MinimalName);
48 }
49
51 {
52 // Not completely safe, relies on that no FName will have its Index and Number equal to Max_uint32
54 return MappedName.IsValid();
55 }
56
61
63 {
64 return *reinterpret_cast<const FMinimalName*>(this);
65 }
66
67 inline bool IsValid() const
68 {
69 return Index != InvalidIndex && Number != InvalidIndex;
70 }
71
72 inline EType GetType() const
73 {
74 return static_cast<EType>(uint32((Index & TypeMask) >> TypeShift));
75 }
76
77 inline bool IsGlobal() const
78 {
79 return ((Index & TypeMask) >> TypeShift) != 0;
80 }
81
82 inline uint32 GetIndex() const
83 {
84 return Index & IndexMask;
85 }
86
87 inline uint32 GetNumber() const
88 {
89 return Number;
90 }
91
92 inline bool operator!=(FMappedName Other) const
93 {
94 return Index != Other.Index || Number != Other.Number;
95 }
96
101
103
104private:
105 inline FMappedName(const uint32 InIndex, const uint32 InNumber)
106 : Index(InIndex)
107 , Number(InNumber) { }
108
109 uint32 Index = InvalidIndex;
110 uint32 Number = InvalidIndex;
111};
112
113/*
114 * Maps serialized name entries to names.
115 */
117{
118public:
119 inline int32 Num() const
120 {
121 return NameEntries.Num();
122 }
123
124 CORE_API void Load(FArchive& Ar, FMappedName::EType NameMapType);
125
127 {
128 check(MappedName.GetType() == NameMapType);
129 check(MappedName.GetIndex() < uint32(NameEntries.Num()));
130
131 return NameEntries[MappedName.GetIndex()].ToName(MappedName.GetNumber());
132 }
133
135 {
136 check(MappedName.GetType() == NameMapType);
137
138 uint32 Index = MappedName.GetIndex();
139 if (Index < uint32(NameEntries.Num()))
140 {
141 OutName = NameEntries[MappedName.GetIndex()].ToName(MappedName.GetNumber());
142
143 return true;
144 }
145
146 return false;
147 }
148
150 {
151 // Wasteful, looks up display name then discards it
153 }
154
156 RangedForConstIteratorType begin() const { return NameEntries.begin(); }
157 RangedForConstIteratorType end() const { return NameEntries.end(); }
158
159private:
160 TArray<FDisplayNameEntryId> NameEntries;
162};
#define check(expr)
Definition AssertionMacros.h:314
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
FORCEINLINE FMinimalName NameToMinimalName(FName InName)
Definition NameTypes.h:1602
FORCEINLINE FName MinimalNameToName(FMinimalName InName)
Definition NameTypes.h:1592
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition MappedName.h:22
bool operator!=(FMappedName Other) const
Definition MappedName.h:92
static FMappedName FromMinimalName(const FMinimalName &MinimalName)
Definition MappedName.h:45
static bool IsResolvedToMinimalName(const FMinimalName &MinimalName)
Definition MappedName.h:50
FMinimalName ToUnresolvedMinimalName() const
Definition MappedName.h:62
FMappedName()=default
static FName SafeMinimalNameToName(const FMinimalName &MinimalName)
Definition MappedName.h:57
FName ResolveName(TConstArrayView< FDisplayNameEntryId > Names) const
Definition MappedName.h:97
EType
Definition MappedName.h:31
bool IsGlobal() const
Definition MappedName.h:77
EType GetType() const
Definition MappedName.h:72
CORE_API friend FArchive & operator<<(FArchive &Ar, FMappedName &MappedName)
Definition MappedName.cpp:8
bool IsValid() const
Definition MappedName.h:67
uint32 GetNumber() const
Definition MappedName.h:87
static FMappedName Create(const uint32 InIndex, const uint32 InNumber, EType InType)
Definition MappedName.h:39
uint32 GetIndex() const
Definition MappedName.h:82
Definition MappedName.h:117
RangedForConstIteratorType end() const
Definition MappedName.h:157
FMinimalName GetMinimalName(const FMappedName &MappedName) const
Definition MappedName.h:149
FName GetName(const FMappedName &MappedName) const
Definition MappedName.h:126
RangedForConstIteratorType begin() const
Definition MappedName.h:156
int32 Num() const
Definition MappedName.h:119
bool TryGetName(const FMappedName &MappedName, FName &OutName) const
Definition MappedName.h:134
TArray< FDisplayNameEntryId >::RangedForConstIteratorType RangedForConstIteratorType
Definition MappedName.h:155
Definition NameTypes.h:617
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType end()
Definition Array.h:3391
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType begin()
Definition Array.h:3389
U16 Index
Definition radfft.cpp:71
Definition NameTypes.h:439
Definition Array.h:206