diff options
-rw-r--r-- | include/hashcomp.h | 1 | ||||
-rw-r--r-- | src/hashcomp.cpp | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index 67a41a968..b903f7748 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -535,6 +535,7 @@ bool operator== (const irc::string& leftval, const std::string& rightval); std::string assign(const irc::string &other); irc::string assign(const std::string &other); +std::string& trim(std::string &str); namespace nspace { diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 1e6db3f65..8212dcaa3 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -624,3 +624,14 @@ irc::string assign(const std::string &other) return other.c_str(); } +std::string& trim(std::string &str) +{ + std::string::size_type start = str.find_first_not_of(" "); + std::string::size_type end = str.find_last_not_of(" "); + if (start == std::string::npos || end == std::string::npos) + str = ""; + else + str = str.substr(start, end-start+1); + + return str; +} |