libzypp 17.37.10

zypp::Rel Struct Reference

Relational operators. More...

`#include <zypp/Rel.h>`

## Related Symbols
(Note that these are not member symbols.)
std::ostream & | operator<< (std::ostream &str, const Rel &obj)
| Stream output.
bool | operator== (const Rel &lhs, const Rel &rhs)
bool | operator!= (const Rel &lhs, const Rel &rhs)

## 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
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...
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
for_use_in_switch | _op
| The operator.
| Rel ()
| DefaultCtor ANY.
| Rel (const std::string &strval_r)
| Ctor from string.
| Rel (const std::string &strval_r, const Rel &default_r)
| Ctor from string (non-throwing).
bool | parseFrom (const std::string &strval_r)
| Assign from string IFF it contains a legal value.
| Rel (unsigned bits_r)
| Ctor from bits.
const std::string & | asString () const
| String representation of relational operator.
const char * | c_str () const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
for_use_in_switch | inSwitch () const
| Enumarator provided for use in `switch` statement.
unsigned | bits () const
| Enumarator values suitable for libsolv.
static bool | isRel (unsigned bits_r)
| Test whether bits_r is a valid Rel (no extra bits set).
| Rel (for_use_in_switch op_r)
| Ctor to initialize the relational operator contants.

## Detailed Description

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`.

Definition at line 45 of file Rel.h.

## Member Enumeration Documentation

## ◆ for_use_in_switch

enum zypp::Rel::for_use_in_switch

Enumarators provided only for use inSwitch statement.

See also
  inSwitch

Note
  Enumarator values also correspond to the values libsolv uses to encode these relations.

Enumerator
NONE_e |
GT_e |
EQ_e |
LT_e |
GE_e |
LE_e |
NE_e |
ANY_e |

Definition at line 67 of file Rel.h.

## Constructor & Destructor Documentation

## ◆ Rel() [1/5]

zypp::Rel::Rel | ( |  | ) |
| inline

DefaultCtor ANY.

Definition at line 79 of file Rel.h.

## ◆ Rel() [2/5]

zypp::Rel::Rel | ( | const std::string & | strval_r | ) |
| 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.

Exceptions

  PARSE | if strval_r is not legal.

Todo
  refine exceptions and check throw.

Definition at line 81 of file Rel.cc.

## ◆ Rel() [3/5]

zypp::Rel::Rel | ( | const std::string & | strval_r,
|  | const Rel & | default_r )

Ctor from string (non-throwing).

Illegal string values resolve to `default_r`

Definition at line 85 of file Rel.cc.

## ◆ Rel() [4/5]

zypp::Rel::Rel | ( | unsigned | bits_r | ) |
| inline explicit

Ctor from bits.

Definition at line 108 of file Rel.h.

## ◆ Rel() [5/5]

zypp::Rel::Rel | ( | for_use_in_switch | op_r | ) |
| inline private

Ctor to initialize the relational operator contants.

Definition at line 152 of file Rel.h.

## Member Function Documentation

## ◆ parseFrom()

bool zypp::Rel::parseFrom | ( | const std::string & | strval_r | ) |

Assign from string IFF it contains a legal value.

Returns
  Whether strval_r contained a legal value.

Definition at line 89 of file Rel.cc.

## ◆ isRel()

bool zypp::Rel::isRel | ( | unsigned | bits_r | ) |
| inline static

Test whether bits_r is a valid Rel (no extra bits set).

Definition at line 113 of file Rel.h.

## ◆ asString()

const std::string & zypp::Rel::asString | ( |  | ) | const

String representation of relational operator.

Returns
  "=", "!=", "<", "<=", ">", ">=", "ANY" or "NONE"

Definition at line 105 of file Rel.cc.

## ◆ c_str()

const char * zypp::Rel::c_str | ( |  | ) | const
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 121 of file Rel.h.

## ◆ inSwitch()

for_use_in_switch zypp::Rel::inSwitch | ( |  | ) | const
| 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.

Rel op;
switch ( op.inSwitch() )
{
case Rel::EQ_e:
...
break;
case Rel::NE_e:
...
// No default! Let compiler warn if case is missing
}
zypp::Rel::inSwitch
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition Rel.h:143
zypp::Rel::Rel
Rel()
DefaultCtor ANY.
Definition Rel.h:79
zypp::Rel::NE_e
@ NE_e
Definition Rel.h:74
zypp::Rel::EQ_e
@ EQ_e
Definition Rel.h:70

Definition at line 143 of file Rel.h.

## ◆ bits()

unsigned zypp::Rel::bits | ( |  | ) | const
| inline

Enumarator values suitable for libsolv.

Definition at line 147 of file Rel.h.

## Friends And Related Symbol Documentation

## ◆ operator<<()

std::ostream & operator<< | ( | std::ostream & | str,
|  | const Rel & | obj )
| related

Stream output.

Definition at line 161 of file Rel.h.

## ◆ operator==()

bool operator== | ( | const Rel & | lhs,
|  | const Rel & | rhs )
| related

Definition at line 167 of file Rel.h.

## ◆ operator!=()

bool operator!= | ( | const Rel & | lhs,
|  | const Rel & | rhs )
| related

Definition at line 171 of file Rel.h.

## Member Data Documentation

## ◆ EQ

const Rel zypp::Rel::EQ
| static

Definition at line 52 of file Rel.h.

## ◆ NE

const Rel zypp::Rel::NE
| static

Definition at line 53 of file Rel.h.

## ◆ LT

const Rel zypp::Rel::LT
| static

Definition at line 54 of file Rel.h.

## ◆ LE

const Rel zypp::Rel::LE
| static

Definition at line 55 of file Rel.h.

## ◆ GT

const Rel zypp::Rel::GT
| static

Definition at line 56 of file Rel.h.

## ◆ GE

const Rel zypp::Rel::GE
| static

Definition at line 57 of file Rel.h.

## ◆ ANY

const Rel zypp::Rel::ANY
| static

Definition at line 58 of file Rel.h.

## ◆ NONE

const Rel zypp::Rel::NONE
| static

Definition at line 59 of file Rel.h.

## ◆ _op

for_use_in_switch zypp::Rel::_op
| private

The operator.

Definition at line 156 of file Rel.h.

The documentation for this struct was generated from the following files:

- zypp/Rel.h
- zypp/Rel.cc