X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParsedCommand.ih;h=90231c20dfeb69d4673b84a90e6b12945bf2c6a2;hb=9cda1b12a3e68538ea8157ca96810f0423123a70;hp=445d05521c3d658ed813dc8f7749bdc7d7639141;hpb=bf1d8ba5ce6fc6a169a938183f8d01c8bdbccf32;p=senf.git diff --git a/Console/ParsedCommand.ih b/Console/ParsedCommand.ih index 445d055..90231c2 100644 --- a/Console/ParsedCommand.ih +++ b/Console/ParsedCommand.ih @@ -27,16 +27,75 @@ #define IH_ParsedCommand_ 1 // Custom includes +#include +#include +#include "Parse.hh" ///////////////////////////////ih.p//////////////////////////////////////// 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 { - template ::value> - struct ParsedCommandTraits - {}; + /** \brief Internal: Argument information structure + + This class is used to hold argument information for automatically parsed commands. + + \see ParsedCommandOverloadBase + */ + struct ArgumentInfoBase + : public intrusive_refcount + { + typedef boost::intrusive_ptr ptr; + + std::string type; + std::string name; + std::string defaultDoc; + bool hasDefault; + std::string doc; + + ArgumentInfoBase(std::string const & type); + + 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 + struct ArgumentInfo + : public ArgumentInfoBase + { + typedef boost::intrusive_ptr ptr; + typedef boost::function Parser; + + static ptr create(); + ArgumentInfo(); + + ParameterType defaultValue; + Parser parser; + + virtual std::string defaultValueStr() const; + }; + +#ifndef DOXYGEN + + // FirstArgType returns void, if the function has no arguments, otherwise it returns arg1_type template 0)> struct FirstArgType @@ -50,14 +109,16 @@ namespace detail { typedef typename Traits::arg1_type type; }; - template - struct ParsedCommandTraits + template ::value> + struct ParsedCommandTraits_i + {}; + + template + struct ParsedCommandTraits_i { - typedef Function base_type; - typedef typename senf::remove_member_pointer< - typename boost::remove_pointer::type>::type function_type; + typedef FunctionP base_type; + typedef typename senf::remove_any_pointer::type function_type; typedef boost::function_traits base_traits; - typedef typename FirstArgType::type first_arg_type; static const bool has_ostream_arg = boost::is_same::value; @@ -68,11 +129,31 @@ namespace detail { base_traits> ::type traits; + typedef typename senf::remove_cvref::type result_type; + static const bool is_member = boost::is_member_pointer::value; typedef typename senf::member_class::type class_type; + + typedef ParsedCommandOverload Overload; + typedef ParsedArgumentAttributor Attributor; }; + // Disable auto-parsing for ParseCommandInfo arg -> register manually parsed command + template + struct ParsedCommandTraits_i + {}; + + template + struct ParsedCommandTraits + : public ParsedCommandTraits_i< FunctionP, + typename senf::remove_any_pointer::type > + {}; + + struct ParsedCommandAddNodeAccess; + +#endif + }}} ///////////////////////////////ih.e////////////////////////////////////////