10#ifndef IPPL_PARAMETER_LIST_H
11#define IPPL_PARAMETER_LIST_H
19#include "Types/Variant.h"
21#include "Utility/IpplException.h"
33 std::variant<double, float, bool, std::string, unsigned int, int, ParameterList>;
44 void add(
const std::string& key,
const T& value) {
45 if (params_m.contains(key)) {
47 "Parameter '" + key +
"' already exists.");
49 params_m[key] = value;
59 T
get(
const std::string& key)
const {
60 if (!params_m.contains(key)) {
62 "Parameter '" + key +
"' not contained.");
64 return std::get<T>(params_m.at(key));
75 T
get(
const std::string& key,
const T& defval)
const {
76 if (!params_m.contains(key)) {
79 return std::get<T>(params_m.at(key));
87 for (
const auto& [key, value] : p.params_m) {
88 params_m[key] = value;
98 for (
const auto& [key, value] : p.params_m) {
99 if (params_m.contains(key)) {
100 params_m[key] = value;
110 template <
typename T>
111 void update(
const std::string& key,
const T& value) {
112 if (!params_m.contains(key)) {
114 "Parameter '" + key +
"' does not exist.");
116 params_m[key] = value;
119 template <
class Stream>
120 friend Stream& operator<<(Stream& stream,
const ParameterList& sp) {
121 std::cout <<
"HI" << std::endl;
122 for (
const auto& [key, value] : sp.params_m) {
123 const auto& keyLocal = key;
126 stream << std::make_pair(keyLocal, arg);
138 static int indent = -4;
144 for (
const auto& [key, value] : sp.params_m) {
145 const auto& keyLocal = key;
150 os << std::string(indent,
' ') << std::left << std::setw(20) << keyLocal
156 if (key != std::prev(sp.params_m.end())->first) {
165 if (
this != &other) {
167 params_m = other.params_m;
173 std::map<std::string, variant_t> params_m;
Definition IpplException.h:6
Definition ParameterList.h:29
void update(const std::string &key, const T &value)
Definition ParameterList.h:111
T get(const std::string &key) const
Definition ParameterList.h:59
T get(const std::string &key, const T &defval) const
Definition ParameterList.h:75
void merge(const ParameterList &p) noexcept
Definition ParameterList.h:86
void add(const std::string &key, const T &value)
Definition ParameterList.h:44
friend std::ostream & operator<<(std::ostream &os, const ParameterList &sp)
Definition ParameterList.h:137
void update(const ParameterList &p) noexcept
Definition ParameterList.h:97