#include <senf/Utils/Console/OverloadedCommand.hh>
OverloadedCommandNode is like SimpleCommandNode but allows to register multiple commands to a single node. This works by calling each command in the list consecutively until no 'SyntaxErrorException' exception is thrown.
This works by first adding an OverloadedCommandNode to the directory in question and then adding commands to that node. Commands are derived from CommandOverload.
senf::console::DirectoryNode & dir (...); senf::console::OverloadedCommandNode & cmd ( dir.add("cmd", senf::console::OverloadedCommandNode::create()) ); cmd.add(senf::console::SimpleCommandOverload::create(&callback)); cmd.add(senf::console::SimpleCommandOverload::create(&anotherCallback));
However, this facility is normally used not directly but indirectly (and automatically) when adding argument parsing callbacks.
Definition at line 162 of file OverloadedCommand.hh.
Public Types |
|
typedef boost::shared_ptr < OverloadedCommandNode > |
ptr |
typedef boost::shared_ptr < OverloadedCommandNode const > |
cptr |
typedef boost::weak_ptr < OverloadedCommandNode > |
weak_ptr |
typedef OverloadedCommandNode | node_type |
typedef OverloadedCommandNode & | return_type |
typedef boost::iterator_range < Overloads::const_iterator > |
OverloadsRange |
Public Member Functions |
|
template<class Command > | |
Command & | add (boost::intrusive_ptr< Command > overload) |
Add an additional overload. |
|
OverloadedCommandNode & | doc (std::string const &doc) |
Assign global help for all overloads. |
|
OverloadedCommandNode & | shortdoc (std::string const &doc) |
Assign short documentation for all overloads. |
|
unsigned | overloadIndex (CommandOverload const &overload) |
Return the overload index for overload. |
|
OverloadsRange | overloads () const |
Get all overloads. |
|
ptr | thisptr () |
Get smart pointer to node. |
|
cptr | thisptr () const |
Get smart pointer to node (const). |
|
Static Public Member Functions |
|
static OverloadedCommandNode & | insertOverload (DirectoryNode &dir, std::string const &name, CommandOverload::ptr overload) |
Structors and default members |
|
static ptr | create () |
typedef boost::shared_ptr<OverloadedCommandNode const> senf::console::OverloadedCommandNode:: | ||||
cptr | ||||
Reimplemented from senf::console::CommandNode.
Definition at line 172 of file OverloadedCommand.hh.
typedef OverloadedCommandNode senf::console::OverloadedCommandNode:: | ||||
node_type | ||||
Definition at line 175 of file OverloadedCommand.hh.
typedef boost::iterator_range<Overloads::const_iterator> senf::console::OverloadedCommandNode:: | ||||
OverloadsRange | ||||
Definition at line 178 of file OverloadedCommand.hh.
typedef boost::shared_ptr<OverloadedCommandNode> senf::console::OverloadedCommandNode:: | ||||
ptr | ||||
Reimplemented from senf::console::CommandNode.
Definition at line 171 of file OverloadedCommand.hh.
typedef OverloadedCommandNode& senf::console::OverloadedCommandNode:: | ||||
return_type | ||||
Definition at line 176 of file OverloadedCommand.hh.
typedef boost::weak_ptr<OverloadedCommandNode> senf::console::OverloadedCommandNode:: | ||||
weak_ptr | ||||
Reimplemented from senf::console::CommandNode.
Definition at line 173 of file OverloadedCommand.hh.
Command & senf::console::OverloadedCommandNode:: | ||||
add | ( | boost::intrusive_ptr< Command > | overload | ) |
Add an additional overload.
Definition at line 38 of file OverloadedCommand.cti.
senf::console::OverloadedCommandNode::ptr senf::console::OverloadedCommandNode:: | ||||
create | () | |||
Definition at line 36 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode & senf::console::OverloadedCommandNode:: | ||||
doc | ( | std::string const & | doc | ) |
Assign global help for all overloads.
Definition at line 53 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode & senf::console::OverloadedCommandNode:: | ||||
insertOverload | ( | DirectoryNode & | dir, | |
std::string const & | name, | |||
CommandOverload::ptr | overload | ) | ||
Definition at line 39 of file OverloadedCommand.cc.
unsigned senf::console::OverloadedCommandNode:: | ||||
overloadIndex | ( | CommandOverload const & | overload | ) |
Return the overload index for overload.
overloadIndex returns the index of overload in the internal list of overloads.
Definition at line 67 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode::OverloadsRange senf::console::OverloadedCommandNode:: | ||||
overloads | () | |||
Get all overloads.
Definition at line 74 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode & senf::console::OverloadedCommandNode:: | ||||
shortdoc | ( | std::string const & | doc | ) |
Assign short documentation for all overloads.
Definition at line 60 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode::cptr senf::console::OverloadedCommandNode:: | ||||
thisptr | () | |||
Get smart pointer to node (const).
Reimplemented from senf::console::CommandNode.
Definition at line 46 of file OverloadedCommand.cci.
senf::console::OverloadedCommandNode::ptr senf::console::OverloadedCommandNode:: | ||||
thisptr | () | |||
Get smart pointer to node.
Reimplemented from senf::console::CommandNode.
Definition at line 41 of file OverloadedCommand.cci.