aboutsummaryrefslogtreecommitdiff
path: root/libbrep/common.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-03-18 22:17:49 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-03-27 17:28:44 +0300
commit35359f038f571dc46de3d14af72a2bc911fb0a24 (patch)
treede3e89d678e78b9efc4d395274fd7ccc68f4a213 /libbrep/common.hxx
parent8ad672cc7211952716ffe1fbf76c179b4f1149e3 (diff)
Implement brep-monitor
Diffstat (limited to 'libbrep/common.hxx')
-rw-r--r--libbrep/common.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index 44028df..b7fc2da 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -8,6 +8,8 @@
#include <chrono>
#include <type_traits> // static_assert
+#include <odb/query.hxx>
+
#include <libbpkg/package-name.hxx>
#include <libbrep/types.hxx>
@@ -510,6 +512,34 @@ namespace brep
compare_version_ne (x.version, y.version, true);
}
+ // Allow comparing the query members with the query parameters bound by
+ // reference to variables of the package id type (in particular in the
+ // prepared queries).
+ //
+ // Note that it is not operator==() since the query template parameter type
+ // can not be deduced from the function parameter types and needs to be
+ // specified explicitly.
+ //
+ template <typename T, typename ID>
+ inline auto
+ equal (const ID& x, const package_id& y)
+ -> decltype (x.tenant == odb::query<T>::_ref (y.tenant) &&
+ x.name == odb::query<T>::_ref (y.name) &&
+ x.version.epoch == odb::query<T>::_ref (y.version.epoch))
+ {
+ using query = odb::query<T>;
+
+ const auto& qv (x.version);
+ const canonical_version& v (y.version);
+
+ return x.tenant == query::_ref (y.tenant) &&
+ x.name == query::_ref (y.name) &&
+ qv.epoch == query::_ref (v.epoch) &&
+ qv.canonical_upstream == query::_ref (v.canonical_upstream) &&
+ qv.canonical_release == query::_ref (v.canonical_release) &&
+ qv.revision == query::_ref (v.revision);
+ }
+
// Repository id comparison operators.
//
inline bool