2020-02-07 11:24:35 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vcpkg/base/expected.h>
|
|
|
|
#include <vcpkg/packagespec.h>
|
2020-02-09 14:50:26 -08:00
|
|
|
#include <vcpkg/textrowcol.h>
|
2020-02-07 11:24:35 -08:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace vcpkg::Parse
|
|
|
|
{
|
|
|
|
struct ParseControlErrorInfo
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::vector<std::string> missing_fields;
|
|
|
|
std::vector<std::string> extra_fields;
|
|
|
|
std::string error;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class P>
|
|
|
|
using ParseExpected = vcpkg::ExpectedT<std::unique_ptr<P>, std::unique_ptr<ParseControlErrorInfo>>;
|
|
|
|
|
2020-02-09 14:50:26 -08:00
|
|
|
using Paragraph = std::unordered_map<std::string, std::pair<std::string, TextRowCol>>;
|
2020-02-07 11:24:35 -08:00
|
|
|
|
|
|
|
struct ParagraphParser
|
|
|
|
{
|
2020-02-09 14:50:26 -08:00
|
|
|
ParagraphParser(Paragraph&& fields) : fields(std::move(fields)) {}
|
2020-02-07 11:24:35 -08:00
|
|
|
|
|
|
|
void required_field(const std::string& fieldname, std::string& out);
|
2020-02-09 14:50:26 -08:00
|
|
|
std::string optional_field(const std::string& fieldname);
|
|
|
|
void required_field(const std::string& fieldname, std::pair<std::string&, TextRowCol&> out);
|
|
|
|
void optional_field(const std::string& fieldname, std::pair<std::string&, TextRowCol&> out);
|
2020-02-07 11:24:35 -08:00
|
|
|
std::unique_ptr<ParseControlErrorInfo> error_info(const std::string& name) const;
|
|
|
|
|
|
|
|
private:
|
2020-02-09 14:50:26 -08:00
|
|
|
Paragraph&& fields;
|
2020-02-07 11:24:35 -08:00
|
|
|
std::vector<std::string> missing_fields;
|
|
|
|
};
|
|
|
|
|
|
|
|
ExpectedS<std::vector<std::string>> parse_default_features_list(const std::string& str,
|
2020-02-09 14:50:26 -08:00
|
|
|
CStringView origin = "<unknown>",
|
|
|
|
TextRowCol textrowcol = {});
|
2020-02-07 11:24:35 -08:00
|
|
|
ExpectedS<std::vector<ParsedQualifiedSpecifier>> parse_qualified_specifier_list(const std::string& str,
|
2020-02-09 14:50:26 -08:00
|
|
|
CStringView origin = "<unknown>",
|
|
|
|
TextRowCol textrowcol = {});
|
2020-02-07 11:24:35 -08:00
|
|
|
ExpectedS<std::vector<Dependency>> parse_dependencies_list(const std::string& str,
|
2020-02-09 14:50:26 -08:00
|
|
|
CStringView origin = "<unknown>",
|
|
|
|
TextRowCol textrowcol = {});
|
2020-02-07 11:24:35 -08:00
|
|
|
}
|