vcpkg/toolsrc/src/SourceParagraph.cpp

51 lines
1.7 KiB
C++
Raw Normal View History

2016-09-19 11:50:08 +08:00
#include "SourceParagraph.h"
#include "vcpkglib_helpers.h"
namespace vcpkg
{
//
namespace SourceParagraphRequiredField
{
static const std::string SOURCE = "Source";
static const std::string VERSION = "Version";
}
2016-09-19 11:50:08 +08:00
2016-11-04 05:34:52 +08:00
namespace SourceParagraphOptionalField
{
static const std::string DESCRIPTION = "Description";
static const std::string MAINTAINER = "Maintainer";
static const std::string BUILD_DEPENDS = "Build-Depends";
}
2016-09-19 11:50:08 +08:00
2016-11-04 05:34:52 +08:00
const std::vector<std::string>& SourceParagraph::get_list_of_valid_fields()
{
2016-11-04 05:34:52 +08:00
static const std::vector<std::string> valid_fields =
{
SourceParagraphRequiredField::SOURCE,
SourceParagraphRequiredField::VERSION,
2016-11-04 05:34:52 +08:00
SourceParagraphOptionalField::DESCRIPTION,
SourceParagraphOptionalField::MAINTAINER,
SourceParagraphOptionalField::BUILD_DEPENDS
};
2016-11-04 05:34:52 +08:00
return valid_fields;
}
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);
2016-11-04 05:34:52 +08:00
this->description = remove_optional_field(&fields, SourceParagraphOptionalField::DESCRIPTION);
this->maintainer = remove_optional_field(&fields, SourceParagraphOptionalField::MAINTAINER);
2016-11-04 05:34:52 +08:00
std::string deps = remove_optional_field(&fields, SourceParagraphOptionalField::BUILD_DEPENDS);
this->depends = parse_depends(deps);
this->unparsed_fields = std::move(fields);
}
2016-09-19 11:50:08 +08:00
}