libzypp 17.31.23
|
Functions | |
template<class Tp , class TCompare > | |
bool | zypp::compareByRel (Rel op, const Tp &lhs, const Tp &rhs, TCompare compare) |
Comparison of two elements using relational operator op. | |
Take a class like zypp::Edition. Editions are comaprable. You can compare them lexicographical, or according to their version and release values, or match them (i.e. taking empty version or release values as wildcard).
No matter which way is appropriate within a certain context. You need functions to compare, and may want to use classes like zypp::Range, based on the desired comparison.
All the class has to do, is providing a general comparison method (preferably static)
Compare<Tp>
provides a functor wrapping compare
. In case the general comparison method is named differently, the class, or you, have to provide an approriate functor.
compareByRel
then compares two elements using a certain operator and general comparison method.
Furthermore a bunch of functors using a certain operator is defined. All templated by type and general comparison method (defaults to Compare<Tp>).
Classes like zypp:Range are templated by by type and general comparison method as well. Thus you may use Edition ranges based on Edition::Compare, as well as ranges based on Edition::Match (Edition provides these two functors).
Again: Everything a class has to provide is the general comparison method. Comparison functors and ranges are then immediately available.
|
inline |
Comparison of two elements using relational operator op.
Expects TCompare to be a binary operator returning -1, 0, 1
if the elements compare <,==,>
.
true
. false
. Definition at line 108 of file RelCompare.h.