aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-01-23 15:13:12 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-01-23 15:13:12 -0800
commit3a6571a0191df8ff000384937a6254f378ca23cf (patch)
treeb1a4c78efef26896769c69db7cd5b500a7c877f4 /toolsrc/src
parent6d3ab4579d50f74cbe43373fa16ba875a97a8717 (diff)
downloadvcpkg-3a6571a0191df8ff000384937a6254f378ca23cf.tar.gz
vcpkg-3a6571a0191df8ff000384937a6254f378ca23cf.zip
Add Strings::split() function
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg_Strings.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp
index cf7d3b0ee..16477a45c 100644
--- a/toolsrc/src/vcpkg_Strings.cpp
+++ b/toolsrc/src/vcpkg_Strings.cpp
@@ -119,4 +119,25 @@ 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;
+ size_t pos = s.find(delimiter);
+ while (pos != std::string::npos)
+ {
+ output.push_back(s.substr(i, pos - i));
+ i = ++pos;
+ pos = s.find(delimiter, pos);
+
+ if (pos == std::string::npos)
+ {
+ output.push_back(s.substr(i, s.length()));
+ }
+ }
+
+ return output;
+ }
}