summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string-util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-string-util.cpp')
-rw-r--r--source/core/slang-string-util.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp
new file mode 100644
index 000000000..c60ad9683
--- /dev/null
+++ b/source/core/slang-string-util.cpp
@@ -0,0 +1,29 @@
+#include "slang-string-util.h"
+
+namespace Slang {
+
+/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& slicesOut)
+{
+ slicesOut.Clear();
+
+ const char* start = in.begin();
+ const char* end = in.end();
+
+ while (start < end)
+ {
+ // Move cur so it's either at the end or at next split character
+ const char* cur = start;
+ while (cur < end && *cur != splitChar)
+ {
+ cur++;
+ }
+
+ // Add to output
+ slicesOut.Add(UnownedStringSlice(start, cur));
+
+ // Skip the split character, if at end we are okay anyway
+ start = cur + 1;
+ }
+}
+
+} // namespace Slang