summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorJohan Björk <phb@spotify.com>2011-02-15 13:34:14 (GMT)
committerBrad King <brad.king@kitware.com>2011-06-07 14:18:54 (GMT)
commitd0a403fd99e000f32467f66fe898d785f30435eb (patch)
tree14d657d3350cf560f62d581a64f736789a6fc14a /Source/cmSystemTools.cxx
parentd4884710a4db8a24e08b47617c912ba83deb1e39 (diff)
downloadCMake-d0a403fd99e000f32467f66fe898d785f30435eb.zip
CMake-d0a403fd99e000f32467f66fe898d785f30435eb.tar.gz
CMake-d0a403fd99e000f32467f66fe898d785f30435eb.tar.bz2
CMake: Move tokenize to cmSystemTools
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7bc89a4..9341a4c 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2833,3 +2833,35 @@ bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
}
return false;
}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
+ const std::string& sep)
+{
+ std::vector<std::string> tokens;
+ std::string::size_type tokend = 0;
+
+ do
+ {
+ std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
+ if (tokstart==std::string::npos)
+ {
+ break; // no more tokens
+ }
+ tokend=str.find_first_of(sep,tokstart);
+ if (tokend==std::string::npos)
+ {
+ tokens.push_back(str.substr(tokstart));
+ }
+ else
+ {
+ tokens.push_back(str.substr(tokstart,tokend-tokstart));
+ }
+ } while (tokend!=std::string::npos);
+
+ if (tokens.empty())
+ {
+ tokens.push_back("");
+ }
+ return tokens;
+}