#pragma once #include #include #include namespace vcpkg { /// Status paragraphs /// /// Collection of , e.g. contains the information /// about whether a package is installed or not. /// struct StatusParagraphs { StatusParagraphs(); explicit StatusParagraphs(std::vector>&& ps); using container = std::vector>; using iterator = container::reverse_iterator; using const_iterator = container::const_reverse_iterator; /// Find the StatusParagraph for given spec. /// Package specification to find the status paragraph for /// Iterator for found spec const_iterator find(const PackageSpec& spec) const { return find(spec.name(), spec.triplet()); } /// Find the StatusParagraph for given feature spec. /// Feature specification to find the status paragraph for /// Iterator for found spec const_iterator find(const FeatureSpec& spec) const { return find(spec.name(), spec.triplet(), spec.feature()); } /// Find a StatusParagraph by name, triplet and feature. /// Package name /// Triplet /// Feature name /// Iterator for found spec iterator find(const std::string& name, Triplet triplet, const std::string& feature = ""); const_iterator find(const std::string& name, Triplet triplet, const std::string& feature = "") const; std::vector*> find_all(const std::string& name, Triplet triplet); Optional get_installed_package_view(const PackageSpec& spec) const; /// Find the StatusParagraph for given spec if installed /// Package specification to find the status for /// Iterator for found spec const_iterator find_installed(const PackageSpec& spec) const; /// Find the StatusParagraph for given feature spec if installed /// Feature specification to find the status for /// Iterator for found spec const_iterator find_installed(const FeatureSpec& spec) const; /// Find the StatusParagraph for given spec and return its install status /// Package specification to check if installed /// `true` if installed, `false` if not or not found. bool is_installed(const PackageSpec& spec) const; /// Find the StatusParagraph for given feature spec and return its install status /// Feature specification to check if installed /// `true` if installed, `false` if not or not found. bool is_installed(const FeatureSpec& spec) const; iterator insert(std::unique_ptr); friend void serialize(const StatusParagraphs& pgh, std::string& out_str); iterator end() { return paragraphs.rend(); } const_iterator end() const { return paragraphs.rend(); } iterator begin() { return paragraphs.rbegin(); } const_iterator begin() const { return paragraphs.rbegin(); } private: std::vector> paragraphs; }; void serialize(const StatusParagraphs& pgh, std::string& out_str); }