summaryrefslogtreecommitdiff
path: root/src/core/common/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/common/Utils.cpp')
-rw-r--r--src/core/common/Utils.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/common/Utils.cpp b/src/core/common/Utils.cpp
index 5eaafe9..5fde29c 100644
--- a/src/core/common/Utils.cpp
+++ b/src/core/common/Utils.cpp
@@ -55,5 +55,24 @@ bool Utils::isIdentifier(const std::string &name)
}
return true;
}
+
+std::vector<std::string> Utils::split(const std::string &s, char delim)
+{
+ std::vector<std::string> res;
+ const size_t totalLen = s.size();
+ size_t start = 0;
+ size_t len = 0;
+ for (size_t i = 0; i <= totalLen; i++) {
+ if (i == totalLen || s[i] == delim) {
+ res.push_back(s.substr(start, len));
+ start = i + 1;
+ len = 0;
+ } else {
+ len++;
+ }
+ }
+ return res;
+}
+
}