libzypp 17.37.10

Range.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_RANGE_H
13#define ZYPP_RANGE_H
14
15#include <zypp/RelCompare.h>
16
18 namespace zypp
19{
20
21 namespace range_detail
22 {
23 bool overlaps( Rel lhs, Rel rhs, int cmp );
24 }
25
27 //
28 // CLASS NAME : Range
29 //
33 template<class Tp, class TCompare = Compare<Tp> >
34 struct Range
35 {
37 Rel op;
39 Tp value;
40
42 Range()
43 : op( Rel::ANY )
44 {}
45
47 Range( const Tp & value_r )
48 : op( Rel::EQ )
49 , value( value_r )
50 {}
51
53 Range( Rel op_r, const Tp & value_r )
54 : op( op_r )
55 , value( value_r )
56 {}
57
59 bool overlaps( const Range & rhs ) const
60 { return range_detail::overlaps( op, rhs.op, TCompare()( value, rhs.value ) ); }
61 };
62
63
64 template<class Tp, class TCompare>
65 inline bool overlaps( const Range<Tp,TCompare> & lhs,
66 const Range<Tp,TCompare> & rhs )
67 { return lhs.overlaps( rhs ); }
68
70
71 template<class Tp, class TCompare>
72 inline bool operator==( const Range<Tp,TCompare> & lhs,
73 const Range<Tp,TCompare> & rhs )
74 {
75 return( lhs.op == rhs.op
76 && ( lhs.op == Rel::ANY
77 || lhs.op == Rel::NONE
78 || relCompare( Rel::EQ, lhs.value, rhs.value, TCompare() )
79 )
80 );
81 }
82
83 template<class Tp, class TCompare>
84 inline bool operator!=( const Range<Tp,TCompare> & lhs,
85 const Range<Tp,TCompare> & rhs )
86 { return ! ( lhs == rhs ); }
87
89} // namespace zypp
91#endif // ZYPP_RANGE_H
RelCompare.h
zypp::range_detail
Definition Range.cc:24
zypp::range_detail::overlaps
bool overlaps(Rel lhs, Rel rhs, int cmp)
Compute Range overlaps.
Definition Range.cc:30
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator==
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...
Definition SetRelationMixin.h:84
zypp::overlaps
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
Definition Range.h:65
zypp::operator!=
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...
Definition SetRelationMixin.h:109
zypp::Range
Definition Range.h:35
zypp::Range::Range
Range(Rel op_r, const Tp &value_r)
Ctor taking Rel and Tp.
Definition Range.h:53
zypp::Range::Range
Range(const Tp &value_r)
Ctor taking Tp (Rel::EQ).
Definition Range.h:47
zypp::Range< Edition >::value
Edition value
Definition Range.h:39
zypp::Range::Range
Range()
Default ctor: Rel::ANY.
Definition Range.h:42
zypp::Range< Edition >::op
Rel op
Definition Range.h:37
zypp::Range::overlaps
bool overlaps(const Range &rhs) const
Return whether two Ranges overlap.
Definition Range.h:59
zypp::Rel
Relational operators.
Definition Rel.h:46
zypp::Rel::NONE
static const Rel NONE
Definition Rel.h:59
zypp::Rel::ANY
static const Rel ANY
Definition Rel.h:58
zypp::Rel::EQ
static const Rel EQ
Definition Rel.h:52