From aa8db3531b1f38fa00a5e254579e5a9b47b38217 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Sun, 15 Apr 2007 11:31:21 +0000 Subject: added StringTrim --- tools.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools.cpp') 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", "
" ); } +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 -- cgit v1.2.3