X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FParsedCommand.mpp;h=df42e0ae6a4f039ba763044e14d9c49c6cb26add;hb=01e02e262ea327678dfa0c3f7a66d50ed91924d5;hp=57948c1972da882599f521d47abd5256c1d134e6;hpb=748363b235c4651b3992cc291a95dc2e18e45724;p=senf.git diff --git a/Console/ParsedCommand.mpp b/Console/ParsedCommand.mpp index 57948c1..df42e0a 100644 --- a/Console/ParsedCommand.mpp +++ b/Console/ParsedCommand.mpp @@ -29,6 +29,8 @@ // Custom includes #include #include +#include +#include #include #include #include @@ -70,9 +72,8 @@ public: mpp_TrailingArgTypes())> Function; # define mpp_l(z,n,d) \ - typedef typename boost::remove_const< \ - typename boost::remove_reference< typename traits::mpp_ArgTypeN(n) >::type >::type \ - mpp_ArgTypeN(n); + typedef typename senf::remove_cvref< typename traits::mpp_ArgTypeN(n) >::type \ + mpp_ArgTypeN(n); BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ ) # undef mpp_l @@ -125,34 +126,19 @@ v_execute(std::ostream & os, ParseCommandInfo const & command) { if ( command.arguments().size() > BOOST_PP_ITERATION() || (command.arguments().size() < BOOST_PP_ITERATION() - && ! arg( BOOST_PP_ITERATION()-1 ).hasDefault) ) + && ! arg( command.arguments().size() ).hasDefault) ) throw SyntaxErrorException("invalid number of arguments"); - // First define local variables argN for the parameters. The variables are initialized to their - // default values -# define mpp_l(z,n,d) mpp_ArgTypeN(n) mpp_ArgN(n) (arg< mpp_ArgTypeN(n) >( n ).defaultValue); - BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ ) -# undef mpp_l - ParseCommandInfo::argument_iterator i (command.arguments().begin()); ParseCommandInfo::argument_iterator const i_end (command.arguments().end()); - // Now parse the arguments which are provided leaving the trailing arguments at their default - // value. We have already checked above, whether those default values are valid. Be aware, that - // the following cases do NOT have 'break' statements ! - - switch (BOOST_PP_ITERATION() - command.arguments().size()) { - # define mpp_l(z,n,d) \ - case n : \ + mpp_ArgTypeN(n) mpp_ArgN(n) (arg< mpp_ArgTypeN(n) >( n ).defaultValue); \ + if (i != i_end) \ detail::ParameterTraits< mpp_ArgTypeN(n) >::parse( *(i++), mpp_ArgN(n) ); BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ ) # undef mpp_l - default : // This happens, if ALL arguments are defaulted - ; - } - // Now call the function binding the arguments to the values parsed above. callAndWrite is // specialized to ignore a 'void' return value but automatically write all other values to the // output stream. @@ -183,6 +169,19 @@ struct CreateParsedCommandOverload }; // //////////////////////////////////////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==5 // //////////////////////////////////// +// //////////////////////////////////////////////////////////////////////// + +// Create keyword arg forwarding functions + +template +next_type arg ( BOOST_PP_ENUM_BINARY_PARAMS( BOOST_PP_ITERATION(), A, const & a ), + typename arg_params::match< BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ) >::type + kw = arg_params()) const { + return argInfo( kw(BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), a )) ); +} + +// //////////////////////////////////////////////////////////////////////// #endif // ///////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////// // Undefine local Macros