Electroneum
Loading...
Searching...
No Matches
epee::command_handler Class Reference

#include <console_handler.h>

Inheritance diagram for epee::command_handler:

Public Types

typedef boost::function< bool(const std::vector< std::string > &)> callback
typedef std::map< std::string, std::pair< callback, std::pair< std::string, std::string > > > lookup

Public Member Functions

std::string get_usage ()
std::pair< std::string, std::string > get_documentation (const std::vector< std::string > &cmd)
void set_handler (const std::string &cmd, const callback &hndlr, const std::string &usage="", const std::string &description="")
bool process_command_vec (const std::vector< std::string > &cmd)
bool process_command_str (const std::string &cmd)

Detailed Description

Definition at line 482 of file console_handler.h.

Member Typedef Documentation

◆ callback

typedef boost::function<bool (const std::vector<std::string> &)> epee::command_handler::callback

Definition at line 484 of file console_handler.h.

◆ lookup

typedef std::map<std::string, std::pair<callback, std::pair<std::string, std::string> > > epee::command_handler::lookup

Definition at line 485 of file console_handler.h.

Member Function Documentation

◆ get_documentation()

std::pair< std::string, std::string > epee::command_handler::get_documentation ( const std::vector< std::string > & cmd)
inline

Definition at line 498 of file console_handler.h.

499 {
500 if(cmd.empty())
501 return std::make_pair("", "");
502 auto it = m_command_handlers.find(cmd.front());
503 if(it == m_command_handlers.end())
504 return std::make_pair("", "");
505 return it->second.second;
506 }

◆ get_usage()

std::string epee::command_handler::get_usage ( )
inline

Definition at line 487 of file console_handler.h.

488 {
489 std::stringstream ss;
490
491 for(auto& x:m_command_handlers)
492 {
493 ss << x.second.second.first << ENDL;
494 }
495 return ss.str();
496 }
#define ENDL

◆ process_command_str()

bool epee::command_handler::process_command_str ( const std::string & cmd)
inline

Definition at line 530 of file console_handler.h.

531 {
532 std::vector<std::string> cmd_v;
533 boost::split(cmd_v,cmd,boost::is_any_of(" "), boost::token_compress_on);
534 return process_command_vec(cmd_v);
535 }
bool process_command_vec(const std::vector< std::string > &cmd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_command_vec()

bool epee::command_handler::process_command_vec ( const std::vector< std::string > & cmd)
inline

Definition at line 519 of file console_handler.h.

520 {
521 if(!cmd.size())
522 return false;
523 auto it = m_command_handlers.find(cmd.front());
524 if(it == m_command_handlers.end())
525 return false;
526 std::vector<std::string> cmd_local(cmd.begin()+1, cmd.end());
527 return it->second.first(cmd_local);
528 }
Here is the caller graph for this function:

◆ set_handler()

void epee::command_handler::set_handler ( const std::string & cmd,
const callback & hndlr,
const std::string & usage = "",
const std::string & description = "" )
inline

Definition at line 508 of file console_handler.h.

509 {
510 lookup::mapped_type & vt = m_command_handlers[cmd];
511 vt.first = hndlr;
512 vt.second.first = description.empty() ? cmd : usage;
513 vt.second.second = description.empty() ? usage : description;
514#ifdef HAVE_READLINE
516#endif
517 }
static void add_completion(const std::string &command)
Here is the call graph for this function:

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/console_handler.h