1#ifndef PFLIB_TOOL_MENU_H
2#define PFLIB_TOOL_MENU_H
14#include "pflib/Exception.h"
15#include "pflib/logging/Logging.h"
17namespace pflib::menu {
67 bool preserve_last_blank =
false);
229 static ::pflib::logging::logger the_log_;
246 static char*
matcher(
const char* text,
int state);
308 unsigned int category = 0) {
309 lines_.emplace_back(name, desc, ex, category);
328 unsigned int category = 0) {
329 lines_.emplace_back(name, desc, ex, category);
355 unsigned int category = 0) {
357 lines_.emplace_back(name, desc, sb, category);
379 lines_.emplace_back(
"EXIT",
"leave this menu");
380 lines_.emplace_back(
"HELP",
"print help for this menu",
413 void hide(
unsigned int categories) {
424 for (
const auto& l :
lines_) {
445 for (
const auto& l :
lines_) {
496 const Line* theMatch = 0;
502 for (
size_t i = 0; i <
lines_.size(); i++)
503 if (strcasecmp(request.
c_str(),
lines_[i].name()) == 0) {
507 if (nmatch > 1) theMatch = 0;
510 printf(
" Command '%s' not understood.\n\n", request.
c_str());
513 if (theMatch->
execute(p_target)) {
518 }
while (theMatch == 0 or not theMatch->
empty());
562 unsigned int category = 0) {
563 return root()->
submenu(name, desc, render_func, category);
575 for (
const auto& l :
lines_) {
633 Line(
const char* n,
const char* d)
665 pflib_log(error) <<
"[" << e.
name() <<
"] : " << e.
message();
667 pflib_log(error) <<
"Unknown Exception " << e.
what();
693 void hide(
unsigned int categories) {
PFlib.
Definition Exception.h:12
const std::string & message() const
Get the message of the exception.
Definition Exception.h:52
virtual const char * what() const
The error message.
Definition Exception.h:76
const std::string & name() const
Get the name of the exception.
Definition Exception.h:46