mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
helpers: add trim methodes for left and right trim
This commit is contained in:
@@ -483,6 +483,18 @@ std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/)
|
|||||||
return result.erase(0, result.find_first_not_of(trimChars));
|
return result.erase(0, result.find_first_not_of(trimChars));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ltrim(std::string& str, const std::string& trimChars)
|
||||||
|
{
|
||||||
|
str.erase(0, str.find_first_not_of(trimChars));
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rtrim(std::string& str, const std::string& trimChars)
|
||||||
|
{
|
||||||
|
str.erase(str.find_last_not_of(trimChars) + 1);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
std::string cutString(const std::string str, int msgFont, const int width)
|
std::string cutString(const std::string str, int msgFont, const int width)
|
||||||
{
|
{
|
||||||
Font *msgFont_ = g_Font[msgFont];
|
Font *msgFont_ = g_Font[msgFont];
|
||||||
|
@@ -69,7 +69,9 @@ std::string getBaseName(std::string &path);
|
|||||||
std::string getFileName(std::string &file);
|
std::string getFileName(std::string &file);
|
||||||
std::string getFileExt(std::string &file);
|
std::string getFileExt(std::string &file);
|
||||||
std::string getNowTimeStr(const char* format);
|
std::string getNowTimeStr(const char* format);
|
||||||
std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
std::string trim(std::string& str, const std::string& trimChars = " \n\r\t");
|
||||||
|
std::string ltrim(std::string& str, const std::string& trimChars = " \n\r\t");
|
||||||
|
std::string rtrim(std::string& str, const std::string& trimChars = " \n\r\t");
|
||||||
std::string cutString(const std::string str, int msgFont, const int width);
|
std::string cutString(const std::string str, int msgFont, const int width);
|
||||||
std::string strftime(const char *format, const struct tm *tm);
|
std::string strftime(const char *format, const struct tm *tm);
|
||||||
std::string strftime(const char *format, time_t when, bool gm = false);
|
std::string strftime(const char *format, time_t when, bool gm = false);
|
||||||
|
Reference in New Issue
Block a user