10#define ThrowInputError \
11 throw std::invalid_argument( \
12 (GetErrorOriginScope().empty() ? "" : GetErrorOriginScope() + "\n") + \
13 "Input error: " + ObjectType() + "\n" + err_stream.str())
15#define ExceptionParamNotPresent(param_name) \
16 throw std::logic_error(std::string(__PRETTY_FUNCTION__) + ": Parameter \"" + \
17 param_name + "\" not present in list of parameters.")
28 for (
const auto& param : other)
35 for (
const auto& [param_name, tag] : other_map)
38 "Duplicate tags detected.");
39 this_map[param_name] = tag;
45 for (
const auto& [param_name, tag] : other_map)
48 "Duplicate tags detected.");
49 this_map[param_name] = tag;
55 for (
const auto& [param_name, tag] : other_map)
58 "Duplicate tags detected.");
59 this_map[param_name] = tag;
65 for (
const auto& [param_name, tag] : other_map)
68 "Duplicate tags detected.");
69 this_map[param_name] = tag;
75 for (
const auto& [param_name, tag] : other_map)
78 "Duplicate tags detected.");
79 this_map[param_name] = tag;
85 for (
const auto& [param_name, tag] : other_map)
88 "Duplicate tags detected.");
89 this_map[param_name] = tag;
95 for (
const auto& [param_name, tag] : other_map)
98 "Duplicate tags detected.");
99 this_map[param_name] = tag;
105 for (
auto& [param_name, tag] : other_map)
108 "Duplicate tags detected.");
109 this_map[param_name] = std::move(tag);
130 const std::string& block_name)
133 "Parameter \"" + param_name +
"\" not present in block");
140 const std::string& param_name)
const
153 "Invalid parameter \"" + param_name +
"\".");
161 bool ignored =
false;
165 if (std::find(list.begin(), list.end(), param_name) != list.end())
176 const std::string& doc_string)
178 auto new_block = block;
188 const std::string& name,
189 const std::vector<ParameterBlock>& array,
190 const std::string& doc_string)
194 for (
auto& block : array)
205 const std::string& doc_string)
216 const std::string& doc_string)
233 std::stringstream err_stream;
247 const auto& req_param =
GetParam(param_index);
248 const auto& req_param_name = req_param.Name();
255 if (not params.
Has(req_param_name))
256 err_stream <<
"Required param \"" << req_param_name
257 <<
"\" not supplied.\ndoc-string: "
259 <<
"\nEnsure the parameter given is supplied or not nil";
271 const auto& param_name = param.Name();
273 if (not this->
Has(param_name))
274 err_stream <<
"Invalid param \"" << param_name <<
"\" supplied.\n";
277 err_stream <<
"Invalid param \"" << param_name <<
"\" supplied. ";
278 err_stream <<
"The parameter has been renamed. ";
293 const auto& param_name = param.Name();
297 if (this->
Has(param_name) and (dep_warns.count(param_name) > 0))
299 <<
"Parameter \"" << param_name <<
"\" has been deprecated "
300 <<
"and will be removed soon.\n"
301 << dep_warns.at(param_name);
312 const auto& param_name = param.Name();
316 if (this->
Has(param_name) and (dep_errs.count(param_name) > 0))
319 <<
"Parameter \"" << param_name <<
"\" has been deprecated.\n"
320 << dep_errs.at(param_name);
329 const auto& param_name = param.Name();
333 auto& input_param =
GetParam(param_name);
336 if (param.Type() != input_param.Type())
340 err_stream <<
"Invalid parameter type \""
342 <<
"\" for parameter \"" << param_name
343 <<
"\". Expecting type \""
354 if (not constraint->IsAllowable(param.Value()))
356 err_stream << constraint->OutOfRangeString(input_param.Name(),
374 const std::string& param_name,
const std::string& deprecation_message )
386 const std::string& param_name,
const std::string& deprecation_message )
398 const std::string& param_name,
const std::string& renaming_description)
415 std::string(
"Parameter \"") + param_name +
418 " to which constraints cannot be applied");
429 const std::string& param_name)
432 "Parameter \"" + param_name +
"\" not present.");
448 const std::string sp2 =
" ";
449 const std::string sp4 =
" ";
451 for (
const auto& param : params)
453 const auto& param_name = param.Name();
454 Chi::log.
Log() << sp2 <<
"PARAM_BEGIN " << param_name;
456 const auto type = param.Type();
465 Chi::log.
Log() << sp4 <<
"DEFAULT_VALUE " << param.Value().PrintStr();
468 std::stringstream outstr;
469 outstr << sp4 <<
"DEFAULT_VALUE ";
470 for (
size_t k = 0; k < param.NumParameters(); ++k)
472 const auto& sub_param = param.GetParam(k);
473 outstr << sub_param.Value().PrintStr() <<
", ";
493 if (not linkage.empty()) {
Chi::log.
Log() << sp4 <<
"LINKS " << linkage; }
#define ChiLogicalErrorIf(condition, message)
#define ChiInvalidArgumentIf(condition, message)
static void Exit(int error_code)
LogStream Log(LOG_LVL level=LOG_0)
bool Has(const std::string ¶m_name) const
size_t NumParameters() const
void AddParameter(ParameterBlock block)
const std::vector< ParameterBlock > & Parameters() const
void SetBlockName(const std::string &name)
ParameterBlockType Type() const
ParameterBlock & GetParam(const std::string ¶m_name)
std::string ParameterBlockTypeName(ParameterBlockType type)