11#ifndef ZYPP_BASE_SETRELATIONMIXIN_H
12#define ZYPP_BASE_SETRELATIONMIXIN_H
17#include <zypp/base/Easy.h>
18#include <zypp/base/EnumClass.h>
37 static const std::string & asString(
Enum val_r );
43 inline std::ostream &
operator<<( std::ostream &
str,
const SetCompare::Enum & obj )
44 {
return str << SetCompare::asString( obj ); }
46 inline std::ostream &
operator<<( std::ostream &
str,
const SetCompare & obj )
47 {
return str << obj.asEnum(); }
68 static const std::string & asString(
Enum val_r );
74 inline std::ostream &
operator<<( std::ostream &
str,
const SetRelation::Enum & obj )
75 {
return str << SetRelation::asString( obj ); }
77 inline std::ostream &
operator<<( std::ostream &
str,
const SetRelation & obj )
78 {
return str << obj.asEnum(); }
81 inline bool operator==(
const SetRelation::Enum & lhs,
const SetCompare::Enum & rhs )
82 {
return( lhs&rhs || !(lhs|rhs) ); }
84 inline bool operator==(
const SetRelation::Enum & lhs,
const SetCompare & rhs )
85 {
return( lhs == rhs.asEnum() ); }
87 inline bool operator==(
const SetRelation & lhs,
const SetCompare::Enum & rhs )
88 {
return( lhs.asEnum() == rhs ); }
90 inline bool operator==(
const SetRelation & lhs,
const SetCompare & rhs )
91 {
return( lhs.asEnum() == rhs.asEnum() ); }
93 inline bool operator==(
const SetCompare::Enum & lhs,
const SetRelation::Enum & rhs )
94 {
return( rhs == lhs ); }
96 inline bool operator==(
const SetCompare::Enum & lhs,
const SetRelation & rhs )
97 {
return( rhs == lhs ); }
99 inline bool operator==(
const SetCompare & lhs,
const SetRelation::Enum & rhs )
100 {
return( rhs == lhs ); }
102 inline bool operator==(
const SetCompare & lhs,
const SetRelation & rhs )
103 {
return( rhs == lhs ); }
106 inline bool operator!=(
const SetRelation::Enum & lhs,
const SetCompare::Enum & rhs )
107 {
return !( lhs == rhs ); }
109 inline bool operator!=(
const SetRelation::Enum & lhs,
const SetCompare & rhs )
110 {
return !( lhs == rhs ); }
112 inline bool operator!=(
const SetRelation & lhs,
const SetCompare::Enum & rhs )
113 {
return !( lhs == rhs ); }
115 inline bool operator!=(
const SetRelation & lhs,
const SetCompare & rhs )
116 {
return !( lhs == rhs ); }
118 inline bool operator!=(
const SetCompare::Enum & lhs,
const SetRelation::Enum & rhs )
119 {
return !( lhs == rhs ); }
121 inline bool operator!=(
const SetCompare::Enum & lhs,
const SetRelation & rhs )
122 {
return !( lhs == rhs ); }
124 inline bool operator!=(
const SetCompare & lhs,
const SetRelation::Enum & rhs )
125 {
return !( lhs == rhs ); }
127 inline bool operator!=(
const SetCompare & lhs,
const SetRelation & rhs )
128 {
return !( lhs == rhs ); }
143 template <
class Derived>
148 SetCompare
compare(
const Derived & trg )
const
149 {
return derived().setRelationMixinCompare( trg ); }
155 bool compare(
const Derived & trg, SetCompare cmp )
const
156 {
return compare( trg ) == cmp; }
159 {
return compare( trg ) == cmp; }
162 bool compare(
const Derived & trg, SetRelation rel )
const
163 {
return compare( trg ) == rel; }
166 {
return compare( trg ) == rel; }
177 {
return *
static_cast<const Derived*
>( this ); }
181 template <
class Derived>
186 template <
class Derived>
188 {
return src.
compare( trg, cmp ); }
191 template <
class Derived>
193 {
return src.
compare( trg, rel ); }
196 template <
class Derived>
198 {
return src.
compare( trg, SetRelation::equal ); }
201 template <
class Derived>
203 {
return !( src == trg ); }
212#define SETRELATIONMIXIN_DEFINE_COMPARE_BETWEEN(DERIVED_TYPE,OTHER_TYPE) \
213 inline SetCompare compare( const base::SetRelationMixin<DERIVED_TYPE> & src, OTHER_TYPE trg ) \
214 { return src.compare( DERIVED_TYPE(trg) ); } \
215 inline SetCompare compare( OTHER_TYPE src, const base::SetRelationMixin<DERIVED_TYPE> & trg ) \
216 { return DERIVED_TYPE(src).compare( trg ); } \
218 inline bool compare( const base::SetRelationMixin<DERIVED_TYPE> & src, OTHER_TYPE trg, SetCompare cmp ) \
219 { return src.compare( DERIVED_TYPE(trg), cmp ); } \
220 inline bool compare( OTHER_TYPE src, const base::SetRelationMixin<DERIVED_TYPE> & trg, SetCompare cmp ) \
221 { return DERIVED_TYPE(src).compare( trg, cmp ); } \
223 inline bool compare( const base::SetRelationMixin<DERIVED_TYPE> & src, OTHER_TYPE trg, SetRelation rel ) \
224 { return src.compare( DERIVED_TYPE(trg), rel ); } \
225 inline bool compare( OTHER_TYPE src, const base::SetRelationMixin<DERIVED_TYPE> & trg, SetRelation rel ) \
226 { return DERIVED_TYPE(src).compare( trg, rel ); } \
228 inline bool operator==( const base::SetRelationMixin<DERIVED_TYPE> & src, OTHER_TYPE trg ) \
229 { return src.compare( DERIVED_TYPE(trg), SetRelation::equal ); } \
230 inline bool operator==( OTHER_TYPE src, const base::SetRelationMixin<DERIVED_TYPE> & trg ) \
231 { return DERIVED_TYPE(src).compare( trg, SetRelation::equal ); } \
233 inline bool operator!=( const base::SetRelationMixin<DERIVED_TYPE> & src, OTHER_TYPE trg ) \
234 { return !( src == trg ); } \
235 inline bool operator!=( OTHER_TYPE src, const base::SetRelationMixin<DERIVED_TYPE> & trg ) \
236 { return !( src == trg ); }
Provide set relation methods based on Derived::setRelationMixinCompare A class using this mixin must ...
bool compare(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg, SetCompare cmp)
Compare sets and match against SetCompare.
bool compare(const Derived &trg, SetRelation rel) const
Compare sets and match against SetRelation.
bool compare(const Derived &trg, SetCompare cmp) const
Compare sets and match against SetCompare.
DEFAULT_COPYABLE(SetRelationMixin)
bool compare(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg, SetRelation rel)
Compare sets and match against SetRelation.
DEFAULT_MOVABLE(SetRelationMixin)
SetCompare compare(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg)
Compare sets.
SetCompare compare(const SetRelationMixin< Derived > &trg) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool operator==(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg)
Equal.
bool operator!=(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg)
Unequal.
bool compare(const SetRelationMixin< Derived > &trg, SetCompare cmp) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool compare(const SetRelationMixin< Derived > &trg, SetRelation rel) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
SetCompare compare(const Derived &trg) const
Compare sets.
const Derived & derived() const
Access to sublass Derived.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
bool operator!=(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Result of set comparison (use like 'enum class SetCompare') This is the type a compare function shoul...
base::EnumClass< ESetCompareDef > SetCompare
typedef 'enum class SetCompare'
Set Relation based on SetCompare (use like 'enum class SetRelation') Comparison (== !...
base::EnumClass< ESetRelationDef > SetRelation
typedef 'enum class SetRelation'