ShlubluLib
v0.5
ShlubluLib is a lightweight, modular, general purpose, open-source C++ library for Linux and Windows.
|
Functions | |
template<typename T > | |
std::string | xtos (T arg) |
Converts arithmetic values or pointers to std::string. More... | |
template<typename T > | |
std::string | xtofs (T arg) |
Converts floating point values to std::string in fixed notation. More... | |
std::vector< std::string > const & | split (std::string const &s, char delim, std::vector< std::string > &elems) |
Splits a string delimited by a given character and stores the substrings in the given target vector. More... | |
std::vector< std::string > | split (std::string const &s, char delim) |
Splits a string delimited by a given character and returns the result as a vector of substrings. More... | |
std::string & | ltrim (std::string &s) |
Trims the leading blank characters of a string. More... | |
std::string & | rtrim (std::string &s) |
Trims the trailing blank characters of a string. More... | |
std::string & | trim (std::string &s) |
Trims the leading and trailing blank characters of a string. More... | |
std::string & | replace (std::string &source, std::string const &find, std::string const &replaceBy) |
Replaces all occurences of a substring in a string. More... | |
std::string & | lower (std::string &s) |
Converts a string to lowercase. More... | |
std::string | lower (std::string const &s) |
Returns a lowercase version of the given string. More... | |
std::string & | upper (std::string &s) |
Converts a string to uppercase. More... | |
std::string | upper (std::string const &s) |
Returns a uppercase version of the given string. More... | |
std::wstring | toWString (std::string const &str) |
Returns an UTF-8 wstring version of the given string. More... | |
std::string | fromWString (std::wstring const &wstr) |
Returns a string version of the given UTF-8 wstring. More... | |
size_t | levenshteinDistance (std::string const &s, std::string const &t) |
Computes the Levenshtein distance between two strings. More... | |
Helper functions for std::string.
|
inline |
Converts arithmetic values or pointers to std::string.
arg | the value to convert |
Example
|
inline |
Converts floating point values to std::string in fixed notation.
arg | the value to convert |
Example
std::vector<std::string> const& shlublu::String::split | ( | std::string const & | s, |
char | delim, | ||
std::vector< std::string > & | elems | ||
) |
Splits a string delimited by a given character and stores the substrings in the given target vector.
'elems' is cleared before receiving the resulting substrings.
s | the string to split |
delim | the delimiter |
elems | the vector to store the resulting substrings |
Example
std::vector<std::string> shlublu::String::split | ( | std::string const & | s, |
char | delim | ||
) |
Splits a string delimited by a given character and returns the result as a vector of substrings.
s | the string to split |
delim | the delimiter |
Example
std::string& shlublu::String::ltrim | ( | std::string & | s | ) |
Trims the leading blank characters of a string.
s | the string to trim |
Example
std::string& shlublu::String::rtrim | ( | std::string & | s | ) |
Trims the trailing blank characters of a string.
s | the string to trim |
Example
std::string& shlublu::String::trim | ( | std::string & | s | ) |
Trims the leading and trailing blank characters of a string.
s | the string to trim |
Example
std::string& shlublu::String::replace | ( | std::string & | source, |
std::string const & | find, | ||
std::string const & | replaceBy | ||
) |
Replaces all occurences of a substring in a string.
source | the string that contains substrings to replace |
find | the substring to be replaced |
replaceBy | the replacement substring |
std::invalid_argument | if find is empty |
Example
std::string& shlublu::String::lower | ( | std::string & | s | ) |
Converts a string to lowercase.
s | the string to convert |
Example
std::string shlublu::String::lower | ( | std::string const & | s | ) |
Returns a lowercase version of the given string.
s | the string to convert |
Example
std::string& shlublu::String::upper | ( | std::string & | s | ) |
Converts a string to uppercase.
s | the string to convert |
Example
std::string shlublu::String::upper | ( | std::string const & | s | ) |
Returns a uppercase version of the given string.
s | the string to convert |
Example
std::wstring shlublu::String::toWString | ( | std::string const & | str | ) |
Returns an UTF-8 wstring version of the given string.
str | the string to convert |
Example
std::string shlublu::String::fromWString | ( | std::wstring const & | wstr | ) |
Returns a string version of the given UTF-8 wstring.
wstr | the UTF-8 wstring to convert |
Example
size_t shlublu::String::levenshteinDistance | ( | std::string const & | s, |
std::string const & | t | ||
) |
Computes the Levenshtein distance between two strings.
s | a string |
t | another string |
Example