Files
UnrealEngineUWP/Engine/Source/Programs/UnrealHeaderTool/Private/FileLineException.cpp
Ryan Durand 74c879d5f3 Updating copyrights for Engine Programs.
#rnx
#rb none
#jira none

#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869242 in //Fortnite/Release-12.00/... via CL 10869536
#ROBOMERGE-BOT: FORTNITE (Main -> Dev-EngineMerge) (v613-10869866)

[CL 10870960 by Ryan Durand in Main branch]
2019-12-26 23:06:02 -05:00

46 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "FileLineException.h"
#include "UnrealHeaderTool.h"
void VARARGS FFileLineException::ThrowfImpl(FString&& InFilename, int32 InLine, const TCHAR* Fmt, ...)
{
int32 BufferSize = 512;
TCHAR StartingBuffer[512];
TCHAR* Buffer = StartingBuffer;
int32 Result = -1;
// First try to print to a stack allocated location
GET_VARARGS_RESULT( Buffer, BufferSize, BufferSize-1, Fmt, Fmt, Result );
// If that fails, start allocating regular memory
if( Result == -1 )
{
Buffer = nullptr;
while(Result == -1)
{
BufferSize *= 2;
Buffer = (TCHAR*) FMemory::Realloc( Buffer, BufferSize * sizeof(TCHAR) );
GET_VARARGS_RESULT( Buffer, BufferSize, BufferSize-1, Fmt, Fmt, Result );
}
}
Buffer[Result] = 0;
FString ResultString(Buffer);
if( BufferSize != 512 )
{
FMemory::Free( Buffer );
}
throw FFileLineException(MoveTemp(ResultString), MoveTemp(InFilename), InLine);
}
FFileLineException::FFileLineException(FString&& InMessage, FString&& InFilename, int32 InLine)
: Message (MoveTemp(InMessage))
, Filename(MoveTemp(InFilename))
, Line (InLine)
{
}