#pragma once #include #include #include namespace vcpkg { struct ParsedSpecifier { std::string name; std::vector features; std::string triplet; static ExpectedT from_string(const std::string& input); }; struct PackageSpec { static ExpectedT from_name_and_triplet(const std::string& name, const Triplet& triplet); static std::vector to_package_specs(const std::vector& ports, const Triplet& triplet); static std::vector from_dependencies_of_port(const std::string& port, const std::vector& dependencies, const Triplet& triplet); const std::string& name() const; const Triplet& triplet() const; std::string dir() const; std::string to_string() const; bool operator<(const PackageSpec& other) const { if (name() < other.name()) return true; if (name() > other.name()) return false; return triplet() < other.triplet(); } private: std::string m_name; Triplet m_triplet; }; struct FeatureSpec { FeatureSpec(const PackageSpec& spec, const std::string& feature) : m_spec(spec), m_feature(feature) {} const std::string& name() const { return m_spec.name(); } const std::string& feature() const { return m_feature; } const Triplet& triplet() const { return m_spec.triplet(); } const PackageSpec& spec() const { return m_spec; } std::string to_string() const; static std::vector from_strings_and_triplet(const std::vector& depends, const Triplet& t); bool operator<(const FeatureSpec& other) const { if (name() < other.name()) return true; if (name() > other.name()) return false; if (feature() < other.feature()) return true; if (feature() > other.feature()) return false; return triplet() < other.triplet(); } bool operator==(const FeatureSpec& other) const { return triplet() == other.triplet() && name() == other.name() && feature() == other.feature(); } bool operator!=(const FeatureSpec& other) const { return !(*this == other); } private: PackageSpec m_spec; std::string m_feature; }; struct FullPackageSpec { PackageSpec package_spec; std::vector features; static std::vector to_feature_specs(const std::vector& specs); static ExpectedT from_string(const std::string& spec_as_string, const Triplet& default_triplet); }; struct Features { std::string name; std::vector features; static ExpectedT from_string(const std::string& input); }; bool operator==(const PackageSpec& left, const PackageSpec& right); bool operator!=(const PackageSpec& left, const PackageSpec& right); } namespace std { template<> struct hash { size_t operator()(const vcpkg::PackageSpec& value) const { size_t hash = 17; hash = hash * 31 + std::hash()(value.name()); hash = hash * 31 + std::hash()(value.triplet()); return hash; } }; template<> struct equal_to { bool operator()(const vcpkg::PackageSpec& left, const vcpkg::PackageSpec& right) const { return left == right; } }; }