From 35359f038f571dc46de3d14af72a2bc911fb0a24 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 18 Mar 2020 22:17:49 +0300 Subject: Implement brep-monitor --- libbrep/common.hxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libbrep/common.hxx') 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 #include // static_assert +#include + #include #include @@ -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 + inline auto + equal (const ID& x, const package_id& y) + -> decltype (x.tenant == odb::query::_ref (y.tenant) && + x.name == odb::query::_ref (y.name) && + x.version.epoch == odb::query::_ref (y.version.epoch)) + { + using query = odb::query; + + 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 -- cgit v1.1