diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-02 20:26:52 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-02 20:26:52 -0700 |
| commit | 4665b16ab3556235ddcbdac160df261ee87694e4 (patch) | |
| tree | 6bbe535285a808ff457ada4cccc28838a7868400 /toolsrc/src/SourceParagraph.cpp | |
| parent | 079a027b1e81becd4ba448362579f625dd7bcca4 (diff) | |
| download | vcpkg-4665b16ab3556235ddcbdac160df261ee87694e4.tar.gz vcpkg-4665b16ab3556235ddcbdac160df261ee87694e4.zip | |
Add checks for fields in CONTROL file. Resolves #228
Diffstat (limited to 'toolsrc/src/SourceParagraph.cpp')
| -rw-r--r-- | toolsrc/src/SourceParagraph.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/toolsrc/src/SourceParagraph.cpp b/toolsrc/src/SourceParagraph.cpp index 75c8ebfef..c870bde21 100644 --- a/toolsrc/src/SourceParagraph.cpp +++ b/toolsrc/src/SourceParagraph.cpp @@ -1,16 +1,50 @@ #include "SourceParagraph.h" #include "vcpkglib_helpers.h" -using namespace vcpkg::details; +namespace vcpkg +{ + // + namespace SourceParagraphRequiredField + { + static const std::string SOURCE = "Source"; + static const std::string VERSION = "Version"; + } -vcpkg::SourceParagraph::SourceParagraph() = default; + namespace SourceParagraphOptionalEntry + { + static const std::string DESCRIPTION = "Description"; + static const std::string MAINTAINER = "Maintainer"; + static const std::string BUILD_DEPENDS = "Build-Depends"; + } -vcpkg::SourceParagraph::SourceParagraph(const std::unordered_map<std::string, std::string>& fields): - name(required_field(fields, "Source")), - version(required_field(fields, "Version")), - description(optional_field(fields, "Description")), - maintainer(optional_field(fields, "Maintainer")) -{ - std::string deps = optional_field(fields, "Build-Depends"); - this->depends = parse_depends(deps); + const std::vector<std::string>& SourceParagraph::get_list_of_valid_entries() + { + static const std::vector<std::string> valid_enties = + { + SourceParagraphRequiredField::SOURCE, + SourceParagraphRequiredField::VERSION, + + SourceParagraphOptionalEntry::DESCRIPTION, + SourceParagraphOptionalEntry::MAINTAINER, + SourceParagraphOptionalEntry::BUILD_DEPENDS + }; + + return valid_enties; + } + + SourceParagraph::SourceParagraph() = default; + + SourceParagraph::SourceParagraph(std::unordered_map<std::string, std::string> fields) + { + using namespace vcpkg::details; + this->name = remove_required_field(&fields, SourceParagraphRequiredField::SOURCE); + this->version = remove_required_field(&fields, SourceParagraphRequiredField::VERSION); + this->description = remove_optional_field(&fields, SourceParagraphOptionalEntry::DESCRIPTION); + this->maintainer = remove_optional_field(&fields, SourceParagraphOptionalEntry::MAINTAINER); + + std::string deps = remove_optional_field(&fields, SourceParagraphOptionalEntry::BUILD_DEPENDS); + this->depends = parse_depends(deps); + + this->unparsed_fields = std::move(fields); + } } |
