#include <iostream>
#include <string>
namespace stamen {
const stamen_display_f stamen_display = stamen::builtin_display;
class Generator {
public:
static void generateInclude(std::ostream &os, bool cpp) {
os << "#ifndef STAMEN_MENU_H\n";
os << "#define STAMEN_MENU_H\n\n";
struct arguments_t {
std::string config;
bool cpp = false;
bool user = false;
} opt;
if (cpp) os << "#include \"stamen.hpp\"\n\n";
void generateIncludeHeaders(std::ostream &os) {
if (opt.user) {
if (opt.cpp) os << "#include \"stamen.hpp\"\n\n";
else os << "#include \"stamen.h\"\n\n";
} else {
if (opt.cpp) os << "#include <stamen/stamen.hpp>\n\n";
else os << "#include <stamen/stamen.h>\n\n";
}
}
for (const auto &[code, menu] : Menu::menu_lookup) {
os << std::format("int {}(int);\n", menu.getCode());
}
void generateInclude(std::ostream &os) {
os << "#ifndef STAMEN_MENU_H\n";
os << "#define STAMEN_MENU_H\n\n";
os << "\n#endif\n";
}
generateIncludeHeaders(os);
static void generateSource(std::ostream &os, bool cpp) {
if (cpp) os << "#include \"stamen.hpp\"\n\n";
else os << "#include \"stamen.h\"\n\n";
for (const auto &[code, menu] : stamen::Menu::menu_lookup) {
os << std::format("int {}(int);\n", menu.getCode());
}
os << "#include \"shared.h\"\n\n";
for (const auto &[code, menu] : Menu::menu_lookup) {
os << std::format("int {}(int) {{\n", menu.getCode());
os << "\n#endif\n";
}
if (cpp) os << "\tstatic const stamen::item_t items[] = ";
else os << "\tstatic const stamen_item_t items[] = ";
void generateSource(std::ostream &os) {
os << "#include \"shared.h\"\n";
generateIncludeHeaders(os);
os << "{\n";
for (int i = 0; i < menu.getSize(); i++) {
os << "\t\t{ " << menu.getCode(i);
os << ", \"" << menu.getPrompt(i) << "\" },\n";
}
os << "\t};\n";
for (const auto &[code, menu] : stamen::Menu::menu_lookup) {
os << std::format("int {}(int) {{\n", menu.getCode());
if (cpp) os << "\treturn stamen::stamen_display";
else os << "\treturn stamen_display";
if (opt.cpp) os << "\tstatic const stamen::item_t items[] = ";
else os << "\tstatic const stamen_item_t items[] = ";
os << std::format("(\"{}\"", menu.getTitle());
os << ", items, sizeof(items) / sizeof(items[0]));\n";
os << "}\n\n";
os << "{\n";
for (int i = 0; i < menu.getSize(); i++) {
os << "\t\t{ " << menu.getCode(i);
os << ", \"" << menu.getPrompt(i) << "\" },\n";
}
}
};
} // namespace stamen
os << "\t};\n";
struct arguments_t {
std::string config;
bool cpp = false;
};
if (opt.cpp) os << "\treturn stamen::stamen_display";
else os << "\treturn stamen_display";
os << std::format("(\"{}\"", menu.getTitle());
os << ", items, sizeof(items) / sizeof(items[0]));\n";
os << "}\n\n";
}
}
int parse_opt(int key, const char *arg, args::Parser *parser) {
auto arguments = (arguments_t *)parser->input();
switch (key) {
case 'u': arguments->user = true; break;
case 666: arguments->cpp = false; break;
case 777: arguments->cpp = true; break;
case args::ARG: