aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg_Strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/vcpkg_Strings.cpp')
-rw-r--r--toolsrc/src/vcpkg_Strings.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp
index cf7d3b0ee..b974b0a06 100644
--- a/toolsrc/src/vcpkg_Strings.cpp
+++ b/toolsrc/src/vcpkg_Strings.cpp
@@ -119,4 +119,24 @@ namespace vcpkg::Strings
return s == "";
}), strings->end());
}
+
+ std::vector<std::string> split(const std::string& s, const std::string& delimiter)
+ {
+ std::vector<std::string> output;
+
+ size_t i = 0;
+ for (size_t pos = s.find(delimiter); pos != std::string::npos; pos = s.find(delimiter, pos))
+ {
+ output.push_back(s.substr(i, pos - i));
+ i = ++pos;
+ }
+
+ // Add the rest of the string after the last delimiter, unless there is nothing after it
+ if (i != s.length())
+ {
+ output.push_back(s.substr(i, s.length()));
+ }
+
+ return output;
+ }
}