Commit 4044e1e3 authored by Pawel Sznajder's avatar Pawel Sznajder
Browse files

add new members in StringUtils (trim)

parent 19899287
...@@ -72,6 +72,9 @@ public: ...@@ -72,6 +72,9 @@ public:
// Remove leading and trailing spaces from a string // Remove leading and trailing spaces from a string
static void trim(std::string &str, const std::string& whitespace = " \t"); static void trim(std::string &str, const std::string& whitespace = " \t");
// Remove all white spaces from a string
static void trimAll(std::string &str, const std::string& whitespace = " \t");
static unsigned int count(std::string str, static unsigned int count(std::string str,
const std::string & searchString); const std::string & searchString);
......
...@@ -181,6 +181,15 @@ void StringUtils::trim(std::string &str, const std::string& whitespace) { ...@@ -181,6 +181,15 @@ void StringUtils::trim(std::string &str, const std::string& whitespace) {
} }
} }
void StringUtils::trimAll(std::string &str, const std::string& whitespace) {
std::string::const_iterator it;
for (it = whitespace.begin(); it != whitespace.end(); ++it) {
str.erase(std::remove(str.begin(), str.end(), *it), str.end());
}
}
unsigned int StringUtils::count(std::string str, unsigned int StringUtils::count(std::string str,
const std::string & searchString) { const std::string & searchString) {
unsigned int resultat = 0; unsigned int resultat = 0;
...@@ -367,7 +376,8 @@ size_t StringUtils::findFirst(const std::string& file, ...@@ -367,7 +376,8 @@ size_t StringUtils::findFirst(const std::string& file,
return fileSize; return fileSize;
} }
std::string StringUtils::formatDate(const time_t &time, const std::string &format) { std::string StringUtils::formatDate(const time_t &time,
const std::string &format) {
// see : http://stackoverflow.com/questions/16357999/current-date-and-time-as-string // see : http://stackoverflow.com/questions/16357999/current-date-and-time-as-string
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment