Start templating engine.

This commit is contained in:
jmsgrogan 2022-10-12 09:01:19 +01:00
parent c0bcfaccac
commit cdd0cc6b78
9 changed files with 230 additions and 1 deletions

View file

@ -20,6 +20,37 @@ bool StringUtils::IsSpace(char c)
return std::isspace(c, loc);
}
std::vector<std::string> StringUtils::split(const std::string& input)
{
std::vector<std::string> substrings;
std::string working_string;
std::locale loc;
bool last_was_nonspace{ false };
for (auto c : input)
{
if (std::isspace(c, loc))
{
if (last_was_nonspace)
{
substrings.push_back(working_string);
working_string = "";
last_was_nonspace = false;
}
}
else
{
last_was_nonspace = true;
working_string += c;
}
}
if (!working_string.empty())
{
substrings.push_back(working_string);
}
return substrings;
}
std::string StringUtils::ToLower(const std::string& s)
{
std::string ret;

View file

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vector>
class StringUtils
{
@ -20,4 +21,5 @@ public:
static std::string ToLower(const std::string& s);
static std::string convert(const std::wstring& input);
static std::string ToPaddedString(unsigned numBytes, unsigned entry);
static std::vector<std::string> split(const std::string& input);
};