50 std::vector<std::string> tokens;
51 std::string::size_type start = str.find_first_not_of(delimiters);
52 while (start != std::string::npos) {
53 std::string::size_type end = str.find_first_of(delimiters, start);
54 if (end == std::string::npos) {
55 tokens.push_back(str.substr(start));
58 tokens.push_back(str.substr(start, end - start));
59 start = str.find_first_not_of(delimiters, end);
83 bool hasDigit =
false;
86 if (std::isdigit(
static_cast<unsigned char>(c))) {
88 }
else if (c ==
'+' || c ==
'-') {
90 if (hasDigit || hasSign)
93 }
else if (!std::isspace(
static_cast<unsigned char>(c))) {
115 const std::string ws(
" \t\n\r\f\v");
116 std::string::size_type b = str.find_first_not_of(ws);
117 if (b == std::string::npos)
119 std::string::size_type e = str.find_last_not_of(ws);
120 const std::string t = str.substr(b, e - b + 1);
122 std::string::size_type i = 0;
123 if (t[i] ==
'+' || t[i] ==
'-')
126 if (i >= t.size() || !(std::isdigit(
static_cast<unsigned char>(t[i])) || t[i] ==
'.'))
128 const char *begin = t.c_str();
130 std::strtod(begin, &end);
131 return end == begin + t.size();
156 const char *begin = str.c_str();
157 const char *end = begin + str.size();
158 while (begin != end && std::isspace(
static_cast<unsigned char>(*begin)))
162 const std::from_chars_result res = std::from_chars(begin, end, value);
164 *ok = (res.ec == std::errc{});
191 const char *begin = str.c_str();
194 const double value = std::strtod(begin, &end);
196 *ok = (end != begin) && (errno != ERANGE);
214 if (a.size() != b.size())
216 for (std::string::size_type i = 0; i < a.size(); ++i) {
217 if (std::tolower(
static_cast<unsigned char>(a[i])) !=
218 std::tolower(
static_cast<unsigned char>(b[i])))
239 if (needle.size() > haystack.size())
241 auto toLower = [](
unsigned char c) {
return std::tolower(c); };
242 for (std::string::size_type i = 0; i + needle.size() <= haystack.size(); ++i) {
243 std::string::size_type j = 0;
244 for (; j < needle.size(); ++j) {
245 if (toLower(haystack[i+j]) != toLower(needle[j]))
248 if (j == needle.size())
267 if (prefix.size() > str.size())
269 for (std::string::size_type i = 0; i < prefix.size(); ++i) {
270 if (std::tolower(
static_cast<unsigned char>(str[i])) !=
271 std::tolower(
static_cast<unsigned char>(prefix[i])))
static bool IsFloat(const std::string &str)
static bool ContainsNoCase(const std::string &haystack, const std::string &needle)
static int ToInt(const std::string &str, bool *ok=nullptr)
static bool BeginsWithNoCase(const std::string &str, const std::string &prefix)
static bool IsEqualNoCase(const std::string &a, const std::string &b)
static std::vector< std::string > Split(const std::string &str, const std::string &delimiters)
static double ToDouble(const std::string &str, bool *ok=nullptr)
static bool IsInt(const std::string &str)