Console: More documentation and cleanup
[senf.git] / Console / ParsedCommand.ih
index 445d055..d8a72d2 100644 (file)
@@ -34,10 +34,43 @@ namespace senf {
 namespace console {
 namespace detail {
 
+#ifndef DOXYGEN
+
+    struct ArgumentInfoBase
+        : public intrusive_refcount
+    {
+        typedef boost::intrusive_ptr<ArgumentInfoBase> ptr;
+        
+        std::string type;
+        std::string name;
+        bool hasDefault;
+        std::string doc;
+        
+        ArgumentInfoBase(std::string const & type);
+
+        virtual std::string defaultValueStr() const = 0;
+    };
+    
+    template <class ParameterType>
+    struct ArgumentInfo 
+        : public ArgumentInfoBase
+    {
+        typedef boost::intrusive_ptr<ArgumentInfo> ptr;
+
+        static ptr create();
+        ArgumentInfo();
+
+        ParameterType defaultValue;
+
+        virtual std::string defaultValueStr() const;
+    };
+    
     template <class Function, bool isFN=senf::is_any_function<Function>::value>
     struct ParsedCommandTraits
     {};
 
+    // FirstArgType returns void, if the function has no arguments, otherwise it returns arg1_type
+
     template <class Traits, bool flag=(Traits::arity>0)>
     struct FirstArgType
     {
@@ -54,10 +87,8 @@ namespace detail {
     struct ParsedCommandTraits<Function, true>
     {
         typedef Function base_type;
-        typedef typename senf::remove_member_pointer<
-            typename boost::remove_pointer<base_type>::type>::type function_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;
 
         static const bool has_ostream_arg = boost::is_same<first_arg_type, std::ostream &>::value;
@@ -73,6 +104,22 @@ namespace detail {
         typedef typename senf::member_class<base_type>::type class_type;
     };
 
+    template <class Type>
+    struct CheckVoidReturn
+    {
+        template <class Fn>
+        static void call(Fn fn, std::ostream & os);
+    };
+
+    template <>
+    struct CheckVoidReturn<void>
+    {
+        template <class Fn>
+        static void call(Fn fn, std::ostream & os);
+    };
+
+#endif
+
 }}}
 
 ///////////////////////////////ih.e////////////////////////////////////////