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

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

#include <NamedValue.h>

Classes

class  TInserter
 

Public Member Functions

bool empty () const
 Whether not initialized (no (name,value) pair remembered) More...
 
bool insert (const Tp &value_r, const std::string &name_r)
 Remember name (1st call) or alias (subsequent calls). More...
 
Get value for name or alias.
bool haveValue (const std::string &name_r) const
 Whether there is a value mapped for name_r. More...
 
bool getValue (const std::string &name_r, Tp &value_r) const
 Get value mapped for name or alias. More...
 
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. More...
 
bool getName (const Tp &value_r, std::string &name_r) const
 Get name of value. More...
 
const std::string & getName (const Tp &value_r) const
 
Inserter
TInserter operator() (const Tp &value_r)
 

Private Types

typedef std::map< std::string, Tp > NameMap
 
typedef std::map< Tp, std::string > ValueMap
 

Private Attributes

NameMap _nameMap
 
ValueMap _valueMap
 

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" ) );

Definition at line 41 of file NamedValue.h.

Member Typedef Documentation

template<class Tp , const bool _tWithAlias = true>
typedef std::map< std::string, Tp > zypp::NamedValue< Tp, _tWithAlias >::NameMap
private

Definition at line 43 of file NamedValue.h.

template<class Tp , const bool _tWithAlias = true>
typedef std::map< Tp, std::string > zypp::NamedValue< Tp, _tWithAlias >::ValueMap
private

Definition at line 44 of file NamedValue.h.

Member Function Documentation

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.

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.

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.

template<class Tp , const bool _tWithAlias = true>
const Tp& zypp::NamedValue< Tp, _tWithAlias >::getValue ( const std::string &  name_r) 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 74 of file NamedValue.h.

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.

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.

template<class Tp , const bool _tWithAlias = true>
const std::string& zypp::NamedValue< Tp, _tWithAlias >::getName ( const Tp &  value_r) 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 101 of file NamedValue.h.

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.

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
true if this is the 1st call for value_r.
Exceptions
std::logic_errorif name_r is already used as name or alias.
std::logic_errorif _tWithAlias is false and a name for value_r is already defined.

Definition at line 132 of file NamedValue.h.

Member Data Documentation

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

Definition at line 154 of file NamedValue.h.

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: