25 #include "StringUtils.hh"
28 const std::string &seperator,
29 std::vector<std::string> &ret)
33 const int sepLen = seperator.length();
36 register int posL = 0;
37 register int posR = str.find(seperator);
44 ret.push_back(str.substr(posL, posR - posL));
49 posR = str.find(seperator, posL);
53 if (posR == -1 && (
unsigned int)posL < str.length()) {
54 ret.push_back(str.substr(posL, str.length() - posL));
60 std::vector<std::string> &ret,
61 const std::string &charsToSplit)
65 size_t nextPos, firstPos = str.find_first_not_of(charsToSplit);
66 while (firstPos != std::string::npos) {
67 nextPos = str.find_first_of(charsToSplit, firstPos);
68 if (nextPos != std::string::npos) {
69 ret.push_back(str.substr(firstPos, nextPos-firstPos));
70 firstPos = str.find_first_not_of(charsToSplit, nextPos);
72 ret.push_back(str.substr(firstPos, str.size()-firstPos));
73 firstPos = std::string::npos;
83 const std::string &charsToTrim)
85 const int left = str.find_first_not_of(charsToTrim);
86 const int right = str.find_last_not_of(charsToTrim);
88 if (left != -1 && right != -1) {
89 ret = str.substr(left, right - left + 1);
static void Trim(const std::string &str, std::string &ret, const std::string &charsToTrim=" \t\n")
Trims the given string, i.e.
static void Explode(const std::string &str, const std::string &seperator, std::vector< std::string > &ret)
Explodes the given string into tokens which are separated by the given separator string.
static void SplitByChars(const std::string &str, std::vector< std::string > &ret, const std::string &charsToSplit="\t\n ,;")
Splits the given string into tokens which are separated by any of the given separator characters (sim...