libzypp: zypp/CapMatch.h Source File

libzypp 17.38.14

CapMatch.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_CAPMATCH_H
13#define ZYPP_CAPMATCH_H
14
15#include <iosfwd>
16#include <zypp-core/Globals.h>
17
19namespace zypp
20{
21
23 //
24 // CLASS NAME : CapMatch
25 //
38 class ZYPP_API CapMatch
39 {
40 enum Result { NOMATCH, MATCH, IRRELEVANT };
41
42 public:
43
44 CapMatch()
45 : _result( IRRELEVANT )
46 {}
47
48 CapMatch( bool val_r )
49 : _result( val_r ? MATCH : NOMATCH )
50 {}
51
52 static const CapMatch yes;
53 static const CapMatch no;
54 static const CapMatch irrelevant;
55
56 friend bool operator==( const CapMatch & lhs, const CapMatch & rhs )
57 { return lhs._result == rhs._result; }
58
59 friend bool operator!=( const CapMatch & lhs, const CapMatch & rhs )
60 { return lhs._result != rhs._result; }
61
62 friend CapMatch operator!( const CapMatch & lhs )
63 {
64 if ( lhs._result == CapMatch::IRRELEVANT )
65 return lhs;
66 return !(lhs._result == CapMatch::MATCH);
67 }
68
69 friend CapMatch operator&&( const CapMatch & lhs, const CapMatch & rhs )
70 {
71 if ( lhs._result == CapMatch::IRRELEVANT )
72 return rhs;
73 if ( rhs._result == CapMatch::IRRELEVANT )
74 return lhs;
75 return (lhs._result == CapMatch::MATCH)
76 && (rhs._result == CapMatch::MATCH);
77 }
78
79 friend CapMatch operator||( const CapMatch & lhs, const CapMatch & rhs )
80 {
81 if ( lhs._result == CapMatch::IRRELEVANT )
82 return rhs;
83 if ( rhs._result == CapMatch::IRRELEVANT )
84 return lhs;
85 return (lhs._result == CapMatch::MATCH)
86 || (rhs._result == CapMatch::MATCH);
87 }
88
89 friend std::ostream & operator<<( std::ostream & str, const CapMatch & obj );
90
91 private:
92 Result _result;
93 };
94
95
97 std::ostream & operator<<( std::ostream & str, const CapMatch & obj ) ZYPP_API;
98
100} // namespace zypp
102#endif // ZYPP_CAPMATCH_H
Globals.h
Provides API related macros.
zypp::CapMatch
Tri state Capability match result.
Definition CapMatch.h:39
zypp::CapMatch::operator!=
friend bool operator!=(const CapMatch &lhs, const CapMatch &rhs)
Definition CapMatch.h:59
zypp::CapMatch::operator==
friend bool operator==(const CapMatch &lhs, const CapMatch &rhs)
Definition CapMatch.h:56
zypp::CapMatch::_result
Result _result
Definition CapMatch.h:92
zypp::CapMatch::no
static const CapMatch no
Definition CapMatch.h:53
zypp::CapMatch::irrelevant
static const CapMatch irrelevant
Definition CapMatch.h:54
zypp::CapMatch::yes
static const CapMatch yes
Definition CapMatch.h:52
zypp::CapMatch::CapMatch
CapMatch(bool val_r)
Definition CapMatch.h:48
zypp::CapMatch::CapMatch
CapMatch()
Definition CapMatch.h:44
zypp::CapMatch::operator!
friend CapMatch operator!(const CapMatch &lhs)
Definition CapMatch.h:62
zypp::CapMatch::Result
Result
Definition CapMatch.h:40
zypp::CapMatch::MATCH
@ MATCH
Definition CapMatch.h:40
zypp::CapMatch::NOMATCH
@ NOMATCH
Definition CapMatch.h:40
zypp::CapMatch::IRRELEVANT
@ IRRELEVANT
Definition CapMatch.h:40
zypp::CapMatch::operator&&
friend CapMatch operator&&(const CapMatch &lhs, const CapMatch &rhs)
Definition CapMatch.h:69
zypp::CapMatch::operator||
friend CapMatch operator||(const CapMatch &lhs, const CapMatch &rhs)
Definition CapMatch.h:79
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65