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
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...

## Detailed Description

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.

## Member Typedef Documentation

## ◆ const_iterator

using G::OptionMap::const_iterator = Map::const_iterator

Definition at line 49 of file goptionmap.h.

## ◆ iterator

using G::OptionMap::iterator = Map::iterator

Definition at line 48 of file goptionmap.h.

## ◆ Map

using G::OptionMap::Map = std::multimap<std::string,OptionValue,std::less<std::string> >

Definition at line 46 of file goptionmap.h.

## ◆ value_type

using G::OptionMap::value_type = Map::value_type

Definition at line 47 of file goptionmap.h.

## Member Function Documentation

## ◆ begin()

G::OptionMap::const_iterator G::OptionMap::begin | ( |  | ) | const
| noexcept

Returns the begin iterator.

Definition at line 76 of file goptionmap.cpp.

## ◆ cbegin()

G::OptionMap::const_iterator G::OptionMap::cbegin | ( |  | ) | const
| noexcept

Returns the begin iterator.

Definition at line 82 of file goptionmap.cpp.

## ◆ cend()

G::OptionMap::const_iterator G::OptionMap::cend | ( |  | ) | const
| noexcept

Returns the off-the-end iterator.

Definition at line 94 of file goptionmap.cpp.

## ◆ clear()

void G::OptionMap::clear | ( |  | ) |

Clears the map.

Definition at line 100 of file goptionmap.cpp.

## ◆ contains() [1/3]

bool G::OptionMap::contains | ( | const char * | key | ) | const
| noexcept

Overload for c-string.

Definition at line 117 of file goptionmap.cpp.

## ◆ contains() [2/3]

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

Overload for std-string.

Definition at line 122 of file goptionmap.cpp.

## ◆ contains() [3/3]

bool G::OptionMap::contains | ( | std::string_view | key | ) | const
| noexcept

Returns true if the map contains the given key, but ignoring 'off' option-values.

Definition at line 105 of file goptionmap.cpp.

## ◆ count()

std::size_t G::OptionMap::count | ( | std::string_view | key | ) | const
| noexcept

Returns the total repeat count for all matching entries.

See G::OptionValue::count().

Definition at line 127 of file goptionmap.cpp.

## ◆ end()

G::OptionMap::const_iterator G::OptionMap::end | ( |  | ) | const
| noexcept

Returns the off-the-end iterator.

Definition at line 88 of file goptionmap.cpp.

## ◆ find()

G::OptionMap::const_iterator G::OptionMap::find | ( | std::string_view | key | ) | const
| noexcept

Finds the map entry with the given key.

Definition at line 52 of file goptionmap.cpp.

## ◆ increment()

void G::OptionMap::increment | ( | std::string_view | key | ) |
| noexcept

Increments the repeat count for the given entry.

Definition at line 66 of file goptionmap.cpp.

## ◆ insert()

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.

## ◆ number()

unsigned int G::OptionMap::number | ( | std::string_view | key,
|  | unsigned int | default_
| ) |  | const
| noexcept

Returns the matching value as a number.

Definition at line 161 of file goptionmap.cpp.

## ◆ replace()

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.

## ◆ value()

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.

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

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/glib/goptionmap.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/glib/goptionmap.cpp