about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-09-22T15·43+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-09-22T15·43+0000
commit4578a490ce5a5a6325b4ff2b8f44468464de2d94 (patch)
tree62a5118879990d20e71cccf263f4648bfa3ba253 /src/libutil/util.cc
parentfbedf6056eb2acb5049b0372350b2c93b8185ab7 (diff)
* Parse multi-valued options.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 574c2566b7a5..2e684e9c1441 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -665,6 +665,21 @@ Strings unpackStrings(const string & s)
 }
 
 
+Strings tokenizeString(const string & s, const string & separators)
+{
+    Strings result;
+    string::size_type pos = s.find_first_not_of(separators, 0);
+    while (pos != string::npos) {
+        string::size_type end = s.find_first_of(separators, pos + 1);
+        if (end == string::npos) end = s.size();
+        string token(s, pos, end - pos);
+        result.push_back(token);
+        pos = s.find_first_not_of(separators, end);
+    }
+    return result;
+}
+
+
 string statusToString(int status)
 {
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {