for (const auto& [code, menu] : stamen::menu::menu_lookup)
{
ost << std::format("int {}(std::size_t /* unused */);\n", menu.get_code());
ost << func_decl(
menu.get_code(), "int", {{"std::size_t", "/* unused */"}});
}
ost << std::format("\n}} // namespace {}\n", args.nspace);
ost << nspace(args.nspace);
}
void generate_source_cpp(std::ostream& ost,
const arguments_t& args,
const std::string& include)
const std::string& include_name)
{
ost << "#include <cstddef>\n\n";
ost << std::format("#include \"{}\"\n\n", include);
using namespace cemplate; // NOLINT
ost << std::format("namespace {}\n{{\n\n", args.nspace);
ost << include(include_name, true);
ost << '\n';
ost << std::format("extern int {}(const char *title, ", args.display);
ost << "const stamen::item_t itemv[], size_t size);\n\n";
ost << nspace(args.nspace);
for (const auto& [code, _] : stamen::menu::free_lookup)
{
ost << std::format("extern int {}(std::size_t);\n", code);
ost << func_decl(code, "extern int", {{"std::size_t", "/* unused */"}});
}
ost << '\n';
// clang-format off
for (const auto& [code, menu] : stamen::menu::menu_lookup)
{
ost << std::format("int {}(size_t /* unused */) // NOLINT\n{{\n",
menu.get_code());
ost << "\tstatic const menu_t menu = {\n";
ost << std::format("\t\t.title = \"{}\",\n", menu.get_title());
ost << std::format("\t\t.callback = {},\n", menu.get_code());
ost << std::format("\t\t.items = {{\n");
for (auto i = 0UL; i < menu.get_size(); i++)
{
ost << std::format("\t\t\t{{.callback = {}, .prompt = \"{}\"}},\n",
menu.get_code(i),
menu.get_prompt(i));
}
ost << "\t\t}\n\t};\n\n";
ost << "\treturn menu_t::visit(menu);\n";
ost << "}\n\n";
ost << func(
menu.get_code(),
"extern int",
{{"std::size_t", "/* unused */"}}
)
<< decl("static const menu_t", "menu")
<< initlist({
string(menu.get_title()),
menu.get_code(),
accumulate_items(menu),
})
<< ret("menu_t::visit(menu)")
<< func(menu.get_code());
}
// clang-format on
ost << std::format("\n}} // namespace {}\n", args.nspace);
ost << nspace(args.nspace);
}
int parse_opt(int key, const char* arg, poafloc::Parser* parser)