16 #include <boost/algorithm/string.hpp> 25 std::unique_ptr<std::map<std::string, inspect::command_handler*>>
26 inspect::m_cmd_handlers;
28 std::unique_ptr<std::deque<std::pair<std::vector<std::string>,
std::string>>>
29 inspect::m_help_handlers;
34 if (message.length()) {
35 if (message.find(
"help") != std::string::npos) {
36 output <<
"Command Options: " << std::endl;
37 output <<
" keys - Show all keys owning objects" 39 output <<
" key:XXX - Show all object referenced by " 42 output <<
" all - Show All objects" << std::endl;
43 output <<
"Individual object_base Types:" << std::endl;
45 for (
auto h : *m_help_handlers) {
48 for (
auto s :
h.first) {
55 }
else if (message.find(
"keys") != std::string::npos) {
57 }
else if (message.find(
"key:") != std::string::npos) {
58 std::vector<std::string> results;
59 boost::split(results, message, boost::is_any_of(
":\n"));
61 }
else if (message.find(
"all") != std::string::npos) {
65 std::set<command_handler*> hdlrs;
66 for (
auto h : *m_cmd_handlers) {
67 hdlrs.insert(
h.second);
69 for (
auto h : hdlrs) {
73 auto it = m_cmd_handlers->find(message);
75 if (
it != m_cmd_handlers->end()) {
76 it->second->show(output);
78 output <<
"Unknown Command: " << message << std::endl;
89 if (!m_cmd_handlers) {
90 m_cmd_handlers.reset(
new std::map<std::string, command_handler*>);
91 m_help_handlers.reset(
92 new std::deque<std::pair<std::vector<std::string>,
std::string>>);
95 for (
auto cmd : cmds) {
96 (*m_cmd_handlers)[
cmd] = handler;
98 m_help_handlers->push_front(std::make_pair(cmds, help));
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
void handle_input(const std::string &input, std::ostream &output)
handle input from the requester
inspect command handler Handler
The VPP Object Model (VOM) library.
A representation of a method call to VPP.
save_rewrite_length must be aligned so that reass doesn t overwrite it
static void dump(const client_db::key_t &key, std::ostream &os)
Print each of the object in the DB into the stream provided.