about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
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) {