libzypp  17.36.7
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 
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 
144  { return _op; }
145 
147  unsigned bits() const
148  { return _op; }
149 
150  private:
153  : _op( op_r )
154  {}
157  };
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
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:122
static const Rel NE
Definition: Rel.h:53
static const Rel LT
Definition: Rel.h:54
static const Rel GT
Definition: Rel.h:56
Rel(for_use_in_switch op_r)
Ctor to initialize the relational operator contants.
Definition: Rel.h:152
const std::string & asString() const
String representation of relational operator.
Definition: Rel.cc:105
Relational operators.
Definition: Rel.h:45
static const Rel EQ
Definition: Rel.h:52
String related utilities and Regular expression matching.
static const Rel LE
Definition: Rel.h:55
static const Rel ANY
Definition: Rel.h:58
bool operator==(const Rel &lhs, const Rel &rhs)
Definition: Rel.h:167
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
Definition: Rel.h:113
const char * c_str() const
Definition: Rel.h:121
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
static const Rel GE
Definition: Rel.h:57
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition: Rel.h:143
unsigned bits() const
Enumarator values suitable for libsolv.
Definition: Rel.h:147
for_use_in_switch _op
The operator.
Definition: Rel.h:156
Rel()
DefaultCtor ANY.
Definition: Rel.h:79
for_use_in_switch
Enumarators provided only for use inSwitch statement.
Definition: Rel.h:67
std::ostream & operator<<(std::ostream &str, const Rel &obj)
Definition: Rel.h:161
Rel(unsigned bits_r)
Ctor from bits.
Definition: Rel.h:108
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
bool operator!=(const Rel &lhs, const Rel &rhs)
Definition: Rel.h:171
static const Rel NONE
Definition: Rel.h:59