From b355bdeccecf727d30e48634df9b5d424db570bc Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 4 Jun 2012 12:08:20 +0000 Subject: Added the new recipe parser, parsing the crafting.txt file. Included are a few recipes. The old parser still works, but will be replaced soon. git-svn-id: http://mc-server.googlecode.com/svn/trunk@549 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/StringUtils.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'source/StringUtils.cpp') 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(); -- cgit v1.2.3