libzypp 17.37.10

Rel.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_REL_H
13#define ZYPP_REL_H
14
15#include <iosfwd>
16#include <string>
17
18#include <zypp/Globals.h>
19
21 namespace zypp
22{
23
25 //
26 // CLASS NAME : Rel
27 //
45 struct ZYPP_API Rel
46 {
52 static const Rel EQ;
53 static const Rel NE;
54 static const Rel LT;
55 static const Rel LE;
56 static const Rel GT;
57 static const Rel GE;
58 static const Rel ANY;
59 static const Rel NONE;
61
67 enum for_use_in_switch {
68 NONE_e = 0U,
69 GT_e = 1U,
70 EQ_e = 2U,
71 LT_e = 4U,
72 GE_e = GT_e|EQ_e,
73 LE_e = LT_e|EQ_e,
74 NE_e = GT_e|LT_e,
75 ANY_e = GT_e|EQ_e|LT_e,
76 };
77
79 Rel()
80 : _op( ANY_e )
81 {}
82
93 explicit
94 Rel( const std::string & strval_r );
95
99 Rel( const std::string & strval_r, const Rel & default_r );
100
104 bool parseFrom( const std::string & strval_r );
105
107 explicit
108 Rel( unsigned bits_r )
109 : _op( for_use_in_switch(bits_r & ANY_e) )
110 {}
111
113 static bool isRel( unsigned bits_r )
114 { return (bits_r & ANY_e) == bits_r; }
115
119 const std::string & asString() const;
121 const char * c_str() const
122 { return asString().c_str(); }
123
143 for_use_in_switch inSwitch() const
144 { return _op; }
145
147 unsigned bits() const
148 { return _op; }
149
150 private:
152 Rel( for_use_in_switch op_r )
153 : _op( op_r )
154 {}
155
156 for_use_in_switch _op;
157 };
158
159
161 inline std::ostream & operator<<( std::ostream & str, const Rel & obj )
162 { return str << obj.asString(); }
163
165
167 inline bool operator==( const Rel & lhs, const Rel & rhs )
168 { return lhs.inSwitch() == rhs.inSwitch(); }
169
171 inline bool operator!=( const Rel & lhs, const Rel & rhs )
172 { return ! ( lhs == rhs ); }
173
175} // namespace zypp
177#endif // ZYPP_REL_H
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
zypp::Rel
Relational operators.
Definition Rel.h:46
zypp::Rel::inSwitch
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition Rel.h:143
zypp::Rel::LT
static const Rel LT
Definition Rel.h:54
zypp::Rel::c_str
const char * c_str() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Rel.h:121
zypp::Rel::GT
static const Rel GT
Definition Rel.h:56
zypp::Rel::Rel
Rel()
DefaultCtor ANY.
Definition Rel.h:79
zypp::Rel::Rel
Rel(for_use_in_switch op_r)
Ctor to initialize the relational operator contants.
Definition Rel.h:152
zypp::Rel::LE
static const Rel LE
Definition Rel.h:55
zypp::Rel::Rel
Rel(unsigned bits_r)
Ctor from bits.
Definition Rel.h:108
zypp::Rel::GE
static const Rel GE
Definition Rel.h:57
zypp::Rel::NONE
static const Rel NONE
Definition Rel.h:59
zypp::Rel::operator<<
std::ostream & operator<<(std::ostream &str, const Rel &obj)
Stream output.
Definition Rel.h:161
zypp::Rel::operator!=
bool operator!=(const Rel &lhs, const Rel &rhs)
Definition Rel.h:171
zypp::Rel::NE
static const Rel NE
Definition Rel.h:53
zypp::Rel::ANY
static const Rel ANY
Definition Rel.h:58
zypp::Rel::operator==
bool operator==(const Rel &lhs, const Rel &rhs)
Definition Rel.h:167
zypp::Rel::EQ
static const Rel EQ
Definition Rel.h:52
zypp::Rel::for_use_in_switch
for_use_in_switch
Enumarators provided only for use inSwitch statement.
Definition Rel.h:67
zypp::Rel::ANY_e
@ ANY_e
Definition Rel.h:75
zypp::Rel::LT_e
@ LT_e
Definition Rel.h:71
zypp::Rel::GT_e
@ GT_e
Definition Rel.h:69
zypp::Rel::NE_e
@ NE_e
Definition Rel.h:74
zypp::Rel::LE_e
@ LE_e
Definition Rel.h:73
zypp::Rel::NONE_e
@ NONE_e
Definition Rel.h:68
zypp::Rel::EQ_e
@ EQ_e
Definition Rel.h:70
zypp::Rel::GE_e
@ GE_e
Definition Rel.h:72
zypp::Rel::bits
unsigned bits() const
Enumarator values suitable for libsolv.
Definition Rel.h:147
zypp::Rel::_op
for_use_in_switch _op
The operator.
Definition Rel.h:156
zypp::Rel::isRel
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
Definition Rel.h:113
zypp::Rel::asString
const std::string & asString() const
String representation of relational operator.
Definition Rel.cc:105
Globals.h