From 2a362e8f024c032e14cff13cbca2a27a47c79448 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 30 Aug 2018 23:17:15 +0300 Subject: Add package manifest flags --- libbpkg/manifest.hxx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 20ff344..42e1a24 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -378,6 +378,56 @@ namespace bpkg comment (std::move (c)) {} }; + // Package manifest value forbid/require flags. + // + // Some package manifest values can be forbidden or required for certain + // repository types and in specific contexts (for example, when parsing an + // individual manifest, a manifest list, etc). + // + // Also note that, naturally, the forbid_* and require_* flags are mutually + // exclusive for the same value. + // + enum class package_manifest_flags: std::uint16_t + { + none = 0x0, + + forbid_file = 0x1, // Forbid *-file manifest values. + forbid_location = 0x2, + forbid_sha256sum = 0x4, + forbid_fragment = 0x8, + + require_location = 0x10, + require_sha256sum = 0x20 + }; + + inline package_manifest_flags + operator&= (package_manifest_flags& x, package_manifest_flags y) + { + return x = static_cast ( + static_cast (x) & + static_cast (y)); + } + + inline package_manifest_flags + operator|= (package_manifest_flags& x, package_manifest_flags y) + { + return x = static_cast ( + static_cast (x) | + static_cast (y)); + } + + inline package_manifest_flags + operator& (package_manifest_flags x, package_manifest_flags y) + { + return x &= y; + } + + inline package_manifest_flags + operator| (package_manifest_flags x, package_manifest_flags y) + { + return x |= y; + } + class LIBBPKG_EXPORT package_manifest { public: @@ -418,7 +468,25 @@ namespace bpkg public: package_manifest () = default; // VC export. - package_manifest (butl::manifest_parser&, bool ignore_unknown = false); + + // Create individual manifest. + // + // The default package_manifest_flags value corresponds to a valid + // individual package manifest. + // + package_manifest (butl::manifest_parser&, + bool ignore_unknown = false, + 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&, + butl::manifest_name_value start, + bool ignore_unknown, + package_manifest_flags); void serialize (butl::manifest_serializer&) const; -- cgit v1.1