Template enginge - start parsing nodes.
This commit is contained in:
parent
cdd0cc6b78
commit
98842b24f2
3 changed files with 166 additions and 18 deletions
|
@ -20,6 +20,42 @@ bool StringUtils::IsSpace(char c)
|
|||
return std::isspace(c, loc);
|
||||
}
|
||||
|
||||
std::string StringUtils::strip(const std::string& input)
|
||||
{
|
||||
if (input.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::locale loc;
|
||||
std::string working_string;
|
||||
std::size_t first_nonspace = 0;
|
||||
std::size_t last_nonspace = working_string.size() - 1;
|
||||
for (std::size_t idx = 0; idx < working_string.size(); idx++)
|
||||
{
|
||||
if (!std::isspace(working_string[idx], loc))
|
||||
{
|
||||
first_nonspace = idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (first_nonspace == last_nonspace)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
for (std::size_t idx = last_nonspace; idx > 0; idx--)
|
||||
{
|
||||
if (!std::isspace(working_string[idx], loc))
|
||||
{
|
||||
last_nonspace = idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return working_string.substr(first_nonspace, last_nonspace-first_nonspace);
|
||||
}
|
||||
|
||||
std::vector<std::string> StringUtils::split(const std::string& input)
|
||||
{
|
||||
std::vector<std::string> substrings;
|
||||
|
|
|
@ -22,4 +22,5 @@ public:
|
|||
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);
|
||||
static std::string strip(const std::string& input);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue