24 const char* delimiters,
25 bool tokenCompression =
true)
27 std::stringstream stringStream(str);
29 std::vector<std::string> tokenVector;
30 while (std::getline(stringStream, line))
34 while ((pos = line.find_first_of(delimiters, prev)) != std::string::npos)
39 tokenVector.push_back(line.substr(prev, pos - prev));
42 else if (!tokenCompression)
44 tokenVector.push_back(line.substr(prev, pos - prev));
48 if (prev < line.length())
50 tokenVector.push_back(line.substr(prev, std::string::npos));
62 inline std::string&
StringStartTrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
64 str.erase(0, str.find_first_not_of(chars));
71 inline std::string&
StringEndTrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
73 str.erase(str.find_last_not_of(chars) + 1);
80 inline std::string&
StringTrim(std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
88 inline std::string
StringTrimCopy(
const std::string& str,
const std::string& chars =
"\t\n\v\f\r ")
90 std::string strCopy = str;
96 inline std::string
StringConcat(
const std::vector<std::string>& strings, std::string seperator =
"")
99 for (
auto string : strings)
101 ss <<
string << seperator;
110 const std::string& oldStr,
111 const std::string& newStr)
113 std::string::size_type pos = 0u;
114 while ((pos = str.find(oldStr, pos)) != std::string::npos)
116 str.replace(pos, oldStr.length(), newStr);
117 pos += newStr.length();
129 inline bool StringToBool(
const std::string& s,
bool throw_on_error =
true)
135 std::istringstream is(s);
143 std::string s_lower = s;
144 std::transform(s_lower.begin(),
147 [](
unsigned char c){ return std::tolower(c); });
151 is >> std::boolalpha >> result;
154 if (is.fail() && throw_on_error)