From 8e1998d8ebdb9ead5e432201998cb4db70918f95 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Dec 2015 17:48:21 +0200 Subject: Support version release --- bpkg/manifest | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'bpkg/manifest') diff --git a/bpkg/manifest b/bpkg/manifest index 1d554d4..e53bc69 100644 --- a/bpkg/manifest +++ b/bpkg/manifest @@ -7,6 +7,7 @@ #include #include +#include #include // uint16_t #include #include // move() @@ -31,12 +32,17 @@ namespace bpkg // const std::uint16_t epoch; const std::string upstream; + const std::string release; const std::uint16_t revision; // Upstream part canonical representation. // const std::string canonical_upstream; + // Release part canonical representation. + // + const std::string canonical_release; + // Create a special empty version. // version (): epoch (0), revision (0) {} @@ -48,13 +54,14 @@ namespace bpkg version (const std::string& v): version (v.c_str ()) {} explicit - version (const char* v): version (data_type (v, false)) {} + version (const char* v): version (data_type (v, data_type::parse::full)) {} - // Create the version object from separate epoch, upstream, and + // Create the version object from separate epoch, upstream, release, and // revision parts. // version (std::uint16_t epoch, std::string upstream, + std::string release, std::uint16_t revision); version (version&&) = default; @@ -92,6 +99,9 @@ namespace bpkg if (int c = canonical_upstream.compare (v.canonical_upstream)) return c; + if (int c = canonical_release.compare (v.canonical_release)) + return c; + if (!ignore_revision && revision != v.revision) return revision < v.revision ? -1 : 1; @@ -101,30 +111,34 @@ namespace bpkg bool empty () const noexcept { - // No sense to test epoch and revision for 0 as properly constructed - // version object can not have them different from 0 if upstream is - // empty. - // - return upstream.empty (); + bool e (upstream.empty ()); + assert (!e || (epoch == 0 && release.empty () && revision == 0)); + return e; } private: struct data_type { - data_type (const char*, bool upstream_only); + enum class parse {full, upstream, release}; + + data_type (const char*, parse); std::uint16_t epoch; std::string upstream; + std::string release; std::uint16_t revision; std::string canonical_upstream; + std::string canonical_release; }; explicit version (data_type&& d) : epoch (d.epoch), upstream (std::move (d.upstream)), + release (std::move (d.release)), revision (d.revision), - canonical_upstream (std::move (d.canonical_upstream)) {} + canonical_upstream (std::move (d.canonical_upstream)), + canonical_release (std::move (d.canonical_release)) {} }; inline std::ostream& -- cgit v1.1