Electroneum
epee::async_console_handler Class Reference

#include <console_handler.h>

Public Member Functions

 async_console_handler ()
 
template<class t_server , class chain_handler >
bool run (t_server *psrv, chain_handler ch_handler, std::function< std::string(void)> prompt, const std::string &usage="")
 
template<class chain_handler >
bool run (chain_handler ch_handler, std::function< std::string(void)> prompt, const std::string &usage="", std::function< void(void)> exit_handler=NULL)
 
void stop ()
 
void print_prompt ()
 

Detailed Description

Definition at line 290 of file console_handler.h.

Constructor & Destructor Documentation

◆ async_console_handler()

epee::async_console_handler::async_console_handler ( )
inline

Definition at line 293 of file console_handler.h.

294  {
295  }

Member Function Documentation

◆ print_prompt()

void epee::async_console_handler::print_prompt ( )
inline

Definition at line 315 of file console_handler.h.

316  {
317  std::string prompt = m_prompt();
318  if (!prompt.empty())
319  {
320 #ifdef HAVE_READLINE
321  std::string color_prompt = "\001\033[1;33m\002" + prompt;
322  if (' ' != prompt.back())
323  color_prompt += " ";
324  color_prompt += "\001\033[0m\002";
325  m_stdin_reader.get_readline_buffer().set_prompt(color_prompt);
326 #else
328  std::cout << prompt;
329  if (' ' != prompt.back())
330  std::cout << ' ';
332  std::cout.flush();
333 #endif
334  }
335  }
::std::string string
Definition: gtest-port.h:1097
void reset_console_color()
Definition: mlog.cpp:460
void set_console_color(int color, bool bright)
Definition: mlog.cpp:341
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run() [1/2]

template<class t_server , class chain_handler >
bool epee::async_console_handler::run ( t_server *  psrv,
chain_handler  ch_handler,
std::function< std::string(void)>  prompt,
const std::string &  usage = "" 
)
inline

Definition at line 298 of file console_handler.h.

299  {
300  return run(prompt, usage, [&](const std::string& cmd) { return ch_handler(psrv, cmd); }, [&] { psrv->send_stop_signal(); });
301  }
::std::string string
Definition: gtest-port.h:1097
bool run(t_server *psrv, chain_handler ch_handler, std::function< std::string(void)> prompt, const std::string &usage="")
Here is the caller graph for this function:

◆ run() [2/2]

template<class chain_handler >
bool epee::async_console_handler::run ( chain_handler  ch_handler,
std::function< std::string(void)>  prompt,
const std::string &  usage = "",
std::function< void(void)>  exit_handler = NULL 
)
inline

Definition at line 304 of file console_handler.h.

305  {
306  return run(prompt, usage, [&](const std::string& cmd) { return ch_handler(cmd); }, exit_handler);
307  }
::std::string string
Definition: gtest-port.h:1097
bool run(t_server *psrv, chain_handler ch_handler, std::function< std::string(void)> prompt, const std::string &usage="")
Here is the call graph for this function:

◆ stop()

void epee::async_console_handler::stop ( )
inline

Definition at line 309 of file console_handler.h.

310  {
311  m_running = false;
312  m_stdin_reader.stop();
313  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: