12#ifndef ZYPP_BASE_NAMEDVALUE_H
13#define ZYPP_BASE_NAMEDVALUE_H
40 template<
class Tp, const
bool _tWithAlias = true >
43 typedef std::map< std::string, Tp >
NameMap;
58 typename NameMap::const_iterator it(
_nameMap.find( name_r ) );
65 bool getValue(
const std::string & name_r, Tp & value_r )
const
67 typename NameMap::const_iterator it(
_nameMap.find( name_r ) );
74 const Tp &
getValue(
const std::string & name_r )
const
83 bool haveName(
const std::string & value_r )
const
85 typename ValueMap::const_iterator it(
_valueMap.find( value_r ) );
92 bool getName(
const Tp & value_r, std::string & name_r )
const
94 typename ValueMap::const_iterator it(
_valueMap.find( value_r ) );
101 const std::string &
getName(
const Tp & value_r )
const
132 bool insert(
const Tp & value_r,
const std::string & name_r )
134 typename NameMap::const_iterator nit(
_nameMap.find( name_r ) );
136 throw std::logic_error(
"NamedValue::insert name" );
138 typename ValueMap::const_iterator tit(
_valueMap.find( value_r ) );
142 throw std::logic_error(
"NamedValue::insert alias" );
TInserter(NamedValue &parent_r, const Tp &value_r)
TInserter & operator|(const std::string &name_r)
Simple value<>name mapping supporting aliases.
TInserter operator()(const Tp &value_r)
bool empty() const
Whether not initialized (no (name,value) pair remembered)
bool getValue(const std::string &name_r, Tp &value_r) const
Get value mapped for name or alias.
std::map< Tp, std::string > ValueMap
const Tp & getValue(const std::string &name_r) const
bool haveName(const std::string &value_r) const
Whether there is a name mapped for value_r.
const std::string & getName(const Tp &value_r) const
bool haveValue(const std::string &name_r) const
Whether there is a value mapped for name_r.
bool insert(const Tp &value_r, const std::string &name_r)
Remember name (1st call) or alias (subsequent calls).
bool getName(const Tp &value_r, std::string &name_r) const
Get name of value.
std::map< std::string, Tp > NameMap
Easy-to use interface to the ZYPP dependency resolver.