17 #ifndef HH_SENF_Utils_Console_OverloadedCommand_ 18 #define HH_SENF_Utils_Console_OverloadedCommand_ 1 22 #include <boost/intrusive_ptr.hpp> 23 #include <boost/range/iterator_range.hpp> 25 #include <boost/optional.hpp> 33 class OverloadedCommandNode;
59 typedef boost::intrusive_ptr<CommandOverload>
ptr;
60 typedef boost::intrusive_ptr<CommandOverload const>
cptr;
66 void execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command);
72 void operator()(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command);
78 unsigned numArguments()
const;
87 std::string
doc()
const;
93 unsigned overloadIndex()
const;
101 virtual unsigned v_numArguments()
const = 0;
106 virtual void v_argumentDoc(
unsigned index,
ArgumentDoc &
doc)
const = 0;
112 virtual std::string v_doc()
const = 0;
117 virtual void v_execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command)
156 typedef std::vector<CommandOverload::ptr> Overloads;
162 typedef boost::shared_ptr<OverloadedCommandNode>
ptr;
163 typedef boost::shared_ptr<OverloadedCommandNode const>
cptr;
164 typedef boost::weak_ptr<OverloadedCommandNode>
weak_ptr;
180 template <
class Command>
181 Command & add(boost::intrusive_ptr<Command> overload);
193 OverloadsRange overloads()
const;
196 cptr thisptr()
const;
204 virtual void v_help(std::ostream & output)
const;
205 virtual std::string v_shorthelp()
const;
206 virtual void v_execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command)
209 Overloads overloads_;
211 std::string shortdoc_;
227 typedef boost::intrusive_ptr<SimpleCommandOverload>
ptr;
228 typedef boost::function<void (std::ostream &, ParseCommandInfo const &)>
Function;
247 virtual unsigned v_numArguments()
const;
248 virtual void v_argumentDoc(
unsigned index,
ArgumentDoc &
doc)
const;
249 virtual std::string v_doc()
const;
250 virtual void v_execute(boost::any & rv, std::ostream & os,
ParseCommandInfo const & command)
274 mutable boost::optional<std::string> doc_;
275 mutable boost::optional<std::string> shortdoc_;
bool singleToken
true, if argument is parsed from single token
std::string type
Argument type (string representation)
std::string doc
Documentation for this argument.
OverloadedCommandNode node_type
boost::intrusive_ptr< CommandOverload const > cptr
boost::shared_ptr< OverloadedCommandNode const > cptr
OverloadedCommandNode & return_type
boost::intrusive_ptr< CommandOverload > ptr
Config/console tree directory node.
boost::intrusive_ptr< SimpleCommandOverload > ptr
Command node which allows multiple registered callbacks.
Single parsed console command.
std::string defaultValue
Default value (string representation) or empty string.
boost::function< void(std::ostream &, ParseCommandInfo const &)> Function
Base class for command overload of OverloadedCommandNode.
boost::iterator_range< Overloads::const_iterator > OverloadsRange
OverloadedCommandNode node_type
Config/console tree command node.
std::string name
Argument name.
boost::weak_ptr< OverloadedCommandNode > weak_ptr
Documentation for a single argument.
boost::shared_ptr< OverloadedCommandNode > ptr
OverloadedCommandNode & result_type