mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-26 16:24:35 +01:00
Implement std::string variant of TrimStart; add tests.
This also makes String::TrimStart handle all-whitespace strings.
This commit is contained in:
committed by
Michael Steenbeek
parent
4bc2ad18c4
commit
d768a467b7
@@ -508,7 +508,8 @@ namespace String
|
||||
}
|
||||
ch = nextCh;
|
||||
}
|
||||
return str;
|
||||
// String is all whitespace
|
||||
return ch;
|
||||
}
|
||||
|
||||
utf8 * TrimStart(utf8 * buffer, size_t bufferSize, const utf8 * src)
|
||||
@@ -516,6 +517,12 @@ namespace String
|
||||
return String::Set(buffer, bufferSize, TrimStart(src));
|
||||
}
|
||||
|
||||
std::string TrimStart(const std::string &s)
|
||||
{
|
||||
const utf8 * trimmed = TrimStart(s.c_str());
|
||||
return std::string(trimmed);
|
||||
}
|
||||
|
||||
std::string Trim(const std::string &s)
|
||||
{
|
||||
codepoint_t codepoint;
|
||||
|
||||
Reference in New Issue
Block a user