#include <stringutils.h>
Static Public Member Functions | |
static bool | replace (std::string &str, const std::string &from, const std::string &to) |
static bool | replaceLast (std::string &str, const std::string &from, const std::string &to) |
static bool | startsWith (const std::string &str, const std::string &prefix) |
static bool | endsWith (const std::string &str, const std::string &suffix) |
template<typename T > | |
static std::string | toString (T value) |
template<typename T > | |
static T | parse (const std::string &str) |
template<typename T > | |
static T | parse (const std::string &str, bool adavanced) |
template<typename T > | |
static std::vector< T > | parseArray (const std::string &str) |
static void | toUpper (char *s) |
static void | toUpper (std::string &str) |
static void | toLower (char *s) |
static void | toLower (std::string &str) |
static std::string & | ltrim (std::string &s) |
static std::string & | rtrim (std::string &s) |
static std::string & | trim (std::string &s) |
template<typename T > | |
static std::string | join (const std::vector< T > &v, const std::string &token) |
static std::vector< std::string > | split (const std::string &str, char delim) |
A collection of useful string functions based on std::string
static bool utils::StringUtils::endsWith | ( | const std::string & | str, |
const std::string & | suffix | ||
) | [inline, static] |
Checks a string for specific suffix
Taken from: http://stackoverflow.com/questions/20446201/how-to-check-if-string-ends-with-txt
static std::string utils::StringUtils::join | ( | const std::vector< T > & | v, |
const std::string & | token | ||
) | [inline, static] |
Join vector
Taken from http://dracoater.blogspot.com/2010/03/joining-vector-and-splitting-string-in.html
static std::string& utils::StringUtils::ltrim | ( | std::string & | s | ) | [inline, static] |
Trims from start
Taken from http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
const char * utils::StringUtils::parse | ( | const std::string & | str | ) | [inline, static] |
Converts strings to arbitrary datatypes (using the << stream operator)
str | The string that should be converted |
bool utils::StringUtils::parse | ( | const std::string & | str, |
bool | adavanced | ||
) | [inline, static] |
Converts strings to arbitrary datatypes
str | The string that should be converted |
advanced | True of advanced conversions should be enabled |
static std::vector<T> utils::StringUtils::parseArray | ( | const std::string & | str | ) | [inline, static] |
static bool utils::StringUtils::replace | ( | std::string & | str, |
const std::string & | from, | ||
const std::string & | to | ||
) | [inline, static] |
Replaces first occurrence of from in str with to
Taken from http://stackoverflow.com/questions/3418231/c-replace-part-of-a-string-with-another-string
static bool utils::StringUtils::replaceLast | ( | std::string & | str, |
const std::string & | from, | ||
const std::string & | to | ||
) | [inline, static] |
Replaces last occurrence of from in str with to
static std::string& utils::StringUtils::rtrim | ( | std::string & | s | ) | [inline, static] |
Trims from end
Taken from http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
static std::vector<std::string> utils::StringUtils::split | ( | const std::string & | str, |
char | delim | ||
) | [inline, static] |
Split a string
Taken from http://stackoverflow.com/questions/236129/how-to-split-a-string-in-c
static bool utils::StringUtils::startsWith | ( | const std::string & | str, |
const std::string & | prefix | ||
) | [inline, static] |
static void utils::StringUtils::toLower | ( | char * | s | ) | [inline, static] |
Converts null terminated string to lower case
static void utils::StringUtils::toLower | ( | std::string & | str | ) | [inline, static] |
Converts std::string to lower case
static std::string utils::StringUtils::toString | ( | T | value | ) | [inline, static] |
Converts arbitrary datatypes (all datatypes which support the << stream operator) into std::string
static void utils::StringUtils::toUpper | ( | char * | s | ) | [inline, static] |
Converts null terminated string to upper case
static void utils::StringUtils::toUpper | ( | std::string & | str | ) | [inline, static] |
Converts std::string to upper case
static std::string& utils::StringUtils::trim | ( | std::string & | s | ) | [inline, static] |
Trims from both ends
Taken from http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring