X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParsedCommand.hh;h=020fe6f8671ddbce7e2049d4940b89c68fb73894;hb=869df8df564cd4f4934d4cd1c1b290c2aeabbd92;hp=70f4203a855883a5a027fb375ca94181f53d8ead;hpb=7527fa188b41bd1e1ce1eb55777bfe360eb8373e;p=senf.git diff --git a/Console/ParsedCommand.hh b/Console/ParsedCommand.hh index 70f4203..020fe6f 100644 --- a/Console/ParsedCommand.hh +++ b/Console/ParsedCommand.hh @@ -80,14 +80,136 @@ namespace console { 1)) # include BOOST_PP_ITERATE() + class ParsedCommandAttributorBase + { + public: + OverloadedCommandNode & node() const; + operator OverloadedCommandNode & () const; + + protected: + ParsedCommandAttributorBase(ParsedCommandOverloadBase & overload, unsigned index); + + void argName(std::string const & name) const; + void argDoc(std::string const & doc) const; + template void defaultValue(Type const & value) const; + + ParsedCommandOverloadBase & overload() const; + void overloadDoc(std::string const & doc) const; + + void nodeDoc(std::string const & doc) const; + + private: + ParsedCommandOverloadBase & overload_; + unsigned index_; + }; + + template + class ParsedCommandAttributor + : public ParsedCommandAttributorBase + { + public: + Overload & overload() const; + + protected: + ParsedCommandAttributor(Overload & overload, unsigned index); + + private: + }; + + template + class ParsedAttributeAttributorBase + : public ParsedCommandAttributor + { + public: + Self doc(std::string const & doc) const; + Self overloadDoc(std::string const & doc) const; + + protected: + ParsedAttributeAttributorBase(Overload & overload, unsigned index); + + private: + }; + + template + class ParsedAttributeAttributor + : public ParsedAttributeAttributorBase< Overload, + ParsedAttributeAttributor > + { + public: + typedef typename senf::function_traits_arg_type< + typename Overload::traits, int(index) >::type arg_type; + typedef typename senf::remove_cvref< arg_type >::type value_type; + + typedef OverloadedCommandNode node_type; + typedef ParsedAttributeAttributor return_type; + + ParsedAttributeAttributor arg(std::string const & name = "", + std::string const & doc = "") const; + ParsedAttributeAttributor arg(std::string const & name, + std::string const & doc, + value_type const & value) const; + + private: + explicit ParsedAttributeAttributor(Overload & overload); + + ParsedAttributeAttributor next() const; + + void defaultValue(value_type const & value) const; + + template + friend class ParsedAttributeAttributor; + + template + friend ParsedAttributeAttributor< + ParsedCommandOverload::traits> > + senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int); + + template + friend ParsedAttributeAttributor< + ParsedCommandOverload::traits> > + senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, + Function fn, int, + typename boost::enable_if_c::is_member>::type * = 0); + }; + + template + class ParsedAttributeAttributor + : public ParsedAttributeAttributorBase< Overload, + ParsedAttributeAttributor > + { + public: + typedef OverloadedCommandNode node_type; + typedef ParsedAttributeAttributor return_type; + + private: + explicit ParsedAttributeAttributor(Overload & overload); + + template + friend class ParsedAttributeAttributor; + + template + friend ParsedAttributeAttributor< + ParsedCommandOverload::traits> > + senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int); + + template + friend ParsedAttributeAttributor< + ParsedCommandOverload::traits> > + senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, + Function fn, int, + typename boost::enable_if_c::is_member>::type * = 0); + }; + #ifndef DOXYGEN template - ParsedCommandOverload::traits> & + ParsedAttributeAttributor< + ParsedCommandOverload::traits> > senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int); template - ParsedCommandOverload::traits> & + ParsedAttributeAttributor< + ParsedCommandOverload::traits> > senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, Function fn, int, typename boost::enable_if_c::is_member>::type * = 0); @@ -99,6 +221,7 @@ namespace console { #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() BOOST_TYPEOF_REGISTER_TEMPLATE(senf::console::ParsedCommandOverload, (class,unsigned)) +BOOST_TYPEOF_REGISTER_TEMPLATE(senf::console::ParsedAttributeAttributor, (class, unsigned, bool)) BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function_traits, 1) ///////////////////////////////hh.e////////////////////////////////////////