aboutsummaryrefslogtreecommitdiff
path: root/libbrep/common.hxx
diff options
context:
space:
mode:
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