17 #ifndef HH_SENF_Utils_Console_ParsedCommand_ 18 #define HH_SENF_Utils_Console_ParsedCommand_ 1 22 #define BOOST_PARAMETER_MAX_ARITY 7 25 #include <boost/type_traits/function_traits.hpp> 26 #include <boost/type_traits/is_member_function_pointer.hpp> 27 #include <boost/mpl/if.hpp> 28 #include <boost/parameter/keyword.hpp> 29 #include <boost/parameter/parameters.hpp> 30 #include <senf/config.hh> 42 namespace detail {
struct ArgumentInfoBase; }
130 typedef boost::intrusive_ptr<ParsedCommandOverloadBase>
ptr;
132 detail::ArgumentInfoBase & arg(
unsigned n)
const;
134 void doc(std::string
const & d);
139 template <
class Type>
void addParameter();
142 virtual unsigned v_numArguments()
const;
143 virtual void v_argumentDoc(
unsigned index,
ArgumentDoc & doc)
const;
144 virtual std::string v_doc()
const;
146 typedef std::vector<detail::ArgumentInfoBase::ptr> Parameters;
147 Parameters parameters_;
165 template <
class FunctionTraits,
class ReturnType,
unsigned arity>
169 typedef boost::intrusive_ptr<ParsedCommandOverload>
ptr;
174 # define BOOST_PP_ITERATION_PARAMS_1 \ 175 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \ 176 SENF_ABSOLUTE_INCLUDE_PATH(Utils/Console/ParsedCommand.mpp), \ 178 # include BOOST_PP_ITERATE() 203 void argName(std::string
const &
name);
204 void argDoc(std::string
const & doc);
205 void typeName(std::string
const & doc);
206 void defaultDoc(std::string
const & doc);
209 void overloadDoc(std::string
const & doc);
210 void nodeDoc(std::string
const & doc);
211 void shortDoc(std::string
const & doc);
218 boost::optional<std::string> doc_;
219 boost::optional<std::string> shortdoc_;
234 template <
class Overload>
239 Overload & overload()
const;
308 BOOST_PARAMETER_KEYWORD(type,
name)
399 template <class Overload, class Self, class ReturnType=typename Overload::traits::result_type>
404 Self doc(std::string
const & doc);
405 Self shortdoc(std::string
const & doc);
406 Self overloadDoc(std::string
const & doc);
407 Self formatter(
typename Overload::Formatter formatter);
429 template <
class Overload,
class Self>
434 Self doc(std::string
const & doc);
435 Self shortdoc(std::string
const & doc);
436 Self overloadDoc(std::string
const & doc);
457 template <
class Overload,
unsigned index,
bool flag>
460 ParsedArgumentAttributor<Overload, index, flag> >
462 typedef boost::parameter::parameters<
472 typename Overload::traits, int(index) >::type
arg_type;
476 next_type arg()
const;
497 # define BOOST_PP_ITERATION_PARAMS_1 \ 498 (4, (1, BOOST_PARAMETER_MAX_ARITY, \ 499 SENF_ABSOLUTE_INCLUDE_PATH(Utils/Console/ParsedCommand.mpp), \ 501 # include BOOST_PP_ITERATE() 508 template <
class ArgumentPack>
509 next_type argInfo(ArgumentPack
const & args);
510 template <
class Kw,
class ArgumentPack>
511 void argInfo(Kw
const &, ArgumentPack
const &, boost::mpl::false_);
513 template <
class ArgumentPack>
514 void argInfo(boost::parameter::keyword<kw::type::name>
const &,
515 ArgumentPack
const & args, boost::mpl::true_);
516 template <
class ArgumentPack>
517 void argInfo(boost::parameter::keyword<kw::type::description>
const &,
518 ArgumentPack
const & args, boost::mpl::true_);
519 template <
class ArgumentPack>
520 void argInfo(boost::parameter::keyword<kw::type::default_value>
const &,
521 ArgumentPack
const & args, boost::mpl::true_);
522 template <
class ArgumentPack>
523 void argInfo(boost::parameter::keyword<kw::type::type_name>
const &,
524 ArgumentPack
const & args, boost::mpl::true_);
525 template <
class ArgumentPack>
526 void argInfo(boost::parameter::keyword<kw::type::default_doc>
const &,
527 ArgumentPack
const & args, boost::mpl::true_);
528 template <
class ArgumentPack>
529 void argInfo(boost::parameter::keyword<kw::type::parser>
const &,
530 ArgumentPack
const & args, boost::mpl::true_);
532 next_type next()
const;
534 void defaultValue(value_type
const & value);
535 template <
class Fn>
void parser(Fn fn);
537 template <
class O,
unsigned i,
bool f>
540 friend struct detail::ParsedCommandAddNodeAccess;
545 template <
class Overload,
unsigned index>
548 ParsedArgumentAttributor<Overload, index, false> >
558 template <
class O,
unsigned i,
bool f>
561 friend struct detail::ParsedCommandAddNodeAccess;
611 template <
class Signature>
616 Command(member_function_pointer fn, Owner
const * owner);
618 template <
class Signature>
619 Command(member_function_pointer fn, Owner
const * owner);
629 template <
class Signature>
631 Command(boost::function<Signature> fn,
632 typename boost::enable_if_c<detail::ParsedCommandTraits<Signature>::is_simple>::type * = 0);
634 template <
class Function>
637 typename boost::enable_if_c<detail::ParsedCommandTraits<Function>::is_simple>::type * = 0);
639 template <
class Owner,
class Member>
641 Command(Member memfn, Owner * owner,
642 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0,
643 typename boost::enable_if_c<detail::ParsedCommandTraits<Member>::is_simple>::type * = 0);
645 template <
class Owner,
class Member>
647 Command(Member memfn, Owner
const * owner,
648 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0,
649 typename boost::enable_if_c<detail::ParsedCommandTraits<Member>::is_simple>::type * = 0);
651 template <
class CastTo,
class Signature>
652 typename senf::console::detail::ParsedCommandTraits<CastTo>::Attributor
653 Command(boost::function<Signature> fn);
655 template <
class CastTo,
class Function>
656 typename senf::console::detail::ParsedCommandTraits<CastTo>::Attributor
658 typename boost::enable_if_c<detail::ParsedCommandTraits<Function>::is_callable>::type * = 0,
659 typename boost::disable_if<boost::is_member_function_pointer<Function> >::type * = 0);
661 template <
class Signature>
662 typename senf::console::detail::ParsedCommandTraits<Signature>::Attributor
663 Command(boost::function<Signature> fn);
665 template <
class Function>
666 typename senf::console::detail::ParsedCommandTraits<Function>::Attributor
668 typename boost::enable_if_c<detail::ParsedCommandTraits<Function>::is_callable>::type * = 0,
669 typename boost::disable_if<boost::is_member_function_pointer<Function> >::type * = 0);
671 template <
class Owner,
class Member>
672 typename senf::console::detail::ParsedCommandTraits<Member>::Attributor
673 Command(Member memfn, Owner * owner,
674 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0);
676 template <
class Owner,
class Member>
677 typename senf::console::detail::ParsedCommandTraits<Member>::Attributor
678 Command(Member memfn, Owner
const * owner,
679 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0);
681 template <
class CastTo,
class Owner,
class Member>
682 typename senf::console::detail::ParsedCommandTraits<CastTo>::Attributor
683 Command(Member memfn, Owner * owner,
684 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0);
686 template <
class CastTo,
class Owner,
class Member>
687 typename senf::console::detail::ParsedCommandTraits<CastTo>::Attributor
688 Command(Member memfn, Owner
const * owner,
689 typename boost::enable_if<boost::is_member_function_pointer<Member> >::type * = 0);
OverloadedCommandNode & result_type
Derived class dependent ParsedCommandBase attributes.
unspecified_keyword_type default_value
Argument default value.
unspecified_keyword_type default_doc
String rep of default value.
unspecified_keyword_type parser
Argument parser.
Config/console tree directory node.
Non argument dependent ParsedCommandBase attributes.
unspecified_keyword_type type_name
Type name of this arguments type.
OverloadedCommandNode factory.
boost::intrusive_ptr< ParsedCommandOverload > ptr
Command node which allows multiple registered callbacks.
senf::remove_cvref< arg_type >::type value_type
Generic ParsedCommandOverloadBase attributes.
ParsedArgumentAttributor< Overload, index+1 > next_type
Argument dependent ParsedCommandBase attributes.
OverloadedCommand public header.
CommandOverload implementation with automatic argument parsing.
OverloadedCommandNode node_type
senf::function_traits_arg_type< typename Overload::traits, int(index) >::type arg_type
Base class for command overload of OverloadedCommandNode.
unspecified_keyword_type description
One-line argument description.
boost::intrusive_ptr< ParsedCommandOverloadBase > ptr
OverloadedCommandNode node_type
unspecified_keyword_type name
Argument name.
Documentation for a single argument.