alpaqa pi-pico
Nonconvex constrained optimization
Loading...
Searching...
No Matches
param-complete.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <optional>
6#include <string_view>
7#include <vector>
8using namespace std::string_view_literals;
9
10namespace alpaqa::params {
11
13 /// Full key string, used for diagnostics.
14 std::string_view full_key;
15 /// The subkey to resolve next.
16 std::string_view key;
17 /// The value of the parameter to store.
18 std::optional<std::string_view> value;
19};
20
21struct Result {
22 bool leaf;
23 std::string_view prefix;
24 struct Member {
25 std::string_view name;
26 std::optional<std::string_view> doc = std::nullopt;
27 std::optional<char> suffix = std::nullopt;
28 };
29 std::vector<Member> members;
30};
31
32template <class T>
33Result get_members(const MemberGetter &s); /* deliberately undefined */
34
35template <class T>
36bool is_leaf(); /* deliberately undefined */
37
38template <>
40 template <class T, class T_actual, class A>
41 static attribute_accessor make(A T_actual::*, std::string_view doc = "") {
42 return {
43 .get{[](const auto &s) { return get_members<A>(s); }},
44 .doc{doc},
45 .leaf{is_leaf<A>()},
46 };
47 }
48
51 std::string_view doc;
52 bool leaf;
53};
54
55template <class T>
57 enum_accessor(T, std::string_view doc = "") : doc(doc) {}
58 std::string_view doc;
59};
60
61} // namespace alpaqa::params
62
63void print_completion(std::string_view method, std::string_view params);
std::optional< std::string_view > doc
Result get_members(const MemberGetter &s)
Catch-all.
std::string_view key
The subkey to resolve next.
std::string_view prefix
std::string_view full_key
Full key string, used for diagnostics.
std::vector< Member > members
std::optional< std::string_view > value
The value of the parameter to store.
Function wrapper to set attributes of a struct, type-erasing the type of the attribute.
Definition structs.hpp:11
Function wrapper access the enumerators of an enum, type-erasing the type of the enum.
Definition structs.hpp:81
constexpr const auto inf
Definition config.hpp:112
void print_completion(std::string_view method, std::string_view params)
static attribute_accessor make(A T_actual::*, std::string_view doc="")