diff options
Diffstat (limited to 'cpp/src/IceUtil/StringUtil.cpp')
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 62bd9e1f44d..e087e5586dc 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -364,6 +364,23 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri return true; } +// +// Trim white space (" \t\r\n") +// +string +IceUtilInternal::trim(const string& s) +{ + static const string delim = " \t\r\n"; + string::size_type beg = s.find_first_not_of(delim); + if(beg == string::npos) + { + return ""; + } + else + { + return s.substr(beg, s.find_last_not_of(delim) - beg + 1); + } +} // // If a single or double quotation mark is found at the start position, |