E-MailRelay
Public Types | Public Member Functions | List of all members
G::OptionMap Class Reference

A multimap-like container for command-line options and their values. More...

#include <goptionmap.h>

Public Types

typedef std::multimap< std::string, OptionValue > Map
 
typedef Map::value_type value_type
 
typedef Map::iterator iterator
 
typedef Map::const_iterator const_iterator
 

Public Member Functions

 OptionMap ()
 Default constructor for an empty map.
 
void insert (const Map::value_type &)
 Inserts the key/value pair into the map. More...
 
const_iterator begin () const
 Returns the begin iterator.
 
const_iterator end () const
 Returns the off-the-end iterator.
 
const_iterator find (const std::string &) const
 Finds the map entry with the given key.
 
void clear ()
 Clears the map.
 
bool contains (const std::string &) const
 Returns true if the map contains the given key, but ignoring un-valued() 'off' options. More...
 
bool contains (const char *) const
 Overload taking a c-string.
 
size_t count (const std::string &key) const
 Returns the number of times the key appears in the multimap.
 
std::string value (const std::string &key, const std::string &default_=std::string()) const
 Returns the value of the valued() option identified by the given key. More...
 
std::string value (const char *key, const char *default_=nullptr) const
 Overload taking c-strings.
 

Detailed Description

A multimap-like container for command-line options and their values.

Normally populated by G::OptionParser.

Definition at line 39 of file goptionmap.h.

Member Function Documentation

bool G::OptionMap::contains ( const std::string &  key) const

Returns true if the map contains the given key, but ignoring un-valued() 'off' options.

Definition at line 58 of file goptionmap.cpp.

void G::OptionMap::insert ( const Map::value_type &  value)

Inserts the key/value pair into the map.

The ordering of values in the map with the same key is normally the order of insertion (but this can depend on the underlying multimap implementation).

Definition at line 28 of file goptionmap.cpp.

std::string G::OptionMap::value ( const std::string &  key,
const std::string &  default_ = std::string() 
) const

Returns the value of the valued() option identified by the given key.

Multiple matching values are concatenated with a comma separator (normally in the order of insertion).

Definition at line 83 of file goptionmap.cpp.


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