Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 247:c9b3ba0fd140
path management in zip files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Dec 2012 17:27:23 +0100 |
parents | 7f74209ea0f8 |
children | 3c291753231f |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Fri Nov 30 17:09:52 2012 +0100 +++ b/Core/Toolbox.cpp Tue Dec 04 17:27:23 2012 +0100 @@ -566,5 +566,30 @@ return boost::posix_time::to_iso_string(now); } + std::string Toolbox::StripSpaces(const std::string& source) + { + size_t first = 0; + while (first < source.length() && + isspace(source[first])) + { + first++; + } + + if (first == source.length()) + { + // String containing only spaces + return ""; + } + + size_t last = source.length(); + while (last > first && + isspace(source[last - 1])) + { + last--; + } + + assert(first <= last); + return source.substr(first, last - first); + } }