Files
UnrealEngineUWP/Engine/Source/Programs/UnrealHeaderTool/Private/StringUtils.cpp
Steve Robb 04c2da0cf2 #ttp 331467: Make UHT not depend on CoreUObject
#add FClass and FClasses added to encapsulate (and ultimately replace) UClass and FClassTree.
#add StringUtils contains a bunch of string-related functions which were in FHeaderParser for no real reason.
#change Replaced FClassTree with UHT and fixed up all the code which was affected.

#codereview robert.manuszewski

[CL 2045258 by Steve Robb in Main branch]
2014-04-23 18:42:01 -04:00

61 lines
1.7 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "UnrealHeaderTool.h"
#include "StringUtils.h"
FString GetClassNameWithPrefixRemoved(const FString InClassName)
{
const FString ClassPrefix = GetClassPrefix( InClassName );
if( !ClassPrefix.IsEmpty() )
{
return InClassName.Right(InClassName.Len() - ClassPrefix.Len());
}
return FString();
}
FString GetClassNameWithoutPrefix( const FString& InClassNameOrFilename )
{
// Check for header names (they don't come with a full path so we only search for the first dot)
const int32 DotIndex = InClassNameOrFilename.Find(TEXT("."));
if (DotIndex == INDEX_NONE)
{
const FString ClassPrefix = GetClassPrefix( InClassNameOrFilename );
return InClassNameOrFilename.Right(InClassNameOrFilename.Len() - ClassPrefix.Len());
}
else
{
return InClassNameOrFilename.Mid(0, DotIndex);
}
}
FString GetClassPrefix( const FString InClassName )
{
bool bIsLabledDeprecated;
return GetClassPrefix(InClassName, /*out*/ bIsLabledDeprecated);
}
FString GetClassPrefix( const FString InClassName, bool& bIsLabeledDeprecated )
{
FString ClassPrefix = InClassName.Left(1);
bIsLabeledDeprecated = false;
// First make sure the class name starts with a valid prefix
if( ClassPrefix == TEXT("I") ||
ClassPrefix == TEXT("A") ||
ClassPrefix == TEXT("U") )
{
// If it is a class prefix, check for deprecated class prefix
if( InClassName.Mid(1, 11) == TEXT("DEPRECATED_") )
{
bIsLabeledDeprecated = true;
return InClassName.Left(12);
}
}
// Otherwise check for struct prefix. If it's not a class or struct prefix, it's invalid
else if( ClassPrefix != TEXT("F") && ClassPrefix != TEXT("T") )
{
ClassPrefix = TEXT("");
}
return ClassPrefix;
}