aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-23 17:48:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-01-08 16:07:37 +0200
commit8e1998d8ebdb9ead5e432201998cb4db70918f95 (patch)
tree8ea6cc85665e77e65b8bfa4eb16a10256ed449c4 /bpkg/manifest
parent9863b40b7d3df92f1a6b975b372586fbc0c6b404 (diff)
Support version release
Diffstat (limited to 'bpkg/manifest')
-rw-r--r--bpkg/manifest32
1 files changed, 23 insertions, 9 deletions
diff --git a/bpkg/manifest b/bpkg/manifest
index 1d554d4..e53bc69 100644
--- a/bpkg/manifest
+++ b/bpkg/manifest
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include <cassert>
#include <cstdint> // uint16_t
#include <ostream>
#include <algorithm> // 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&