diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-08-19 19:27:34 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-08-19 19:27:34 -0700 |
| commit | f219ce0b8c3e84e5fc1df21ad2f2c8b13f0fe413 (patch) | |
| tree | d78ee0a1a2e2a30ee465c6c90cd8544106a9c133 /toolsrc/src/vcpkg_Parse.cpp | |
| parent | 4d34488649fe5d71b8a553706d960a3784c56bb1 (diff) | |
| download | vcpkg-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.cpp | 33 |
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; + } } |
