add linker basis

This commit is contained in:
Jan
2021-03-08 12:46:27 +01:00
parent 39a1485be6
commit e6a91c0305
14 changed files with 538 additions and 84 deletions

View File

@ -6,6 +6,7 @@
#include "Utils/Arguments/UsageInformation.h"
#include "ObjLoading.h"
#include "ObjWriting.h"
#include "Utils/FileUtils.h"
const CommandLineOption* const OPTION_HELP =
CommandLineOption::Builder::Create()
@ -84,66 +85,6 @@ UnlinkerArgs::UnlinkerArgs()
m_verbose = false;
}
bool UnlinkerArgs::ParsePathsString(const std::string& pathsString, std::set<std::string>& output)
{
std::ostringstream currentPath;
bool pathStart = true;
int quotationPos = 0; // 0 = before quotations, 1 = in quotations, 2 = after quotations
for (auto character : pathsString)
{
switch (character)
{
case '"':
if (quotationPos == 0 && pathStart)
{
quotationPos = 1;
}
else if (quotationPos == 1)
{
quotationPos = 2;
pathStart = false;
}
else
{
return false;
}
break;
case ';':
if (quotationPos != 1)
{
std::string path = currentPath.str();
if (!path.empty())
{
output.insert(path);
currentPath = std::ostringstream();
}
pathStart = true;
quotationPos = 0;
}
else
{
currentPath << character;
}
break;
default:
currentPath << character;
pathStart = false;
break;
}
}
if (currentPath.tellp() > 0)
{
output.insert(currentPath.str());
}
return true;
}
void UnlinkerArgs::PrintUsage()
{
UsageInformation usage("unlinker.exe");
@ -231,7 +172,7 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
// --search-path
if (m_argument_parser.IsOptionSpecified(OPTION_SEARCH_PATH))
{
if (!ParsePathsString(m_argument_parser.GetValueForOption(OPTION_SEARCH_PATH), m_user_search_paths))
if (!FileUtils::ParsePathsString(m_argument_parser.GetValueForOption(OPTION_SEARCH_PATH), m_user_search_paths))
{
return false;
}