libzypp: zypp::NamedValue< Tp, _tWithAlias > Class Template Reference

libzypp 17.38.14

zypp::NamedValue< Tp, _tWithAlias > Class Template Reference

Simple value<>name mapping supporting aliases. More...

`#include <zypp/base/NamedValue.h>`

## Classes
class | TInserter

## Public Member Functions
bool | empty () const
| Whether not initialized (no (name,value) pair remembered).
Get value for name or alias.
bool | haveValue (const std::string &name_r) const
| Whether there is a `value` mapped for name_r.
bool | getValue (const std::string &name_r, Tp &value_r) const
| Get value mapped for name or alias.
const Tp & | getValue (const std::string &name_r) const
Get name for value.
bool | haveName (const std::string &value_r) const
| Whether there is a `name` mapped for value_r.
bool | getName (const Tp &value_r, std::string &name_r) const
| Get name of value.
const std::string & | getName (const Tp &value_r) const

## Private Types
using | NameMap = std::map<std::string, Tp>
using | ValueMap = std::map<Tp, std::string>

## Inserter
NameMap | _nameMap
ValueMap | _valueMap
TInserter | operator() (const Tp &value_r)
bool | insert (const Tp &value_r, const std::string &name_r)
| Remember name (1st call) or alias (subsequent calls).

## Detailed Description

template<class Tp, const bool _tWithAlias = true>
class zypp::NamedValue< Tp, _tWithAlias >

Simple value<>name mapping supporting aliases.

enum Commands {
CMD_1,
CMD_2
};
NamedValue<Commands> clist;
// Value | Name | Alias...
clist( CMD_1 ) | "cmd1";
clist( CMD_2 ) | "cmd2" | "second";
std::string name( clist.getName( CMD_1 ) );
Commands cmd( clist.getValue( "second" ) );
zypp::NamedValue
Simple value<>name mapping supporting aliases.
Definition NamedValue.h:42
zypp::NamedValue::getValue
bool getValue(const std::string &name_r, Tp &value_r) const
Get value mapped for name or alias.
Definition NamedValue.h:65
zypp::NamedValue::getName
bool getName(const Tp &value_r, std::string &name_r) const
Get name of value.
Definition NamedValue.h:92

Definition at line 41 of file NamedValue.h.

## Member Typedef Documentation

## ◆ NameMap

template<class Tp, const bool _tWithAlias = true>

using zypp::NamedValue< Tp, _tWithAlias >::NameMap = std::map<std::string, Tp>
| private

Definition at line 43 of file NamedValue.h.

## ◆ ValueMap

template<class Tp, const bool _tWithAlias = true>

using zypp::NamedValue< Tp, _tWithAlias >::ValueMap = std::map<Tp, std::string>
| private

Definition at line 44 of file NamedValue.h.

## Member Function Documentation

## ◆ empty()

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::empty | ( |  | ) | const
| inline

Whether not initialized (no (name,value) pair remembered).

Definition at line 48 of file NamedValue.h.

## ◆ haveValue()

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::haveValue | ( | const std::string & | name_r | ) | const
| inline

Whether there is a `value` mapped for name_r.

Definition at line 56 of file NamedValue.h.

## ◆ getValue() [1/2]

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::getValue | ( | const std::string & | name_r,
|  | Tp & | value_r ) const
| inline

Get value mapped for name or alias.

Returns
  `true` if name or alias was found.

Definition at line 65 of file NamedValue.h.

## ◆ getValue() [2/2]

template<class Tp, const bool _tWithAlias = true>

const Tp & zypp::NamedValue< Tp, _tWithAlias >::getValue | ( | const std::string & | name_r | ) | const
| inline

Definition at line 74 of file NamedValue.h.

## ◆ haveName()

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::haveName | ( | const std::string & | value_r | ) | const
| inline

Whether there is a `name` mapped for value_r.

Definition at line 83 of file NamedValue.h.

## ◆ getName() [1/2]

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::getName | ( | const Tp & | value_r,
|  | std::string & | name_r ) const
| inline

Get name of value.

Returns
  `true` if name or alias was found.

Definition at line 92 of file NamedValue.h.

## ◆ getName() [2/2]

template<class Tp, const bool _tWithAlias = true>

const std::string & zypp::NamedValue< Tp, _tWithAlias >::getName | ( | const Tp & | value_r | ) | const
| inline

Definition at line 101 of file NamedValue.h.

## ◆ operator()()

template<class Tp, const bool _tWithAlias = true>

TInserter zypp::NamedValue< Tp, _tWithAlias >::operator() | ( | const Tp & | value_r | ) |
| inline

Definition at line 123 of file NamedValue.h.

## ◆ insert()

template<class Tp, const bool _tWithAlias = true>

bool zypp::NamedValue< Tp, _tWithAlias >::insert | ( | const Tp & | value_r,
|  | const std::string & | name_r )
| inline

Remember name (1st call) or alias (subsequent calls).

Returns
  \C true if this is the 1st call for value_r.

Exceptions

  std::logic_error | if name_r is already used as name or alias.
  std::logic_error | if `_tWithAlias` is `false` and a name for value_r is already defined.

Definition at line 132 of file NamedValue.h.

## Member Data Documentation

## ◆ _nameMap

template<class Tp, const bool _tWithAlias = true>

NameMap zypp::NamedValue< Tp, _tWithAlias >::_nameMap
| private

Definition at line 154 of file NamedValue.h.

## ◆ _valueMap

template<class Tp, const bool _tWithAlias = true>

ValueMap zypp::NamedValue< Tp, _tWithAlias >::_valueMap
| private

Definition at line 155 of file NamedValue.h.

The documentation for this class was generated from the following file:

- zypp/base/NamedValue.h