summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools.cpp13
-rw-r--r--tools.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/tools.cpp b/tools.cpp
index 677ce02..fff3483 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -108,4 +108,17 @@ string StringEscapeAndBreak( string const& input )
return StringReplace( plainBuilder.str(), "\n", "<br/>" );
}
+string StringTrim(string const& str)
+{
+ string res = str;
+ string::size_type pos = res.find_last_not_of(' ');
+ if(pos != string::npos) {
+ res.erase(pos + 1);
+ pos = res.find_first_not_of(' ');
+ if(pos != string::npos) res.erase(0, pos);
+ }
+ else res.erase(res.begin(), res.end());
+ return res;
+}
+
} // namespace vdrlive
diff --git a/tools.h b/tools.h
index fdba13d..0779e8f 100644
--- a/tools.h
+++ b/tools.h
@@ -29,6 +29,7 @@ std::string StringRepeat(int times, const std::string& input);
std::string StringWordTruncate(const std::string& input, size_t maxLen, bool& truncated);
std::string StringEscapeAndBreak( std::string const& input );
std::string StringFormatBreak(std::string const& input);
+std::string StringTrim(const std::string& str);
struct bad_lexical_cast: std::runtime_error
{