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 (std::string_view key, const std::string &value) |
Replaces all matching values with a single value. More... | |
void | increment (std::string_view key) noexcept |
Increments the repeat count for the given entry. More... | |
const_iterator | begin () const noexcept |
Returns the begin iterator. More... | |
const_iterator | cbegin () const noexcept |
Returns the begin iterator. More... | |
const_iterator | end () const noexcept |
Returns the off-the-end iterator. More... | |
const_iterator | cend () const noexcept |
Returns the off-the-end iterator. More... | |
const_iterator | find (std::string_view) const noexcept |
Finds the map entry with the given key. More... | |
void | clear () |
Clears the map. More... | |
bool | contains (std::string_view) const noexcept |
Returns true if the map contains the given key, but ignoring 'off' option-values. More... | |
bool | contains (const char *) const noexcept |
Overload for c-string. More... | |
bool | contains (const std::string &) const noexcept |
Overload for std-string. More... | |
std::size_t | count (std::string_view key) const noexcept |
Returns the total repeat count for all matching entries. More... | |
std::string | value (std::string_view key, std::string_view default_={}) const |
Returns the matching value, with concatentation into a comma-separated list if multivalued (with no escaping). More... | |
unsigned int | number (std::string_view key, unsigned int default_) const noexcept |
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 43 of file goptionmap.h.
using G::OptionMap::const_iterator = Map::const_iterator |
Definition at line 49 of file goptionmap.h.
using G::OptionMap::iterator = Map::iterator |
Definition at line 48 of file goptionmap.h.
using G::OptionMap::Map = std::multimap<std::string,OptionValue,std::less<std::string> > |
Definition at line 46 of file goptionmap.h.
using G::OptionMap::value_type = Map::value_type |
Definition at line 47 of file goptionmap.h.
|
noexcept |
Returns the begin iterator.
Definition at line 76 of file goptionmap.cpp.
|
noexcept |
Returns the begin iterator.
Definition at line 82 of file goptionmap.cpp.
|
noexcept |
Returns the off-the-end iterator.
Definition at line 94 of file goptionmap.cpp.
void G::OptionMap::clear | ( | ) |
Clears the map.
Definition at line 100 of file goptionmap.cpp.
|
noexcept |
Overload for c-string.
Definition at line 117 of file goptionmap.cpp.
|
noexcept |
Overload for std-string.
Definition at line 122 of file goptionmap.cpp.
|
noexcept |
Returns true if the map contains the given key, but ignoring 'off' option-values.
Definition at line 105 of file goptionmap.cpp.
|
noexcept |
Returns the total repeat count for all matching entries.
Definition at line 127 of file goptionmap.cpp.
|
noexcept |
Returns the off-the-end iterator.
Definition at line 88 of file goptionmap.cpp.
|
noexcept |
Finds the map entry with the given key.
Definition at line 52 of file goptionmap.cpp.
|
noexcept |
Increments the repeat count for the given entry.
Definition at line 66 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.
Definition at line 27 of file goptionmap.cpp.
|
noexcept |
Returns the matching value as a number.
Definition at line 161 of file goptionmap.cpp.
void G::OptionMap::replace | ( | std::string_view | key, |
const std::string & | value | ||
) |
Replaces all matching values with a single value.
Definition at line 58 of file goptionmap.cpp.
std::string G::OptionMap::value | ( | std::string_view | key, |
std::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 136 of file goptionmap.cpp.