From 7144cf3d2f25d546fd00df4fd1ddcda3f18e2c95 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Dec 2015 13:31:18 +0200 Subject: Add support for ignoring unknown manifest entries --- bpkg/manifest | 16 ++++++++++------ bpkg/manifest.cxx | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'bpkg') diff --git a/bpkg/manifest b/bpkg/manifest index 106b6ca..1d554d4 100644 --- a/bpkg/manifest +++ b/bpkg/manifest @@ -311,8 +311,10 @@ namespace bpkg butl::optional location; public: - package_manifest (manifest_parser&); - package_manifest (manifest_parser&, manifest_name_value start); + package_manifest (manifest_parser&, bool ignore_unknown = false); + package_manifest (manifest_parser&, + manifest_name_value start, + bool ignore_unknown = false); void serialize (manifest_serializer&) const; @@ -326,7 +328,7 @@ namespace bpkg using base_type::base_type; package_manifests () = default; - package_manifests (manifest_parser&); + package_manifests (manifest_parser&, bool ignore_unknown = false); void serialize (manifest_serializer&) const; @@ -477,8 +479,10 @@ namespace bpkg butl::optional description; public: - repository_manifest (manifest_parser&); - repository_manifest (manifest_parser&, manifest_name_value start); + repository_manifest (manifest_parser&, bool ignore_unknown = false); + repository_manifest (manifest_parser&, + manifest_name_value start, + bool ignore_unknown = false); void serialize (manifest_serializer&) const; @@ -504,7 +508,7 @@ namespace bpkg using base_type::base_type; repository_manifests () = default; - repository_manifests (manifest_parser&); + repository_manifests (manifest_parser&, bool ignore_unknown = false); void serialize (manifest_serializer&) const; diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index 3857c28..440bf2a 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -420,8 +420,8 @@ namespace bpkg // package_manifest // package_manifest:: - package_manifest (parser& p) - : package_manifest (p, p.next ()) // Delegate + package_manifest (parser& p, bool iu) + : package_manifest (p, p.next (), iu) // Delegate { // Make sure this is the end. // @@ -432,7 +432,7 @@ namespace bpkg } package_manifest:: - package_manifest (parser& p, name_value nv) + package_manifest (parser& p, name_value nv, bool iu) { auto bad_name ([&p, &nv](const string& d) { throw parsing (p.name (), nv.name_line, nv.name_column, d);}); @@ -782,7 +782,7 @@ namespace bpkg bad_value ("invalid package location"); } } - else + else if (!iu) bad_name ("unknown name '" + n + "' in package manifest"); } @@ -874,12 +874,12 @@ namespace bpkg // package_manifests // package_manifests:: - package_manifests (parser& p) + package_manifests (parser& p, bool iu) { name_value nv (p.next ()); while (!nv.empty ()) { - push_back (package_manifest (p, nv)); + push_back (package_manifest (p, nv, iu)); nv = p.next (); if (!back ().location) @@ -1178,8 +1178,8 @@ namespace bpkg // repository_manifest // repository_manifest:: - repository_manifest (parser& p) - : repository_manifest (p, p.next ()) // Delegate + repository_manifest (parser& p, bool iu) + : repository_manifest (p, p.next (), iu) // Delegate { // Make sure this is the end. // @@ -1190,7 +1190,7 @@ namespace bpkg } repository_manifest:: - repository_manifest (parser& p, name_value nv) + repository_manifest (parser& p, name_value nv, bool iu) { auto bad_name ([&p, &nv](const string& d) { throw parsing (p.name (), nv.name_line, nv.name_column, d);}); @@ -1285,7 +1285,7 @@ namespace bpkg description = move (v); } - else + else if (!iu) bad_name ("unknown name '" + n + "' in repository manifest"); } @@ -1389,12 +1389,12 @@ namespace bpkg // repository_manifests // repository_manifests:: - repository_manifests (parser& p) + repository_manifests (parser& p, bool iu) { name_value nv (p.next ()); while (!nv.empty ()) { - push_back (repository_manifest (p, nv)); + push_back (repository_manifest (p, nv, iu)); nv = p.next (); // Make sure there is location in all except the last entry. -- cgit v1.1