diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2016-09-27 15:51:16 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2016-09-27 15:51:16 -0700 |
| commit | cc29d43f8577be1e053572c83958e633fbbea4e5 (patch) | |
| tree | ee3d05c01cfb442d0da7a73515093b10892ef23f /toolsrc/src/vcpkglib_helpers.cpp | |
| parent | 2ed13a583d5c8537680125d2ab5ec77b0f63503c (diff) | |
| parent | 687ac42cdd39fece9ed816836c049607f8d1223b (diff) | |
| download | vcpkg-cc29d43f8577be1e053572c83958e633fbbea4e5.tar.gz vcpkg-cc29d43f8577be1e053572c83958e633fbbea4e5.zip | |
Merge branch 'master' of https://github.com/microsoft/vcpkg
Diffstat (limited to 'toolsrc/src/vcpkglib_helpers.cpp')
| -rw-r--r-- | toolsrc/src/vcpkglib_helpers.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/toolsrc/src/vcpkglib_helpers.cpp b/toolsrc/src/vcpkglib_helpers.cpp index e947dc647..3aa3735b0 100644 --- a/toolsrc/src/vcpkglib_helpers.cpp +++ b/toolsrc/src/vcpkglib_helpers.cpp @@ -4,29 +4,28 @@ namespace vcpkg {namespace details { - void optional_field(const std::unordered_map<std::string, std::string>& fields, std::string& out, const std::string& fieldname) + std::string optional_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname) { auto it = fields.find(fieldname); if (it == fields.end()) { - out.clear(); + return std::string(); } - else - { - out = it->second; - } + return it->second; }; - void required_field(const std::unordered_map<std::string, std::string>& fields, std::string& out, const std::string& fieldname) + std::string required_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname) { auto it = fields.find(fieldname); vcpkg::Checks::check_throw(it != fields.end(), "Required field not present: %s", fieldname); - out = it->second; + return it->second; }; - void parse_depends(const std::string& depends_string, std::vector<std::string>& out) + std::vector<std::string> parse_depends(const std::string& depends_string) { + std::vector<std::string> out; + size_t cur = 0; do { @@ -34,17 +33,21 @@ namespace vcpkg {namespace details if (pos == std::string::npos) { out.push_back(depends_string.substr(cur)); - return; + break; } out.push_back(depends_string.substr(cur, pos - cur)); // skip comma and space ++pos; if (depends_string[pos] == ' ') + { ++pos; + } cur = pos; } while (cur != std::string::npos); + + return out; } }} |
