1#ifndef PFLIB_TOOL_MENU_H
2#define PFLIB_TOOL_MENU_H
14#ifndef PFLIB_TEST_MENU
15#include "pflib/Exception.h"
46 bool preserve_last_blank =
false);
179 static char*
matcher(
const char* text,
int state);
209template <
typename T,
typename H = T*>
242 lines_.emplace_back(name,desc,ex);
260 lines_.emplace_back(name,desc,ex);
288 auto sb =
new Menu(f);
289 lines_.emplace_back(name,desc,sb);
311 lines_.emplace_back(
"EXIT",
"leave this menu");
361 const Line* theMatch = 0;
369 for (
const auto& l :
lines_)
376 for (
size_t i = 0; i <
lines_.size(); i++)
377 if (strcasecmp(request.
c_str(),
lines_[i].name()) == 0) {
381 if (nmatch > 1) theMatch = 0;
384 printf(
" Command '%s' not understood.\n\n", request.
c_str());
387 if (theMatch->
execute(p_target)) {
392 }
while (theMatch == 0 or not theMatch->
empty());
432 static Menu*
menu(
const char* name,
const char* desc,
483 Line(
const char* n,
const char* d)
526#ifndef PFLIB_TEST_MENU
PFlib.
Definition: Exception.h:12
const std::string & message() const
Get the message of the exception.
Definition: Exception.h:53
virtual const char * what() const
The error message.
Definition: Exception.h:77
const std::string & name() const
Get the name of the exception.
Definition: Exception.h:47