diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-18 20:57:25 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-04-18 20:57:25 +0000 |
commit | 326b2d07b780ef0dcd3091b42eb73c6554982f8c (patch) | |
tree | 668ed431839010b7371c1c324f9b7c541c2a8fb8 /src | |
parent | f1f2a2e0273259713545e360d46b9dbdbfc30589 (diff) |
Add trim() to hashcomp to trail leading and traling spaces from std::strings
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6809 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/hashcomp.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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; +} |