| 118 | } |
| 119 | |
| 120 | void common_preset::set_option(const common_preset_context & ctx, const std::string & env, const std::string & value) { |
| 121 | // try if option exists, update it |
| 122 | for (auto & [opt, val] : options) { |
| 123 | if (opt.env && env == opt.env) { |
| 124 | val = value; |
| 125 | return; |
| 126 | } |
| 127 | } |
| 128 | // if option does not exist, we need to add it |
| 129 | if (ctx.key_to_opt.find(env) == ctx.key_to_opt.end()) { |
| 130 | throw std::runtime_error(string_format( |
| 131 | "%s: option with env '%s' not found in ctx_params", |
| 132 | __func__, env.c_str() |
| 133 | )); |
| 134 | } |
| 135 | options[ctx.key_to_opt.at(env)] = value; |
| 136 | } |
| 137 | |
| 138 | void common_preset::unset_option(const std::string & env) { |
| 139 | for (auto it = options.begin(); it != options.end(); ) { |
no test coverage detected