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

@ -0,0 +1,63 @@
#include "FileUtils.h"
#include <sstream>
bool FileUtils::ParsePathsString(const std::string& pathsString, std::set<std::string>& output)
{
std::ostringstream currentPath;
auto pathStart = true;
auto 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)
{
auto 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;
}

View File

@ -1,10 +1,24 @@
#pragma once
#include <cstdint>
#include <set>
#include <string>
constexpr uint32_t MakeMagic32(const char ch0, const char ch1, const char ch2, const char ch3)
class FileUtils
{
return static_cast<uint32_t>(ch0)
| static_cast<uint32_t>(ch1) << 8
| static_cast<uint32_t>(ch2) << 16
| static_cast<uint32_t>(ch3) << 24;
}
public:
static constexpr uint32_t MakeMagic32(const char ch0, const char ch1, const char ch2, const char ch3)
{
return static_cast<uint32_t>(ch0)
| static_cast<uint32_t>(ch1) << 8
| static_cast<uint32_t>(ch2) << 16
| static_cast<uint32_t>(ch3) << 24;
}
/**
* \brief Splits a path string as user input into a list of paths.
* \param pathsString The path string that was taken as user input.
* \param output A set for strings to save the output to.
* \return \c true if the user input was valid and could be processed successfully, otherwise \c false.
*/
static bool ParsePathsString(const std::string& pathsString, std::set<std::string>& output);
};