Libosmium: osmium::util::Options Class Reference

Libosmium Fast and flexible C++ library for working with OpenStreetMap data

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
osmium::util::Options Class Reference

`#include <options.hpp>`

## Public Types
using | iterator = option_map::iterator
using | const_iterator = option_map::const_iterator
using | value_type = option_map::value_type

## Public Member Functions
| Options ()=default
| Options (const std::initializer_list< value_type > &values)
void | set (const std::string &key, const std::string &value)
void | set (const std::string &key, const char *value)
void | set (const std::string &key, bool value)
void | set (const std::string &data)
std::string | get (const std::string &key, const std::string &default_value="") const noexcept
bool | is_true (const std::string &key) const noexcept
bool | is_false (const std::string &key) const noexcept
bool | is_not_false (const std::string &key) const noexcept
bool | empty () const noexcept
std::size_t | size () const noexcept
iterator | begin () noexcept
iterator | end () noexcept
const_iterator | begin () const noexcept
const_iterator | end () const noexcept
const_iterator | cbegin () const noexcept
const_iterator | cend () const noexcept

## Private Types
using | option_map = std::map<std::string, std::string>

## Private Attributes
option_map | m_options

## Detailed Description

Stores key=value type options. This class can be used stand-alone or as a base class. Options are stored and retrieved by key using the different set() and get() methods.

Both keys and values are stored as strings. The values "true", "yes", "false", and "no" are interpreted as boolean values in some functions.

You can iterate over all set options. Dereferencing an iterator yields a std::pair of the key and value strings.

## Member Typedef Documentation

## ◆ const_iterator

using osmium::util::Options::const_iterator = option_map::const_iterator

## ◆ iterator

using osmium::util::Options::iterator = option_map::iterator

## ◆ option_map

using osmium::util::Options::option_map = std::map<std::string, std::string>
| private

## ◆ value_type

using osmium::util::Options::value_type = option_map::value_type

## Constructor & Destructor Documentation

## ◆ Options() [1/2]

osmium::util::Options::Options | ( |  | ) |
| default

Construct empty option set.

## ◆ Options() [2/2]

osmium::util::Options::Options | ( | const std::initializer_list< value_type > & | values | ) |
| inline

Construct option set from initializer list:

Options options{ { "foo", "true" }, { "bar", "17" } };
osmium::util::Options::Options
Options()=default

## Member Function Documentation

## ◆ begin() [1/2]

const_iterator osmium::util::Options::begin | ( |  | ) | const
| inlinenoexcept

Returns an iterator to the beginning.

## ◆ begin() [2/2]

iterator osmium::util::Options::begin | ( |  | ) |
| inlinenoexcept

Returns an iterator to the beginning.

## ◆ cbegin()

const_iterator osmium::util::Options::cbegin | ( |  | ) | const
| inlinenoexcept

Returns an iterator to the beginning.

## ◆ cend()

const_iterator osmium::util::Options::cend | ( |  | ) | const
| inlinenoexcept

Returns a iterator to the end.

## ◆ empty()

bool osmium::util::Options::empty | ( |  | ) | const
| inlinenoexcept

Is the set of options empty?

## ◆ end() [1/2]

const_iterator osmium::util::Options::end | ( |  | ) | const
| inlinenoexcept

Returns an iterator to the end.

## ◆ end() [2/2]

iterator osmium::util::Options::end | ( |  | ) |
| inlinenoexcept

Returns an iterator to the end.

## ◆ get()

std::string osmium::util::Options::get | ( | const std::string & | key,
|  | const std::string & | default_value = "" ) const
| inlinenoexcept

Get value of "key" option. If not set, the default_value (or empty string) is returned.

## ◆ is_false()

bool osmium::util::Options::is_false | ( | const std::string & | key | ) | const
| inlinenoexcept

Is this option set to a false value ("false" or "no")? Will return false if the value is unset.

## ◆ is_not_false()

bool osmium::util::Options::is_not_false | ( | const std::string & | key | ) | const
| inlinenoexcept

Is this option not set to a false value ("false" or "no")? Will return true if the value is unset.

## ◆ is_true()

bool osmium::util::Options::is_true | ( | const std::string & | key | ) | const
| inlinenoexcept

Is this option set to a true value ("true" or "yes")? Will return false if the value is unset.

## ◆ set() [1/4]

void osmium::util::Options::set | ( | const std::string & | data | ) |
| inline

Set option from string in the form 'key=value'. If the string contains no equal sign, the whole string is the key and it will be set to "true".

## ◆ set() [2/4]

void osmium::util::Options::set | ( | const std::string & | key,
|  | bool | value )
| inline

Set option 'key' to 'value'.

## ◆ set() [3/4]

void osmium::util::Options::set | ( | const std::string & | key,
|  | const char * | value )
| inline

Set option 'key' to 'value'.

## ◆ set() [4/4]

void osmium::util::Options::set | ( | const std::string & | key,
|  | const std::string & | value )
| inline

Set option 'key' to 'value'.

## ◆ size()

std::size_t osmium::util::Options::size | ( |  | ) | const
| inlinenoexcept

The number of options set.

## Member Data Documentation

## ◆ m_options

option_map osmium::util::Options::m_options
| private

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

- include/osmium/util/options.hpp