|
libzypp
15.22.2
|
Relational operators. More...
#include <Rel.h>
Public Types | |
| enum | for_use_in_switch { NONE_e = 0U, GT_e = 1U, EQ_e = 2U, LT_e = 4U, GE_e = GT_e|EQ_e, LE_e = LT_e|EQ_e, NE_e = GT_e|LT_e, ANY_e = GT_e|EQ_e|LT_e } |
| Enumarators provided only for use inSwitch statement. More... | |
Public Member Functions | |
| Rel () | |
| DefaultCtor ANY. More... | |
| Rel (const std::string &strval_r) | |
| Ctor from string. More... | |
| Rel (const std::string &strval_r, const Rel &default_r) | |
| Ctor from string (non-throwing). More... | |
| bool | parseFrom (const std::string &strval_r) |
| Assign from string IFF it contains a legal value. More... | |
| Rel (unsigned bits_r) | |
| Ctor from bits. More... | |
| const std::string & | asString () const |
| String representation of relational operator. More... | |
| const char * | c_str () const |
| for_use_in_switch | inSwitch () const |
Enumarator provided for use in switch statement. More... | |
| unsigned | bits () const |
| Enumarator values suitable for libsolv. More... | |
Static Public Member Functions | |
| static bool | isRel (unsigned bits_r) |
| Test whether bits_r is a valid Rel (no extra bits set). More... | |
Static Public Attributes | |
Relational operators | |
These are the real relational operator contants to use. Don't mind that it's not an enum. See also: zypp::Rel::inSwitch | |
| static const Rel | EQ |
| static const Rel | NE |
| static const Rel | LT |
| static const Rel | LE |
| static const Rel | GT |
| static const Rel | GE |
| static const Rel | ANY |
| static const Rel | NONE |
Private Member Functions | |
| Rel (for_use_in_switch op_r) | |
| Ctor to initialize the relational operator contants. More... | |
Private Attributes | |
| for_use_in_switch | _op |
| The operator. More... | |
Related Functions | |
(Note that these are not member functions.) | |
| std::ostream & | operator<< (std::ostream &str, const Rel &obj) |
| bool | operator== (const Rel &lhs, const Rel &rhs) |
| bool | operator!= (const Rel &lhs, const Rel &rhs) |
Relational operators.
Yes, it could as well be simply an enum.
Yes, you can use the relational operators as if it was an enum.
Except for use in a switch statement; see inSwitch for this.
But we want to construct them from a string representation, as well as providing one. And this way they are wrapped into a namespace, which is a good idea anyway.
ANY and NONE are somewhat special. ANY is the operator created by the default ctor, and it should always resolve to true. This may be handy in queries when you're looking for a Resolvable in ANY Edition if no operator was specified. While NONE should always resolve to false.
|
explicit |
Ctor from string.
Legal values for strval_r are: "==", "!=", "<", "<=", ">", ">=",
as well as "EQ", "NE", "LT", "LE", "GT", "GE", "ANY", "NONE"
and "" (empty string resolves to ANY).
Lower case names are accepted as well.
| PARSE | if strval_r is not legal. |
| zypp::Rel::Rel | ( | const std::string & | strval_r, |
| const Rel & | default_r | ||
| ) |
|
inlineexplicit |
|
inlineprivate |
| bool zypp::Rel::parseFrom | ( | const std::string & | strval_r | ) |
|
inlinestatic |
| const std::string & zypp::Rel::asString | ( | ) | const |
|
inline |
|
inline |
Enumarator provided for use in switch statement.
The sole reason for providing enum for_use_in_switch is, that we may want to use the relational operators in a switch statement. Tht's the only case where you should have to use the enumarator.
|
inline |
|
related |
|
private |