alpaqa 1.0.0a19
Nonconvex constrained optimization
Loading...
Searching...
No Matches
json.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <alpaqa/export.h>
5#include <nlohmann/json_fwd.hpp>
6#include <string>
7#include <vector>
8
9namespace alpaqa::params {
10
11using nlohmann::json;
12
13/// Update/overwrite the first argument based on the JSON object @p j.
14template <class T>
15void ALPAQA_EXPORT set_param(T &, const json &j); /* deliberately undefined */
16
17/// Get the first argument as a JSON object @p j.
18template <class T>
19void ALPAQA_EXPORT get_param(const T &, json &j); /* deliberately undefined */
20
21template <class T>
22struct enum_accessor<T, json> {
23 enum_accessor(T value, std::string_view = "") : value{value} {}
25};
26
27/// Custom parameter parsing exception.
28struct ALPAQA_EXPORT invalid_json_param : std::invalid_argument {
29 using std::invalid_argument::invalid_argument;
30 std::vector<std::string> backtrace;
31};
32
33} // namespace alpaqa::params
void get_param(const T &, json &j)
Get the first argument as a JSON object j.
Definition json.cpp:252
void set_param(T &, const json &j)
Update/overwrite the first argument based on the JSON object j.
Definition json.cpp:248
Function wrapper access the enumerators of an enum, type-erasing the type of the enum.
Definition structs.hpp:94
constexpr const auto inf
Definition config.hpp:112
enum_accessor(T value, std::string_view="")
Definition json.hpp:23
Custom parameter parsing exception.
Definition json.hpp:28
std::vector< std::string > backtrace
Definition json.hpp:30