Utils/Logger: Remove dependency on libboost_datetime
[senf.git] / Console / ParsedCommand.ih
index d4a89f8..90231c2 100644 (file)
 
 namespace senf {
 namespace console {
+
+    template < class FunctionTraits, 
+               class ReturnType=typename FunctionTraits::result_type, 
+              unsigned arity=FunctionTraits::arity >
+    class ParsedCommandOverload;
+
+    template < class Overload, 
+               unsigned index=0, 
+               bool flag=(index < unsigned(Overload::traits::arity)) >
+    class ParsedArgumentAttributor;
+
 namespace detail {
 
-#ifndef DOXYGEN
+    /** \brief Internal: Argument information structure
+        
+        This class is used to hold argument information for automatically parsed commands. 
 
+        \see ParsedCommandOverloadBase
+     */
     struct ArgumentInfoBase
         : public intrusive_refcount
     {
@@ -55,6 +70,12 @@ namespace detail {
         virtual std::string defaultValueStr() const = 0;
     };
     
+    /** \brief Internal: Argument information structure
+        
+        This class is used to hold argument information for automatically parsed commands. 
+
+        \see ParsedCommandOverloadBase
+     */
     template <class ParameterType>
     struct ArgumentInfo 
         : public ArgumentInfoBase
@@ -72,6 +93,8 @@ namespace detail {
         virtual std::string defaultValueStr() const;
     };
     
+#ifndef DOXYGEN
+
     // FirstArgType returns void, if the function has no arguments, otherwise it returns arg1_type
 
     template <class Traits, bool flag=(Traits::arity>0)>
@@ -86,14 +109,14 @@ namespace detail {
         typedef typename Traits::arg1_type type;
     };
 
-    template <class Function, bool isFN=senf::is_any_function<Function>::value>
-    struct ParsedCommandTraits
+    template <class FnunctionP, class Function, bool isFN=boost::is_function<Function>::value>
+    struct ParsedCommandTraits_i
     {};
 
-    template <class Function>
-    struct ParsedCommandTraits<Function, true>
+    template <class FunctionP, class Function>
+    struct ParsedCommandTraits_i<FunctionP, Function, true>
     {
-        typedef Function base_type;
+        typedef FunctionP base_type;
         typedef typename senf::remove_any_pointer<base_type>::type function_type;
         typedef boost::function_traits<function_type> base_traits;
         typedef typename FirstArgType<base_traits>::type first_arg_type;
@@ -111,8 +134,24 @@ namespace detail {
         static const bool is_member = boost::is_member_pointer<base_type>::value;
         
         typedef typename senf::member_class<base_type>::type class_type;
+
+        typedef ParsedCommandOverload<traits> Overload;
+        typedef ParsedArgumentAttributor<Overload> Attributor;
     };
 
+    // Disable auto-parsing for ParseCommandInfo arg -> register manually parsed command
+    template <class FunctionP>
+    struct ParsedCommandTraits_i<FunctionP, void (std::ostream &, ParseCommandInfo const &), true>
+    {};
+
+    template <class FunctionP>
+    struct ParsedCommandTraits
+        : public ParsedCommandTraits_i< FunctionP, 
+                                        typename senf::remove_any_pointer<FunctionP>::type >
+    {};
+
+    struct ParsedCommandAddNodeAccess;
+
 #endif
 
 }}}