26 m_map.insert(
value ) ;
31 auto pair = m_map.equal_range( key ) ;
32 if( pair.first != pair.second )
33 m_map.erase( pair.first , pair.second ) ;
34 m_map.insert( Map::value_type(key,
OptionValue(value)) ) ;
39 auto p = m_map.find( key ) ;
40 if( p != m_map.end() )
41 (*p).second.increment() ;
46 return m_map.begin() ;
66 return m_map.find( key ) ;
76 return contains( std::string(key) ) ;
81 const Map::const_iterator end = m_map.end() ;
82 for(
auto p = m_map.find(key) ; p != end && (*p).first == key ; ++p )
84 if( (*p).second.isOff() )
94 auto pair = m_map.equal_range( key ) ;
95 for(
auto p = pair.first ; p != pair.second ; ++p )
96 n += (*p).second.count() ;
102 return value( std::string(key) , default_ ? std::string(default_) : std::string() ) ;
107 auto range = m_map.equal_range( key ) ;
108 if( range.first == range.second )
111 return join( range.first , range.second , default_ ) ;
114std::string G::OptionMap::join( Map::const_iterator p , Map::const_iterator end ,
const std::string & off_value )
const
117 const char * sep =
"" ;
118 for( ; p != end ; ++p )
120 result.append( sep ) ; sep =
"," ;
121 result.append( (*p).second.value() ) ;
122 if( (*p).second.isOn() )
123 return (*p).second.value() ;
124 if( (*p).second.isOff() )
130bool G::OptionMap::compare(
const Map::value_type & pair1 ,
const Map::value_type & pair2 )
132 return pair1.first < pair2.first ;
const_iterator cend() const
Returns the off-the-end iterator.
std::size_t count(const std::string &key) const
Returns the total repeat count for all matching entries.
void clear()
Clears the map.
const_iterator find(const std::string &) const
Finds the map entry with the given key.
std::string value(const std::string &key, const std::string &default_=std::string()) const
Returns the matching value, with concatentation into a comma-separated list if multivalued.
const_iterator cbegin() const
Returns the begin iterator.
const_iterator end() const
Returns the off-the-end iterator.
void increment(const std::string &key)
Increments the repeat count for the given entry.
void insert(const Map::value_type &)
Inserts the key/value pair into the map.
void replace(const std::string &key, const std::string &value)
Replaces all matching values with a single value.
bool contains(const std::string &) const
Returns true if the map contains the given key, but ignoring 'off' option-values.
const_iterator begin() const
Returns the begin iterator.
A simple structure encapsulating the value of a command-line option.