class OverloadedCommandNode;
+ struct ArgumentDoc {
+ std::string name;
+ std::string type;
+ std::string defaultValue;
+ std::string doc;
+ };
+
/** \brief Base class for command overload of OverloadedCommandNode
This class is the base class of the commands which may be added to an
// Types
typedef boost::intrusive_ptr<CommandOverload> ptr;
+ typedef boost::intrusive_ptr<CommandOverload const> cptr;
///////////////////////////////////////////////////////////////////////////
/**< If the \a arguments are not acceptable for this
overload, a SyntaxErrorException must be thrown.
Same as execute() */
-
- void help(std::ostream & os); ///< Provide help for this specific overload
-
- OverloadedCommandNode & node(); ///< Access owning node
+
+ unsigned numArguments() const;
+ void argumentDoc(unsigned index, ArgumentDoc & doc) const;
+ std::string doc() const;
+
+ OverloadedCommandNode & node() const; ///< Access owning node
/**< \pre The command \e must have been added to an
OverloadedCommandNode. */
+ unsigned overloadIndex() const;
protected:
CommandOverload();
#ifndef DOXYGEN
private:
#endif
- virtual void v_help(std::ostream & os) const = 0;
+ virtual unsigned v_numArguments() const = 0;
+ virtual void v_argumentDoc(unsigned index, ArgumentDoc & doc) const = 0;
+ virtual std::string v_doc() const = 0;
virtual void v_execute(std::ostream & os, ParseCommandInfo const & command) const = 0;
private:
cmd.add(senf::console::SimpleCommandOverload::create(&anotherCallback));
\endcode
- However, this facility is mostly used not directly but indirectly (and automatically) when
+ However, this facility is normally used not directly but indirectly (and automatically) when
adding argument parsing callbacks.
\warning For this to work, the commands <b>must</b> do all syntax checking before doing any
operation
- \ingroup node_tree
+ \ingroup console_commands
*/
class OverloadedCommandNode
: public CommandNode
typedef boost::shared_ptr<OverloadedCommandNode const> cptr;
typedef boost::weak_ptr<OverloadedCommandNode> weak_ptr;
+ typedef OverloadedCommandNode node_type;
+ typedef OverloadedCommandNode & return_type;
+
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
///@{
OverloadedCommandNode & doc(std::string const & doc);
///< Assign global help for all overloads
+ unsigned overloadIndex(CommandOverload const & overload);
+
protected:
private:
private:
SimpleCommandOverload(Function fn);
- virtual void v_help(std::ostream & os) const;
+ virtual unsigned v_numArguments() const;
+ virtual void v_argumentDoc(unsigned index, ArgumentDoc & doc) const;
+ virtual std::string v_doc() const;
virtual void v_execute(std::ostream & os, ParseCommandInfo const & command) const;
Function fn_;