X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FOverloadedCommand.hh;h=4402742127428f1cae5c1eb72d9ee4a67b0847de;hb=9a4ab28bb53bc1a7719141a2263282d4cf73b258;hp=ee9bde99f8e48381f11eb9773666e50e188a5f79;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/OverloadedCommand.hh b/Utils/Console/OverloadedCommand.hh index ee9bde9..4402742 100644 --- a/Utils/Console/OverloadedCommand.hh +++ b/Utils/Console/OverloadedCommand.hh @@ -29,6 +29,7 @@ // Custom includes #include "Node.hh" #include +#include #include "../../Utils/intrusive_refcount.hh" //#include "OverloadedCommand.mpp" @@ -48,6 +49,7 @@ namespace console { std::string type; ///< Argument type (string representation) std::string defaultValue; ///< Default value (string representation) or empty string std::string doc; ///< Documentation for this argument + bool singleToken; ///< \c true, if argument is parsed from single token }; /** \brief Base class for command overload of OverloadedCommandNode @@ -69,13 +71,13 @@ namespace console { virtual ~CommandOverload(); - void execute(std::ostream & os, ParseCommandInfo const & command); + void execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command); ///< Call the overload /**< If the \a arguments are not acceptable for this overload, a SyntaxErrorException must be thrown. Same as operator()() */ - void operator()(std::ostream & os, ParseCommandInfo const & command); + void operator()(boost::any & rv, std::ostream & os, ParseCommandInfo const & command); ///< Call the overload /**< If the \a arguments are not acceptable for this overload, a SyntaxErrorException must be thrown. @@ -120,7 +122,8 @@ namespace console { /**< This member must be implemented in the derived class to return the overloads documentation string. */ - virtual void v_execute(std::ostream & os, ParseCommandInfo const & command) const = 0; + virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command) + const = 0; ///< Execute the overload /**< This member must be implemented in the derived class o execute the overload. */ @@ -158,6 +161,8 @@ namespace console { class OverloadedCommandNode : public CommandNode { + typedef std::vector Overloads; + public: /////////////////////////////////////////////////////////////////////////// // Types @@ -169,6 +174,8 @@ namespace console { typedef OverloadedCommandNode node_type; typedef OverloadedCommandNode & return_type; + typedef boost::iterator_range OverloadsRange; + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -183,12 +190,16 @@ namespace console { 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 \a overload /**< overloadIndex returns the index of \a overload in the internal list of overloads. */ + OverloadsRange overloads() const; ///< Get all overloads + ptr thisptr(); cptr thisptr() const; @@ -196,12 +207,13 @@ namespace console { OverloadedCommandNode(); virtual void v_help(std::ostream & output) const; - virtual void v_execute(std::ostream & output, ParseCommandInfo const & command) const; - - typedef std::vector Overloads; + virtual std::string v_shorthelp() const; + virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command) + const; Overloads overloads_; std::string doc_; + std::string shortdoc_; }; /** \brief Basic command overload @@ -240,7 +252,8 @@ namespace console { 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; + virtual void v_execute(boost::any & rv, std::ostream & os, ParseCommandInfo const & command) + const; Function fn_; std::string doc_;