From 6e90b57a442424876b1325b9209f79c8a885a479 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Jul 2017 11:27:47 +0300 Subject: Make use of foreign package objects in build-related functionality --- libbrep/common.hxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libbrep/common.hxx') diff --git a/libbrep/common.hxx b/libbrep/common.hxx index 6bc5aca..56d6768 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -201,6 +201,13 @@ namespace brep } }; + // repository_location + // + using bpkg::repository_location; + + #pragma db map type(repository_location) as(string) \ + to((?).string ()) from(brep::repository_location (?)) + // Version comparison operators. // // They allow comparing objects that have epoch, canonical_upstream, @@ -330,6 +337,8 @@ namespace brep + x.revision + "DESC"; } + // Package id comparison operators. + // inline bool operator< (const package_id& x, const package_id& y) { @@ -338,6 +347,26 @@ namespace brep return compare_version_lt (x.version, y.version, true); } + + // They allow comparing objects that have name and version data members. The + // idea is that this works for both query members of package id types (in + // particular in join conditions) as well as for values of package_id type. + // + template + inline auto + operator== (const T1& x, const T2& y) + -> decltype (x.name == y.name && x.version.epoch == y.version.epoch) + { + return x.name == y.name && compare_version_eq (x.version, y.version, true); + } + + template + inline auto + operator!= (const T1& x, const T2& y) + -> decltype (x.name == y.name && x.version.epoch == y.version.epoch) + { + return x.name != y.name || compare_version_ne (x.version, y.version, true); + } } #endif // LIBBREP_COMMON_HXX -- cgit v1.1