Utils/Console: UDPServer documentation
[senf.git] / Utils / Console / OverloadedCommand.hh
index ee9bde9..4402742 100644 (file)
@@ -29,6 +29,7 @@
 // Custom includes
 #include "Node.hh"
 #include <boost/intrusive_ptr.hpp>
+#include <boost/range/iterator_range.hpp>
 #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<CommandOverload::ptr> Overloads;
+
     public:
         ///////////////////////////////////////////////////////////////////////////
         // Types
@@ -169,6 +174,8 @@ namespace console {
         typedef OverloadedCommandNode node_type;
         typedef OverloadedCommandNode & return_type;
 
+        typedef boost::iterator_range<Overloads::const_iterator> 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<CommandOverload::ptr> 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_;