1#ifndef OSMIUM_UTIL_OPTIONS_HPP
2#define OSMIUM_UTIL_OPTIONS_HPP
37#include <initializer_list>
44 inline namespace util {
80 Options(
const std::initializer_list<value_type>& values) :
87 void set(
const std::string& key,
const std::string& value) {
94 void set(
const std::string& key,
const char* value) {
101 void set(
const std::string& key,
bool value) {
102 m_options[key] = value ?
"true" :
"false";
110 void set(
const std::string& data) {
111 const std::size_t pos = data.find_first_of(
'=');
112 if (pos == std::string::npos) {
115 const std::string value{data.substr(pos + 1)};
116 set(data.substr(0, pos), value);
124 std::string
get(
const std::string& key,
const std::string& default_value =
"") const noexcept {
127 return default_value;
136 bool is_true(
const std::string& key)
const noexcept {
137 const std::string value{
get(key)};
138 return (value ==
"true" || value ==
"yes");
145 bool is_false(
const std::string& key)
const noexcept {
146 const std::string value{
get(key)};
147 return (value ==
"false" || value ==
"no");
155 const std::string value{
get(key)};
156 return !(value ==
"false" || value ==
"no");
169 std::size_t
size() const noexcept {
Definition: options.hpp:58
const_iterator cend() const noexcept
Definition: options.hpp:211
void set(const std::string &data)
Definition: options.hpp:110
iterator end() noexcept
Definition: options.hpp:183
void set(const std::string &key, bool value)
Definition: options.hpp:101
option_map m_options
Definition: options.hpp:61
bool empty() const noexcept
Definition: options.hpp:162
const_iterator begin() const noexcept
Definition: options.hpp:190
option_map::iterator iterator
Definition: options.hpp:65
option_map::const_iterator const_iterator
Definition: options.hpp:66
const_iterator cbegin() const noexcept
Definition: options.hpp:204
bool is_true(const std::string &key) const noexcept
Definition: options.hpp:136
void set(const std::string &key, const char *value)
Definition: options.hpp:94
std::size_t size() const noexcept
Definition: options.hpp:169
const_iterator end() const noexcept
Definition: options.hpp:197
bool is_false(const std::string &key) const noexcept
Definition: options.hpp:145
option_map::value_type value_type
Definition: options.hpp:67
std::string get(const std::string &key, const std::string &default_value="") const noexcept
Definition: options.hpp:124
void set(const std::string &key, const std::string &value)
Definition: options.hpp:87
bool is_not_false(const std::string &key) const noexcept
Definition: options.hpp:154
std::map< std::string, std::string > option_map
Definition: options.hpp:60
Options(const std::initializer_list< value_type > &values)
Definition: options.hpp:80
iterator begin() noexcept
Definition: options.hpp:176
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53