X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParsedCommand.cti;h=f4b523fda417c0d1e9fe05ea02776e424532608e;hb=8e708e9784c76461252c3bdf646d291c593a49be;hp=e37906c81b4a5a91fa8d2e5b7b4d9517defd406e;hpb=61bbb1c1ec66b1a41951fc971d0325095e17e7a9;p=senf.git diff --git a/Console/ParsedCommand.cti b/Console/ParsedCommand.cti index e37906c..f4b523f 100644 --- a/Console/ParsedCommand.cti +++ b/Console/ParsedCommand.cti @@ -28,7 +28,7 @@ // Custom includes #include "../Utils/membind.hh" #include -#include +#include "../Utils/parameter.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -99,6 +99,13 @@ prefix_ void senf::console::ParsedCommandAttributorBase::defaultValue(Type const overload().arg(index_).hasDefault = true; } +template +prefix_ void senf::console::ParsedCommandAttributorBase::parser(Fn fn) + const +{ + overload().arg(index_).parser = fn; +} + /////////////////////////////////////////////////////////////////////////// // senf::console::ParsedCommandAttributor @@ -162,12 +169,15 @@ senf::console::ParsedArgumentAttributor:: argInfo(ArgumentPack const & args) const { -# define HaveArg(tag) boost::is_same< \ - typename boost::parameter::binding::type, void >() +# define ProcessArg(tag) \ + argInfo( kw:: tag, args, senf::has_parameter< ArgumentPack, kw::type:: tag >() ) - argInfo( kw::name, args, HaveArg(kw::type::name) ); - argInfo( kw::description, args, HaveArg(kw::type::description) ); - argInfo( kw::default_value, args, HaveArg(kw::type::default_value) ); + ProcessArg(name); + ProcessArg(description); + ProcessArg(default_value); + ProcessArg(type_name); + ProcessArg(default_doc); + ProcessArg(parser); return next(); @@ -177,7 +187,7 @@ argInfo(ArgumentPack const & args) template template prefix_ void senf::console::ParsedArgumentAttributor:: -argInfo(Kw const &, ArgumentPack const &, boost::mpl::true_) +argInfo(Kw const &, ArgumentPack const &, boost::mpl::false_) const {} @@ -185,7 +195,7 @@ template template prefix_ void senf::console::ParsedArgumentAttributor:: argInfo(boost::parameter::keyword const &, ArgumentPack const & args, - boost::mpl::false_) + boost::mpl::true_) const { this->argName(args[kw::name]); @@ -195,7 +205,7 @@ template template prefix_ void senf::console::ParsedArgumentAttributor:: argInfo(boost::parameter::keyword const &, ArgumentPack const & args, - boost::mpl::false_) + boost::mpl::true_) const { this->argDoc(args[kw::description]); @@ -205,13 +215,44 @@ template template prefix_ void senf::console::ParsedArgumentAttributor:: argInfo(boost::parameter::keyword const &, ArgumentPack const & args, - boost::mpl::false_) + boost::mpl::true_) const { this->defaultValue(args[kw::default_value]); } template +template +prefix_ void senf::console::ParsedArgumentAttributor:: +argInfo(boost::parameter::keyword const &, ArgumentPack const & args, + boost::mpl::true_) + const +{ + this->typeName(args[kw::type_name]); +} + +template +template +prefix_ void senf::console::ParsedArgumentAttributor:: +argInfo(boost::parameter::keyword const &, ArgumentPack const & args, + boost::mpl::true_) + const +{ + BOOST_STATIC_ASSERT(( senf::has_parameter::value )); + this->defaultDoc(args[kw::default_doc]); +} + +template +template +prefix_ void senf::console::ParsedArgumentAttributor:: +argInfo(boost::parameter::keyword const &, ArgumentPack const & args, + boost::mpl::true_) + const +{ + this->parser(args[kw::parser]); +} + +template prefix_ senf::console::ParsedArgumentAttributor:: ParsedArgumentAttributor(Overload & overload) @@ -231,7 +272,15 @@ prefix_ void senf::console::ParsedArgumentAttributor:: defaultValue(value_type const & value) const { - ParsedCommandAttributorBase::defaultValue(value); + ParsedCommandAttributorBase::defaultValue(value); +} + +template +template +prefix_ void senf::console::ParsedArgumentAttributor::parser(Fn fn) + const +{ + ParsedCommandAttributorBase::parser(fn); } ///////////////////////////////////////////////////////////////////////////