E-MailRelay
|
A multimap-like container for command-line options and their values. More...
#include <goptionmap.h>
Public Types | |
using | Map = std::multimap< std::string, OptionValue, std::less< std::string > > |
using | value_type = Map::value_type |
using | iterator = Map::iterator |
using | const_iterator = Map::const_iterator |
Public Member Functions | |
void | insert (const Map::value_type &) |
Inserts the key/value pair into the map. More... | |
void | replace (string_view key, const std::string &value) |
Replaces all matching values with a single value. More... | |
void | increment (string_view key) |
Increments the repeat count for the given entry. More... | |
const_iterator | begin () const |
Returns the begin iterator. More... | |
const_iterator | cbegin () const |
Returns the begin iterator. More... | |
const_iterator | end () const |
Returns the off-the-end iterator. More... | |
const_iterator | cend () const |
Returns the off-the-end iterator. More... | |
const_iterator | find (string_view) const |
Finds the map entry with the given key. More... | |
void | clear () |
Clears the map. More... | |
bool | contains (string_view) const |
Returns true if the map contains the given key, but ignoring 'off' option-values. More... | |
bool | contains (const char *) const |
Overload for c-string. More... | |
bool | contains (const std::string &) const |
Overload for std-string. More... | |
std::size_t | count (string_view key) const |
Returns the total repeat count for all matching entries. More... | |
std::string | value (string_view key, string_view default_={}) const |
Returns the matching value, with concatentation into a comma-separated list if multivalued (with no escaping). More... | |
unsigned int | number (string_view key, unsigned int default_) const |
Returns the matching value as a number. More... | |
A multimap-like container for command-line options and their values.
The values are G::OptionValue objects, so they can be valued with a string value or unvalued with an on/off status, and they can have a repeat-count. Normally populated by G::OptionParser.
Definition at line 42 of file goptionmap.h.
using G::OptionMap::const_iterator = Map::const_iterator |
Definition at line 48 of file goptionmap.h.
using G::OptionMap::iterator = Map::iterator |
Definition at line 47 of file goptionmap.h.
using G::OptionMap::Map = std::multimap<std::string,OptionValue,std::less<std::string> > |
Definition at line 45 of file goptionmap.h.
using G::OptionMap::value_type = Map::value_type |
Definition at line 46 of file goptionmap.h.
G::OptionMap::const_iterator G::OptionMap::begin | ( | ) | const |
Returns the begin iterator.
Definition at line 62 of file goptionmap.cpp.
G::OptionMap::const_iterator G::OptionMap::cbegin | ( | ) | const |
Returns the begin iterator.
Definition at line 68 of file goptionmap.cpp.
G::OptionMap::const_iterator G::OptionMap::cend | ( | ) | const |
Returns the off-the-end iterator.
Definition at line 80 of file goptionmap.cpp.
void G::OptionMap::clear | ( | ) |
Clears the map.
Definition at line 86 of file goptionmap.cpp.
bool G::OptionMap::contains | ( | const char * | key | ) | const |
Overload for c-string.
Definition at line 103 of file goptionmap.cpp.
bool G::OptionMap::contains | ( | const std::string & | key | ) | const |
Overload for std-string.
Definition at line 108 of file goptionmap.cpp.
bool G::OptionMap::contains | ( | string_view | key | ) | const |
Returns true if the map contains the given key, but ignoring 'off' option-values.
Definition at line 91 of file goptionmap.cpp.
std::size_t G::OptionMap::count | ( | string_view | key | ) | const |
Returns the total repeat count for all matching entries.
Definition at line 113 of file goptionmap.cpp.
G::OptionMap::const_iterator G::OptionMap::end | ( | ) | const |
Returns the off-the-end iterator.
Definition at line 74 of file goptionmap.cpp.
G::OptionMap::const_iterator G::OptionMap::find | ( | string_view | key | ) | const |
Finds the map entry with the given key.
Definition at line 41 of file goptionmap.cpp.
void G::OptionMap::increment | ( | string_view | key | ) |
Increments the repeat count for the given entry.
Definition at line 55 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 in the order of insert()ion (as guaranteed by std::multimap since c++ 2011).
Definition at line 26 of file goptionmap.cpp.
unsigned int G::OptionMap::number | ( | string_view | key, |
unsigned int | default_ | ||
) | const |
Returns the matching value as a number.
Definition at line 147 of file goptionmap.cpp.
void G::OptionMap::replace | ( | string_view | key, |
const std::string & | value | ||
) |
Replaces all matching values with a single value.
Definition at line 47 of file goptionmap.cpp.
std::string G::OptionMap::value | ( | string_view | key, |
string_view | default_ = {} |
||
) | const |
Returns the matching value, with concatentation into a comma-separated list if multivalued (with no escaping).
If there are any on/off option-values matching the key then a single value is returned corresponding to the first one, being G::Str::positive() if 'on' or the supplied default if 'off'.
Definition at line 122 of file goptionmap.cpp.