11#ifndef INCLUDE_ARK_UTILS_HPP
12#define INCLUDE_ARK_UTILS_HPP
31 inline std::vector<std::string>
splitString(
const std::string& source,
const char sep)
33 std::vector<std::string> output;
34 output.emplace_back();
36 for (
const char c : source)
41 output.emplace_back();
52 inline std::string&
ltrim(std::string& s)
56 std::ranges::find_if(s.begin(), s.end(), [](
const unsigned char ch) {
57 return !std::isspace(ch);
67 inline std::string&
rtrim(std::string& s)
70 std::ranges::find_if(s.rbegin(), s.rend(), [](
const unsigned char ch) {
71 return !std::isspace(ch);
85 inline bool isDouble(
const std::string& s,
double* output =
nullptr)
88 const double val = strtod(s.c_str(), &end);
89 if (output !=
nullptr)
91 return end != s.c_str() && *end ==
'\0' && val != HUGE_VAL;
std::string & ltrim(std::string &s)
Remove spaces at the beginning of a string, in place.
std::vector< std::string > splitString(const std::string &source, const char sep)
Cut a string into pieces, given a character separator.
ARK_API std::size_t levenshteinDistance(const std::string &str1, const std::string &str2)
Calculate the Levenshtein distance between two strings.
std::string & rtrim(std::string &s)
Remove spaces at the end of a string, in place.
bool isDouble(const std::string &s, double *output=nullptr)
Checks if a string is a valid double.