35std::string &
trim(std::string &str);
43std::string &
toLower(std::string &str);
51std::string &
toUpper(std::string &str);
60unsigned int atox(
const std::string &str);
68template<
typename T> std::string
toString(
const T &arg)
70 std::ostringstream ss;
93 __attribute__((__format__(__printf__, 1, 2)))
106 std::string_view chars,
107 char replacement =
'_');
120inline bool startsWith(std::string_view str, std::string_view prefix)
122 return str.substr(0, prefix.size()) == prefix;
128inline bool endsWith(std::string_view str, std::string_view suffix)
130 return str.size() >= suffix.size() &&
131 str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
140 const std::string &str2);
156template<
typename T,
typename Enable =
void>
170inline void fromString(
const char *str, std::string_view &value)
182 value = strtoul(str,
nullptr, 10);
185inline void fromString(
const char *str,
unsigned short &value)
187 value =
static_cast<unsigned short>(strtoul(str,
nullptr, 10));
192 value = strtof(str,
nullptr);
205void fromString(
const char *str, std::vector<int> &value);
210 void operator() (
const char *str, T &value)
212 fromString(str,
reinterpret_cast<std::underlying_type_t<T>&
>(value));
219 void operator() (
const char *str, std::optional<T> &value)
228std::string
autocomplete(
const std::vector<std::string> &candidates,
234std::string
normalize(
const std::string &name);
248std::string
join(
const std::vector<std::string> &strings,
const char *separator);
unsigned int atox(const std::string &str)
Converts an ascii hexidecimal string to an integer.
bool isWordSeparator(char chr)
Tells wether the character is a word separator.
std::string & toUpper(std::string &str)
Converts the given string to upper case.
std::string & replaceCharacters(std::string &str, std::string_view chars, char replacement='_')
Replaces a set of characters with another character.
void fromString(const char *str, T &value)
std::string getDirectoryFromURL(const std::string &url)
Derives a directory from the given URL, stripping the schema and replacing certain invalid characters...
std::string & toLower(std::string &str)
Converts the given string to lower case.
std::string join(const std::vector< std::string > &strings, const char *separator)
Joins a vector of strings into one string, separated by the given separator.
std::string & trim(std::string &str)
Trims spaces off the end and the beginning of the given string.
std::string findSameSubstring(const std::string &str1, const std::string &str2)
bool startsWith(std::string_view str, std::string_view prefix)
Returns whether a string starts with a given prefix.
bool endsWith(std::string_view str, std::string_view suffix)
Returns whether a string ends with a given suffix.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.
const char * ipToString(int address)
Converts the given IP address to a string.
std::string normalize(const std::string &name)
Normalize a string, which means lowercase and trim it.
std::string strprintf(char const *,...)
A safe version of sprintf that returns a std::string of the result.
std::string autocomplete(const std::vector< std::string > &candidates, std::string base)
Returns the most approaching string of base from candidates.
std::string & removeColors(std::string &msg)
Removes colors from a string.
bool getBoolFromString(std::string text, bool def=false)
Returns a bool value depending on the given string value.
This class can be partially specialized to provide custom string conversion.
void fromString(const char *str, FillMode &value)