28static inline void ltrim(std::string& s)
 
   30    if (!s.empty() && s[0] == 
'\n')
 
   34    s.erase(s.begin(), std::ranges::find_if(s, [](
int ch) { return !std::isspace(ch); }));
 
 
   39static inline void rtrim(std::string& s)
 
   41    if (!s.empty() && s[s.length() - 1] == 
'\n')
 
   43        s.erase(s.length() - 1);
 
   45    s.erase(std::find_if(s.rbegin(), s.rend(), [](
int ch) { 
 
   46                return !std::isspace(ch);
 
 
   54static inline void trim(std::string& s)
 
 
   62static inline void ltrim(std::string_view& sv)
 
   64    sv.remove_prefix(std::min(sv.find_first_not_of(
' '), sv.size()));
 
 
   69static inline void rtrim(std::string_view& sv)
 
   71    sv.remove_suffix(std::min(sv.size() - sv.find_last_not_of(
' ') - 1, sv.size()));
 
 
   76static inline void trim(std::string_view& sv)
 
 
  112static inline std::string_view 
ltrim_copy(std::string_view sv)
 
 
  121static inline std::string_view 
rtrim_copy(std::string_view sv)
 
 
  130static inline std::string_view 
trim_copy(std::string_view sv)
 
 
  155    auto it = std::search(
str.begin(), 
str.end(), 
 
  156                          from.begin(), from.end(),
 
  157                          [cs](
char ch1, 
char ch2) { return cs == RespectCase
 
  159                                                                : std::toupper(ch1) == std::toupper(ch2); });
 
  165    auto start_pos = 
static_cast<size_t>(it - 
str.begin());
 
  166    str.replace(start_pos, from.length(), to);
 
 
  184static inline void replaceAll(std::string& 
str, 
const std::string& from, 
const std::string& to)
 
  186    std::string::size_type n = 0;
 
  187    while ((n = 
str.find(from, n)) != std::string::npos)
 
  189        str.replace(n, from.size(), to);
 
 
  211static inline std::string 
replaceAll_copy(std::string 
str, 
const std::string& from, 
const std::string& to)
 
 
  221static inline std::vector<std::string> 
split(
const std::string& 
str, 
const std::string& delimiter)
 
  223    size_t pos_start = 0;
 
  225    size_t delim_len = delimiter.length();
 
  226    std::vector<std::string> res;
 
  228    while ((pos_end = 
str.find(delimiter, pos_start)) != std::string::npos)
 
  230        res.push_back(
str.substr(pos_start, pos_end - pos_start));
 
  231        pos_start = pos_end + delim_len;
 
  233    res.push_back(
str.substr(pos_start));
 
 
  241static inline std::vector<std::string> 
split(
const std::string& 
str, 
char delimiter)
 
  243    return split(
str, std::string(1, delimiter));
 
 
  250static inline std::vector<std::string> 
split_wo_empty(
const std::string& 
str, 
const std::string& delimiter)
 
  252    size_t pos_start = 0;
 
  254    size_t delim_len = delimiter.length();
 
  255    std::vector<std::string> res;
 
  257    while ((pos_end = 
str.find(delimiter, pos_start)) != std::string::npos)
 
  259        if (pos_start != pos_end)
 
  261            res.push_back(
str.substr(pos_start, pos_end - pos_start));
 
  263        pos_start = pos_end + delim_len;
 
  264        while (pos_start < 
str.size() && 
str.find(delimiter, pos_start) == pos_start)
 
  266            pos_start += delim_len;
 
  269    if (pos_start != 
str.size())
 
  271        res.push_back(
str.substr(pos_start));
 
 
  287concept StdString = std::convertible_to<T, std::string> || std::convertible_to<T, std::wstring>;
 
  296template<StdString String>
 
  297int stoi(
const String& 
str, 
int default_value, std::size_t* pos = 
nullptr, 
int base = 10) noexcept
 
  301        return std::stoi(
str, pos, base);
 
  306    return default_value;
 
 
  316template<StdString String>
 
  317int64_t 
stol(
const String& 
str, int64_t default_value, std::size_t* pos = 
nullptr, 
int base = 10) noexcept
 
  321        return std::stol(
str, pos, base);
 
  326    return default_value;
 
 
  336template<StdString String>
 
  337uint64_t 
stoul(
const String& 
str, uint64_t default_value, std::size_t* pos = 
nullptr, 
int base = 10) noexcept
 
  341        return std::stoul(
str, pos, base);
 
  346    return default_value;
 
 
  356template<StdString String>
 
  357int64_t 
stoll(
const String& 
str, int64_t default_value, std::size_t* pos = 
nullptr, 
int base = 10) noexcept
 
  361        return std::stoll(
str, pos, base);
 
  366    return default_value;
 
 
  375template<StdString String>
 
  376float stof(
const String& 
str, 
float default_value, std::size_t* pos = 
nullptr) noexcept
 
  380        return std::stof(
str, pos);
 
  385    return default_value;
 
 
  394template<StdString String>
 
  395double stod(
const String& 
str, 
double default_value, std::size_t* pos = 
nullptr) noexcept
 
  399        return std::stod(
str, pos);
 
  404    return default_value;
 
 
  413template<StdString String>
 
  414long double stold(
const String& 
str, 
long double default_value, std::size_t* pos = 
nullptr) noexcept
 
  418        return std::stold(
str, pos);
 
  423    return default_value;
 
 
 
Concept limiting the type to std::string and std::wstring, but also allowing convertible types like c...
 
int stoi(const String &str, int default_value, std::size_t *pos=nullptr, int base=10) noexcept
Interprets a value in the string str.
 
double stod(const String &str, double default_value, std::size_t *pos=nullptr) noexcept
Interprets a value in the string str.
 
long double stold(const String &str, long double default_value, std::size_t *pos=nullptr) noexcept
Interprets a value in the string str.
 
static std::string trim_copy(std::string s)
Trim from both ends (copying)
 
static std::string ltrim_copy(std::string s)
Trim from start (copying)
 
static void rtrim(std::string &s)
Trim from end (in place)
 
uint64_t stoul(const String &str, uint64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
Interprets a value in the string str.
 
static void ltrim(std::string &s)
Trim from start (in place)
 
static void trim(std::string &s)
Trim from both ends (in place)
 
int64_t stoll(const String &str, int64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
Interprets a value in the string str.
 
static std::string replaceAll_copy(std::string str, const std::string &from, const std::string &to, CaseSensitivity cs)
Replaces all occurrence of a search pattern with another sequence.
 
float stof(const String &str, float default_value, std::size_t *pos=nullptr) noexcept
Interprets a value in the string str.
 
static std::string rtrim_copy(std::string s)
Trim from end (copying)
 
static void replaceAll(std::string &str, const std::string &from, const std::string &to, CaseSensitivity cs)
Replaces all occurrence of a search pattern with another sequence.
 
static std::vector< std::string > split_wo_empty(const std::string &str, const std::string &delimiter)
Splits a string into parts at a delimiter and removes empty entries.
 
CaseSensitivity
Enum for case sensitive tasks.
 
@ RespectCase
Respect the case.
 
static std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Splits a string into parts at a delimiter.
 
int64_t stol(const String &str, int64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
Interprets a value in the string str.
 
static bool replace(std::string &str, const std::string &from, const std::string &to, CaseSensitivity cs=RespectCase)
Replaces the first occurrence of a search pattern with another sequence.