21 std::ofstream(
"default_gins.h") << R
"--(#pragma once
25Index create_workspace_gin_default_internal(Workspace& ws, const std::string_view method, const std::string_view gin);
28 std::map<String, Types> has;
31 for (std::size_t i = 0; i < method.GIn().size(); i++) {
32 if (
auto& def = method.GInDefault()[i]; not
is_default(def)) {
33 auto group_ind = method.GInType()[i];
36 has[
var_string(
"::", method.Name(),
"::", method.GIn()[i])];
37 vals.type = group_ind;
40 if (group ==
"String") {
41 val = std::string(
"\"") + def + std::string(
"\"");
42 }
else if (group ==
"Numeric") {
43 if (
"NaN" == def or
"nan" == def) {
44 val =
"std::numeric_limits<Numeric>::quiet_NaN()";
45 }
else if (
"Inf" == def or
"inf" == def) {
46 val =
"std::numeric_limits<Numeric>::infinity()";
47 }
else if (
"-Inf" == def or
"-inf" == def) {
48 val =
"-std::numeric_limits<Numeric>::infinity()";
52 }
else if (def ==
"[]") {
54 }
else if (group ==
"ArrayOfIndex") {
56 val =
"std::initializer_list<Index>" + def;
59 }
else if (group ==
"Vector") {
61 val =
"std::initializer_list<Numeric>" + def;
80 std::ofstream os(
"default_gins.cc");
82 os << R
"--(#include "auto_md.h"
84template <typename T, Index group>
85Index get_and_set_wsv_gin_pos(Workspace& ws, Index pos, T&& data) {
86 static std::size_t anon=0;
89 pos = ws.add_wsv(WsvRecord(var_string("::defgin", anon++).c_str(), "do not modify", group));
92 *static_cast<T *>(ws[pos].get()) = std::forward<T>(data);
97Index create_workspace_gin_default_internal(Workspace& ws, const std::string_view method, const std::string_view gin) {
98 const String key{var_string("::", method, "::", gin)};
99 const static std::map<String, Index> gins {
104 for (
auto& [key, items] : has) {
105 os <<
" {\"" << key <<
"\", " << counter++ <<
"},\n";
111 auto ptr = ws.WsvMap_ptr -> find(key);
112 Index pos = ptr == ws.WsvMap_ptr -> end() ? -1 : ptr -> second;
114 switch (gins.at(key)) {
118 for (
auto& [key, items] : has) {
119 os <<
" case " << counter++ <<
": return get_and_set_wsv_gin_pos<"
121 <<
">(ws, pos, " << items.val <<
");\n";
void define_wsv_groups()
Define the array of workspace variable group names.
std::string var_string(Args &&... args)
bool is_default(const String &x)
void define_md_data_raw()
Declaration of the class MdRecord.
const ArrayOfGroupRecord wsv_groups
The names associated with Wsv groups as Strings.
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.