From 67d7cdd57d3076ccf4c44de3a6b8045bb67d1441 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 9 Oct 2021 22:03:13 +0300 Subject: Add package_manifest constructors accepting manifest values list --- libbpkg/manifest.hxx | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 4aa9b73..8a11a85 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -429,10 +429,23 @@ namespace bpkg dependency_alternatives () = default; dependency_alternatives (bool d, bool b, std::string c) : conditional (d), buildtime (b), comment (std::move (c)) {} + + // Parse the dependency alternatives string representation in the + // `[?][*] [ '|' ]* [; ]` form. Throw + // std::invalid_argument if the value is invalid. + // + explicit LIBBPKG_EXPORT + dependency_alternatives (const std::string&); + + LIBBPKG_EXPORT std::string + string () const; }; - LIBBPKG_EXPORT std::ostream& - operator<< (std::ostream&, const dependency_alternatives&); + inline std::ostream& + operator<< (std::ostream& os, const dependency_alternatives& da) + { + return os << da.string (); + } // requires // @@ -846,6 +859,31 @@ namespace bpkg package_manifest_flags::forbid_sha256sum | package_manifest_flags::forbid_fragment); + // As above but construct the package manifest from the pre-parsed + // manifest values list. + // + // Note that the list is expected not to contain the format version nor + // the end-of-manifest/stream pairs. + // + package_manifest (const std::string& name, + std::vector&&, + bool ignore_unknown = false, + bool complete_dependencies = true, + package_manifest_flags = + package_manifest_flags::forbid_location | + package_manifest_flags::forbid_sha256sum | + package_manifest_flags::forbid_fragment); + + package_manifest (const std::string& name, + std::vector&&, + const std::function&, + bool ignore_unknown = false, + bool complete_depends = true, + package_manifest_flags = + package_manifest_flags::forbid_location | + package_manifest_flags::forbid_sha256sum | + package_manifest_flags::forbid_fragment); + // Create an element of the list manifest. // package_manifest (butl::manifest_parser&, -- cgit v1.1