Files
UnrealEngineUWP/Engine/Source/Programs/UHTLite/Private/HeaderProvider.cpp
fredric echols 841f4fe220 Refactored the following aspects of UHTLite:
* Globals in ClassMaps.cpp have been moved into FHeaderParser, FNativeClassHeaderGenerator, and UnrealHeaderTool_Main(). This is to illustrate how data flows through the program for further refactoring in the near future.

* Static variables have been removed from FHeaderParser.

* UnrealHeaderTool_Main() and associated functions have been moved into UnrealHeaderToolMain.cpp.

* Commented out several sections of code that are not required for code generation. This code will be refactored later.

[CL 14221982 by fredric echols in ue5-main branch]
2020-08-31 15:27:03 -04:00

53 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "HeaderProvider.h"
#include "UnrealHeaderTool.h"
#include "UnrealTypeDefinitionInfo.h"
#include "ClassMaps.h"
FHeaderProvider::FHeaderProvider(EHeaderProviderSourceType InType, FString&& InId)//, bool bInAutoInclude/* = false*/)
: Type(InType)
, Id(MoveTemp(InId))
, Cache(nullptr)
{
}
FUnrealSourceFile* FHeaderProvider::Resolve(const FUnrealSourceFiles& UnrealSourceFilesMap, const FTypeDefinitionInfoMap& TypeDefinitionInfoMap)
{
if (Type != EHeaderProviderSourceType::Resolved)
{
if (Type == EHeaderProviderSourceType::ClassName)
{
FName IdName(*Id, FNAME_Find);
if (const TSharedRef<FUnrealTypeDefinitionInfo>* Source = TypeDefinitionInfoMap.FindByName(IdName))
{
Cache = &(*Source)->GetUnrealSourceFile();
}
}
else if (const TSharedRef<FUnrealSourceFile>* Source = UnrealSourceFilesMap.Find(Id))
{
Cache = &Source->Get();
}
Type = EHeaderProviderSourceType::Resolved;
}
return Cache;
}
FString FHeaderProvider::ToString() const
{
return FString::Printf(TEXT("%s %s"), Type == EHeaderProviderSourceType::ClassName ? TEXT("class") : TEXT("file"), *Id);
}
const FString& FHeaderProvider::GetId() const
{
return Id;
}
bool operator==(const FHeaderProvider& A, const FHeaderProvider& B)
{
return A.Type == B.Type && A.Id == B.Id;
}