diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-04 14:08:20 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-04 14:08:20 +0200 |
commit | b355bdeccecf727d30e48634df9b5d424db570bc (patch) | |
tree | 00489a1317e6ad22a28698f24bd9935160257789 /source/StringUtils.cpp | |
parent | Fixed MSVC2010 projects for new zlib (diff) | |
download | cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar.gz cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar.bz2 cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar.lz cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar.xz cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.tar.zst cuberite-b355bdeccecf727d30e48634df9b5d424db570bc.zip |
Diffstat (limited to '')
-rw-r--r-- | source/StringUtils.cpp | 39 |
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();
|