UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Linker.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"
7#include "Containers/Map.h"
8#include "Containers/Set.h"
10#include "CoreMinimal.h"
11#include "CoreTypes.h"
13#include "Logging/LogMacros.h"
20#include "UObject/NameTypes.h"
24
25class FArchive;
27class FLinkerLoad;
28class FPackagePath;
30class UObject;
31class UPackage;
32class UPackageMap;
34struct FGuid;
35struct FPackageSaveInfo;
37template <typename FuncType> class TFunctionRef;
38
40
62
63
65{
66public:
81
88 {
89 check(!Index.IsNull());
90 if (Index.IsImport())
91 {
92 return Imp(Index);
93 }
94 else
95 {
96 return Exp(Index);
97 }
98 }
105 {
106 check(!Index.IsNull());
107 if (Index.IsImport())
108 {
109 return Imp(Index);
110 }
111 else
112 {
113 return Exp(Index);
114 }
115 }
122 {
123 if (Index.IsImport())
124 {
125 return ImpPtr(Index);
126 }
127 else
128 {
129 return ExpPtr(Index);
130 }
131 }
132
139 {
140 check(Index.IsImport() && ImportMap.IsValidIndex(Index.ToImport()));
141 return ImportMap[Index.ToImport()];
142 }
144 {
145 check(Index.IsImport() && ImportMap.IsValidIndex(Index.ToImport()));
146 return ImportMap[Index.ToImport()];
147 }
154 {
155 if (Index.IsImport())
156 {
157 check(ImportMap.IsValidIndex(Index.ToImport()));
158 return &ImportMap[Index.ToImport()];
159 }
160 return nullptr;
161 }
162
169 {
170 check(Index.IsExport() && ExportMap.IsValidIndex(Index.ToExport()));
171 return ExportMap[Index.ToExport()];
172 }
174 {
175 check(Index.IsExport() && ExportMap.IsValidIndex(Index.ToExport()));
176 return ExportMap[Index.ToExport()];
177 }
184 {
185 if (Index.IsExport())
186 {
187 check(ExportMap.IsValidIndex(Index.ToExport()));
188 return &ExportMap[Index.ToExport()];
189 }
190 return nullptr;
191 }
192
196
205 COREUOBJECT_API FString GetImportPathName(int32 ImportIndex);
214 FString GetImportPathName(FPackageIndex PackageIndex)
215 {
216 if (PackageIndex.IsImport())
217 {
218 return GetImportPathName(PackageIndex.ToImport());
219 }
220 return FString();
221 }
233 COREUOBJECT_API FString GetExportPathName(const FString& RootPackagePath, int32 ExportIndex, bool bResolveForcedExports = false);
234
243 COREUOBJECT_API FString GetImportFullName(int32 ImportIndex);
251 FString GetImportFullName(FPackageIndex PackageIndex)
252 {
253 if (PackageIndex.IsImport())
254 {
255 return GetImportFullName(PackageIndex.ToImport());
256 }
257 return FString();
258 }
259
270 COREUOBJECT_API FString GetExportFullName(const FString& RootPackagePath, int32 ExportIndex, bool bResolveForcedExports = false);
271
278
285 bool ResourceIsIn(FPackageIndex LinkerIndex, FPackageIndex OuterIndex) const;
286
294
300 bool ImportIsInAnyExport(int32 ImportIndex) const;
301
307 bool AnyExportIsInImport(int32 ImportIndex) const;
308
314 bool AnyExportShareOuterWithImport(int32 ImportIndex) const;
315
328 {
329 if (PackageIndex.IsExport())
330 {
331 return GetExportClassName(PackageIndex.ToExport());
332 }
333 return FName();
334 }
341 {
342 return ImportMap[ImportIdx].ClassName;
343 }
350 {
351 if (PackageIndex.IsImport())
352 {
353 return GetImportClassName(PackageIndex.ToImport());
354 }
355 return FName();
356 }
364 {
365 if (PackageIndex.IsImport())
366 {
367 return GetImportClassName(PackageIndex);
368 }
369 else if (PackageIndex.IsExport())
370 {
371 return GetExportClassName(PackageIndex);
372 }
373 return FName();
374 }
375
378};
379
380/*----------------------------------------------------------------------------
381 FLinker.
382----------------------------------------------------------------------------*/
383namespace ELinkerType
384{
385 enum Type
386 {
389 Save
390 };
391}
392
397class FLinker : public FLinkerTables
398{
399private:
400
401 ELinkerType::Type LinkerType;
402
403public:
404
407
410
413
416
419
422
425
428
431
432 UE_DEPRECATED(5.6, "No longer supported. Contact Epic if you need this functionality.")
433 class FSHA1* ScriptSHA = nullptr;
434
437
438 virtual ~FLinker();
439
441 {
442 return LinkerType;
443 }
444
446 virtual FString GetDebugName() const;
447
453 void Serialize(FArchive& Ar);
454
466 COREUOBJECT_API FString GetExportPathName(int32 ExportIndex, const TCHAR* FakeRoot = nullptr, bool bResolveForcedExports = false);
467
479 FString GetExportPathName(FPackageIndex PackageIndex, const TCHAR* FakeRoot = nullptr, bool bResolveForcedExports = false)
480 {
481 if (PackageIndex.IsExport())
482 {
484 }
485 return FString();
486 }
487
496 FString GetPathName(FPackageIndex PackageIndex)
497 {
498 if (PackageIndex.IsImport())
499 {
500 return GetImportPathName(PackageIndex);
501 }
502 else if (PackageIndex.IsExport())
503 {
504 return GetExportPathName(PackageIndex);
505 }
506 return FString();
507 }
508
519 COREUOBJECT_API FString GetExportFullName(int32 ExportIndex, const TCHAR* FakeRoot = nullptr, bool bResolveForcedExports = false);
520
531 FString GetExportFullName(FPackageIndex PackageIndex, const TCHAR* FakeRoot = nullptr, bool bResolveForcedExports = false)
532 {
533 if (PackageIndex.IsExport())
534 {
536 }
537 return FString();
538 }
539
547 FString GetFullImpExpName(FPackageIndex PackageIndex)
548 {
549 if (PackageIndex.IsImport())
550 {
551 return GetImportFullName(PackageIndex);
552 }
553 else if (PackageIndex.IsExport())
554 {
555 return GetExportFullName(PackageIndex);
556 }
557 return FString();
558 }
559
560 UE_DEPRECATED(5.6, "No longer supported. Contact Epic if you need this functionality.")
562 UE_DEPRECATED(5.6, "No longer supported. Contact Epic if you need this functionality.")
564 UE_DEPRECATED(5.6, "No longer supported. Contact Epic if you need this functionality.")
566
573 {
574 if (Export.bExportLoadFailed || Export.bWasFiltered)
575 {
576 return true;
577 }
578#if WITH_EDITOR
579 if (!Export.bNotAlwaysLoadedForEditorGame) // Always load, even if is editor only
580 {
581 return false;
582 }
583#endif
584 if (FilterClientButNotServer && Export.bNotForServer) // "we are a dedicated server"
585 {
586 return true;
587 }
588 if (FilterServerButNotClient && Export.bNotForClient) // "we are a client only"
589 {
590 return true;
591 }
592 if (Export.ThisIndex.IsNull()) // Export is invalid and shouldn't be processed.
593 {
594 return true;
595 }
596 return false;
597 }
598
599};
600
601
602
603template<typename T>
605{
606 return Src && T::StaticType() == Src->GetType() ? (T*)Src : nullptr;
607}
608
609template<typename T>
610inline T* CastChecked(FLinker* Src)
611{
612 T* LinkerCastResult = Src && T::StaticType() == Src->GetType() ? (T*)Src : nullptr;
614 return LinkerCastResult;
615}
616
617/*-----------------------------------------------------------------------------
618 Lazy loading.
619-----------------------------------------------------------------------------*/
620
625
629#define LLF_None 0x00000000
633#define LLF_PayloadInSeparateFile 0x00000001
639#define LLF_SerializeCompressed 0x00000002
643#define LLF_AllFlags 0xFFFFFFFF
644
645/*-----------------------------------------------------------------------------
646 Global functions
647-----------------------------------------------------------------------------*/
648
660UE_DEPRECATED(5.4, "Use GetPackageLinker instead")
662UE_DEPRECATED(5.4, "Use GetPackageLinker instead")
663COREUOBJECT_API FLinkerLoad* LoadPackageLinker(UPackage* InOuter, const FPackagePath& PackagePath, uint32 LoadFlags = LOAD_None, UPackageMap* Sandbox = nullptr, FArchive* InReaderOverride = nullptr);
664
678COREUOBJECT_API FLinkerLoad* GetPackageLinker(UPackage* InOuter, const FPackagePath& PackagePath, uint32 LoadFlags, UPackageMap* Sandbox, FArchive* InReaderOverride = nullptr, FUObjectSerializeContext** InOutLoadContext = nullptr, FLinkerLoad* ImportLinker = nullptr, const FLinkerInstancingContext* InstancingContext = nullptr);
679
681
687
695
696
703
712
720
723
726
727/*
728 * Ensure all data that can be loaded from the linker (thumbnails, bulk data) is loaded, in preparation for saving out the given package
729 *
730 * @param Package The the package for which the linker should be fully loaded
731 */
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
UE_FORCEINLINE_HINT T * Cast(FLinker *Src)
Definition Linker.h:604
uint32 ELazyLoaderFlags
Definition Linker.h:624
COREUOBJECT_API void ConditionalFlushAsyncLoadingForSave(UPackage *InPackage)
Definition Linker.cpp:875
COREUOBJECT_API void DeleteLoaders()
Definition Linker.cpp:918
COREUOBJECT_API void ResetLinkerExports(UPackage *InPackage)
Definition Linker.cpp:816
COREUOBJECT_API FLinkerLoad * GetPackageLinker(UPackage *InOuter, const FPackagePath &PackagePath, uint32 LoadFlags, UPackageMap *Sandbox, FArchive *InReaderOverride=nullptr, FUObjectSerializeContext **InOutLoadContext=nullptr, FLinkerLoad *ImportLinker=nullptr, const FLinkerInstancingContext *InstancingContext=nullptr)
Definition Linker.cpp:628
COREUOBJECT_API FLinkerLoad * LoadPackageLinker(UPackage *InOuter, const FPackagePath &PackagePath, uint32 LoadFlags, UPackageMap *Sandbox, FArchive *InReaderOverride, TFunctionRef< void(FLinkerLoad *LoadedLinker)> LinkerLoadedCallback)
Definition Linker.cpp:802
COREUOBJECT_API void ResetLoaders(UObject *InOuter)
Definition Linker.cpp:842
COREUOBJECT_API FString GetPrestreamPackageLinkerName(const TCHAR *InLongPackageName, bool bSkipIfExists=true)
Definition Linker.cpp:566
T * CastChecked(FLinker *Src)
Definition Linker.h:610
COREUOBJECT_API void ResetLoadersForSave(UPackage *Package, const TCHAR *Filename)
Definition Linker.cpp:883
COREUOBJECT_API void EnsureLoadingComplete(UPackage *Package)
Definition Linker.cpp:928
COREUOBJECT_API void DeleteLoader(FLinkerLoad *Loader)
Definition Linker.cpp:923
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
@ LOAD_None
No flags.
Definition ObjectMacros.h:69
if(Failed) console_printf("Failed.\n")
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 LinkerInstancingContext.h:99
Definition LinkerLoad.h:124
Definition Linker.h:65
COREUOBJECT_API void SerializeSearchableNamesMap(FArchive &Ar)
Definition Linker.cpp:109
TArray< FObjectImport > ImportMap
Definition Linker.h:68
bool DoResourcesShareOutermost(FPackageIndex LinkerIndexLHS, FPackageIndex LinkerIndexRHS) const
Definition Linker.cpp:339
COREUOBJECT_API FString GetExportPathName(const FString &RootPackagePath, int32 ExportIndex, bool bResolveForcedExports=false)
Definition Linker.cpp:259
FString GetImportFullName(FPackageIndex PackageIndex)
Definition Linker.h:251
bool ResourceIsIn(FPackageIndex LinkerIndex, FPackageIndex OuterIndex) const
Definition Linker.cpp:325
bool AnyExportIsInImport(int32 ImportIndex) const
Definition Linker.cpp:359
TArray< FCellImport > CellImportMap
Definition Linker.h:72
FObjectResource & ImpExp(FPackageIndex Index)
Definition Linker.h:87
FName GetClassName(FPackageIndex PackageIndex)
Definition Linker.h:363
FObjectImport * ImpPtr(FPackageIndex Index)
Definition Linker.h:153
COREUOBJECT_API FString GetImportFullName(int32 ImportIndex)
Definition Linker.cpp:301
FName GetImportClassName(int32 ImportIdx)
Definition Linker.h:340
COREUOBJECT_API FString GetExportFullName(const FString &RootPackagePath, int32 ExportIndex, bool bResolveForcedExports=false)
Definition Linker.cpp:306
FName GetExportClassName(FPackageIndex PackageIndex)
Definition Linker.h:327
COREUOBJECT_API FName GetExportClassName(int32 ExportIdx)
Definition Linker.cpp:131
FName GetImportClassName(FPackageIndex PackageIndex)
Definition Linker.h:349
FObjectImport const & Imp(FPackageIndex Index) const
Definition Linker.h:143
bool AnyExportShareOuterWithImport(int32 ImportIndex) const
Definition Linker.cpp:372
COREUOBJECT_API SIZE_T GetAllocatedSize() const
Definition Linker.cpp:144
FPackageIndex ResourceGetOutermost(FPackageIndex LinkerIndex) const
Definition Linker.cpp:314
FObjectExport const & Exp(FPackageIndex Index) const
Definition Linker.h:173
TArray< TArray< FPackageIndex > > DependsMap
Definition Linker.h:76
bool ImportIsInAnyExport(int32 ImportIndex) const
Definition Linker.cpp:344
TMap< FPackageIndex, TArray< FName > > SearchableNamesMap
Definition Linker.h:80
FObjectExport & Exp(FPackageIndex Index)
Definition Linker.h:168
TArray< FObjectExport > ExportMap
Definition Linker.h:70
FObjectResource * ImpExpPtr(FPackageIndex Index)
Definition Linker.h:121
COREUOBJECT_API FString GetImportPathName(int32 ImportIndex)
Definition Linker.cpp:215
FString GetImportPathName(FPackageIndex PackageIndex)
Definition Linker.h:214
FObjectExport * ExpPtr(FPackageIndex Index)
Definition Linker.h:183
FObjectImport & Imp(FPackageIndex Index)
Definition Linker.h:138
FObjectResource const & ImpExp(FPackageIndex Index) const
Definition Linker.h:104
TArray< FCellExport > CellExportMap
Definition Linker.h:74
TArray< FName > SoftPackageReferenceList
Definition Linker.h:78
Definition Linker.h:398
TMap< FPackageIndex, UE::Serialization::Private::FImportTypeHierarchy > ImportTypeHierarchies
Definition Linker.h:424
FString GetPathName(FPackageIndex PackageIndex)
Definition Linker.h:496
void GetScriptSHAKey(uint8 *OutKey)
Definition Linker.cpp:427
bool FilterServerButNotClient
Definition Linker.h:430
bool FilterExport(const FObjectExport &Export)
Definition Linker.h:572
TArray< FGatherableTextData > GatherableTextDataMap
Definition Linker.h:418
FPackageFileSummary Summary
Definition Linker.h:409
bool FilterClientButNotServer
Definition Linker.h:427
UPackage * LinkerRoot
Definition Linker.h:406
virtual FString GetDebugName() const
Definition Linker.cpp:185
TArray< FSoftObjectPath > SoftObjectPathList
Definition Linker.h:415
void UpdateScriptSHAKey(const TArray< uint8 > &ScriptCode)
Definition Linker.cpp:417
COREUOBJECT_API FString GetExportFullName(int32 ExportIndex, const TCHAR *FakeRoot=nullptr, bool bResolveForcedExports=false)
Definition Linker.cpp:396
TArray< FObjectDataResource > DataResourceMap
Definition Linker.h:421
class FSHA1 * ScriptSHA
Definition Linker.h:433
TArray< FNameEntryId > NameMap
Definition Linker.h:412
COREUOBJECT_API FString GetExportPathName(int32 ExportIndex, const TCHAR *FakeRoot=nullptr, bool bResolveForcedExports=false)
Definition Linker.cpp:386
FString GetExportFullName(FPackageIndex PackageIndex, const TCHAR *FakeRoot=nullptr, bool bResolveForcedExports=false)
Definition Linker.h:531
void StartScriptSHAGeneration()
Definition Linker.cpp:406
UE_FORCEINLINE_HINT ELinkerType::Type GetType() const
Definition Linker.h:440
FString GetExportPathName(FPackageIndex PackageIndex, const TCHAR *FakeRoot=nullptr, bool bResolveForcedExports=false)
Definition Linker.h:479
FString GetFullImpExpName(FPackageIndex PackageIndex)
Definition Linker.h:547
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition ObjectResource.h:44
UE_FORCEINLINE_HINT bool IsImport() const
Definition ObjectResource.h:68
int32 ToExport() const
Definition ObjectResource.h:89
int32 ToImport() const
Definition ObjectResource.h:83
UE_FORCEINLINE_HINT bool IsExport() const
Definition ObjectResource.h:73
Definition PackagePath.h:89
Definition UObjectGlobals.h:2492
Definition SecureHash.h:314
Definition StructuredArchiveSlots.h:52
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition Object.h:95
Definition CoreNet.h:191
Definition Package.h:216
Definition Linker.h:384
Type
Definition Linker.h:386
@ Load
Definition Linker.h:388
@ Save
Definition Linker.h:389
@ None
Definition Linker.h:387
U16 Index
Definition radfft.cpp:71
Definition Linker.h:45
int32 CompressedSize
Definition Linker.h:56
int32 UncompressedOffset
Definition Linker.h:50
FCompressedChunk()
Definition Linker.cpp:60
friend COREUOBJECT_API FArchive & operator<<(FArchive &Ar, FCompressedChunk &Chunk)
Definition Linker.cpp:69
int32 CompressedOffset
Definition Linker.h:54
int32 UncompressedSize
Definition Linker.h:52
Definition GatherableTextData.h:47
Definition Guid.h:109
Definition ObjectResource.h:227
Definition ObjectResource.h:444
Definition ObjectResource.h:192
Definition PackageFileSummary.h:57
Definition SavePackage.h:52
Definition UObjectThreadContext.h:140