cemu-vcpkg/toolsrc/include/vcpkg/statusparagraphs.h

83 lines
3.8 KiB
C
Raw Normal View History

2016-09-18 20:50:08 -07:00
#pragma once
#include <vcpkg/statusparagraph.h>
#include <iterator>
#include <memory>
2016-09-18 20:50:08 -07:00
namespace vcpkg
{
[vcpkg] Implement Default-Features (#2697) * [vcpkg] Add Default-Feature to make_status_pgh utility function Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Parse "Default-Features" as dependencies and add test for parsing Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Document some methods and structures Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Add install_default_features_test Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Change install_default_features_test to not have preinstalled package * [vcpkg] Test install behaviour of default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test default features upgrade behavior Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement upgrade with default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test behaviour of upgrade with default features in dependencies Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Make upgrade install new default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Move collecting of packages for which to prevent defaults Further down the line to create_feature_install_plan. Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Fix core missing from default features and potential inf loop Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Rename, fix and move some tests Signed-off-by: Squareys <squareys@googlemail.com>
2018-02-15 01:18:25 +01:00
/// <summary>Status paragraphs</summary>
///
/// Collection of <see cref="vcpkg::StatusParagraph"/>, e.g. contains the information
/// about whether a package is installed or not.
///
2016-09-18 20:50:08 -07:00
struct StatusParagraphs
{
StatusParagraphs();
explicit StatusParagraphs(std::vector<std::unique_ptr<StatusParagraph>>&& ps);
using container = std::vector<std::unique_ptr<StatusParagraph>>;
using iterator = container::reverse_iterator;
using const_iterator = container::const_reverse_iterator;
/// <summary>Find the StatusParagraph for given spec.</summary>
/// <param name="spec">Package specification to find the status paragraph for</param>
/// <returns>Iterator for found spec</returns>
const_iterator find(const PackageSpec& spec) const { return find(spec.name(), spec.triplet()); }
/// <summary>Find the StatusParagraph for given feature spec.</summary>
/// <param name="spec">Feature specification to find the status paragraph for</param>
/// <returns>Iterator for found spec</returns>
const_iterator find(const FeatureSpec& spec) const { return find(spec.name(), spec.triplet(), spec.feature()); }
/// <summary>Find a StatusParagraph by name, triplet and feature.</summary>
/// <param name="name">Package name</param>
/// <param name="triplet">Triplet</param>
/// <param name="feature">Feature name</param>
/// <returns>Iterator for found spec</returns>
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<std::unique_ptr<StatusParagraph>*> find_all(const std::string& name, Triplet triplet);
2017-04-07 14:42:19 -07:00
Optional<InstalledPackageView> get_installed_package_view(const PackageSpec& spec) const;
/// <summary>Find the StatusParagraph for given spec if installed</summary>
/// <param name="spec">Package specification to find the status for</param>
/// <returns>Iterator for found spec</returns>
const_iterator find_installed(const PackageSpec& spec) const;
/// <summary>Find the StatusParagraph for given feature spec if installed</summary>
/// <param name="spec">Feature specification to find the status for</param>
/// <returns>Iterator for found spec</returns>
const_iterator find_installed(const FeatureSpec& spec) const;
/// <summary>Find the StatusParagraph for given spec and return its install status</summary>
/// <param name="spec">Package specification to check if installed</param>
/// <returns>`true` if installed, `false` if not or not found.</returns>
bool is_installed(const PackageSpec& spec) const;
2016-09-18 20:50:08 -07:00
/// <summary>Find the StatusParagraph for given feature spec and return its install status</summary>
/// <param name="spec">Feature specification to check if installed</param>
/// <returns>`true` if installed, `false` if not or not found.</returns>
bool is_installed(const FeatureSpec& spec) const;
2016-09-18 20:50:08 -07:00
iterator insert(std::unique_ptr<StatusParagraph>);
friend void serialize(const StatusParagraphs& pgh, std::string& out_str);
2016-09-18 20:50:08 -07:00
iterator end() { return paragraphs.rend(); }
2016-09-18 20:50:08 -07:00
const_iterator end() const { return paragraphs.rend(); }
2016-09-18 20:50:08 -07:00
iterator begin() { return paragraphs.rbegin(); }
2016-09-18 20:50:08 -07:00
const_iterator begin() const { return paragraphs.rbegin(); }
2016-09-18 20:50:08 -07:00
private:
std::vector<std::unique_ptr<StatusParagraph>> paragraphs;
};
void serialize(const StatusParagraphs& pgh, std::string& out_str);
2016-09-18 20:50:08 -07:00
}