summaryrefslogtreecommitdiffstats
path: root/source/StringUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/StringUtils.cpp')
-rw-r--r--source/StringUtils.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp
index 97571f521..df2e72a17 100644
--- a/source/StringUtils.cpp
+++ b/source/StringUtils.cpp
@@ -88,10 +88,7 @@ AStringVector StringSplit(const AString & str, const AString & delim)
size_t Prev = 0;
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
{
- if (cutAt > 0)
- {
- results.push_back(str.substr(Prev, cutAt - Prev));
- }
+ results.push_back(str.substr(Prev, cutAt - Prev));
Prev = cutAt + delim.length();
}
if (Prev < str.length())
@@ -104,6 +101,40 @@ AStringVector StringSplit(const AString & str, const AString & delim)
+AString TrimString(const AString & str)
+{
+ size_t len = str.length();
+ size_t start = 0;
+ while (start < len)
+ {
+ if (str[start] > 32)
+ {
+ break;
+ }
+ ++start;
+ }
+ if (start == len)
+ {
+ return "";
+ }
+
+ size_t end = len;
+ while (end >= start)
+ {
+ if (str[end] > 32)
+ {
+ break;
+ }
+ --end;
+ }
+
+ return str.substr(start, end - start + 1);
+}
+
+
+
+
+
AString & StrToUpper(AString & s)
{
AString::iterator i = s.begin();