aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg_Parse.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-19 19:27:34 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-08-19 19:27:34 -0700
commitf219ce0b8c3e84e5fc1df21ad2f2c8b13f0fe413 (patch)
treed78ee0a1a2e2a30ee465c6c90cd8544106a9c133 /toolsrc/src/vcpkg_Parse.cpp
parent4d34488649fe5d71b8a553706d960a3784c56bb1 (diff)
downloadvcpkg-f219ce0b8c3e84e5fc1df21ad2f2c8b13f0fe413.tar.gz
vcpkg-f219ce0b8c3e84e5fc1df21ad2f2c8b13f0fe413.zip
[vcpkg] Reorganize some parsing functions.
Diffstat (limited to 'toolsrc/src/vcpkg_Parse.cpp')
-rw-r--r--toolsrc/src/vcpkg_Parse.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Parse.cpp b/toolsrc/src/vcpkg_Parse.cpp
index 659af2939..118cde900 100644
--- a/toolsrc/src/vcpkg_Parse.cpp
+++ b/toolsrc/src/vcpkg_Parse.cpp
@@ -44,4 +44,37 @@ namespace vcpkg::Parse
}
return nullptr;
}
+
+ std::vector<std::string> parse_comma_list(const std::string& str)
+ {
+ if (str.empty())
+ {
+ return {};
+ }
+
+ std::vector<std::string> out;
+
+ size_t cur = 0;
+ do
+ {
+ auto pos = str.find(',', cur);
+ if (pos == std::string::npos)
+ {
+ out.push_back(str.substr(cur));
+ break;
+ }
+ out.push_back(str.substr(cur, pos - cur));
+
+ // skip comma and space
+ ++pos;
+ if (str[pos] == ' ')
+ {
+ ++pos;
+ }
+
+ cur = pos;
+ } while (cur != std::string::npos);
+
+ return out;
+ }
}