aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-10-07 07:05:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-10-07 07:05:57 +0200
commit957303d2f146bc9b12aaaa39c752212ca94dc4eb (patch)
treede208741969a836a3f6a8a9475cfe07aab373cbb
parentf82ed52a4959cecae176600180f967328d924ce6 (diff)
Add complete set of version comparison operators
-rw-r--r--bpkg/package29
1 files changed, 29 insertions, 0 deletions
diff --git a/bpkg/package b/bpkg/package
index ac0ac0f..12079f6 100644
--- a/bpkg/package
+++ b/bpkg/package
@@ -456,6 +456,15 @@ namespace bpkg
template <typename T1, typename T2>
inline auto
+ operator!= (const T1& x, const T2& y) -> decltype (x.epoch != y.epoch)
+ {
+ return x.epoch != y.epoch ||
+ x.canonical_upstream != y.canonical_upstream ||
+ x.revision != y.revision;
+ }
+
+ template <typename T1, typename T2>
+ inline auto
operator< (const T1& x, const T2& y) -> decltype (x.epoch < y.epoch)
{
return x.epoch < y.epoch ||
@@ -466,6 +475,16 @@ namespace bpkg
template <typename T1, typename T2>
inline auto
+ operator<= (const T1& x, const T2& y) -> decltype (x.epoch <= y.epoch)
+ {
+ return x.epoch < y.epoch ||
+ (x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.revision <= y.revision);
+ }
+
+ template <typename T1, typename T2>
+ inline auto
operator> (const T1& x, const T2& y) -> decltype (x.epoch > y.epoch)
{
return x.epoch > y.epoch ||
@@ -474,6 +493,16 @@ namespace bpkg
x.revision > y.revision);
}
+ template <typename T1, typename T2>
+ inline auto
+ operator>= (const T1& x, const T2& y) -> decltype (x.epoch >= y.epoch)
+ {
+ return x.epoch > y.epoch ||
+ (x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) ||
+ (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream &&
+ x.revision >= y.revision);
+ }
+
template <typename T>
inline auto
order_by_version_desc (const T& x) -> //decltype ("ORDER BY" + x.epoch)