5 #ifndef PACKIO_ARGS_SPECS_H 
    6 #define PACKIO_ARGS_SPECS_H 
   17 #include "internal/utils.h" 
   22 template <
typename DefaultType>
 
   25     explicit arg_spec(std::string name) : name_(std::move(name)) {}
 
   26     explicit arg_spec(
const arg& arg) : name_(arg.name()) {}
 
   27     explicit arg_spec(arg::with_value<DefaultType> arg)
 
   28         : name_(std::move(arg.name)), default_value_(std::move(arg.value))
 
   32     const std::string& name()
 const { 
return name_; }
 
   33     const std::optional<DefaultType>& default_value()
 const 
   35         return default_value_;
 
   40     std::optional<DefaultType> default_value_;
 
   44 using arg_specs_tuple_for_sync_procedure_t =
 
   45     map_tuple_t<arg_spec, decay_tuple_t<typename func_traits<F>::args_type>>;
 
   48 using arg_specs_tuple_for_async_procedure_t =
 
   49     left_shift_tuple_t<arg_specs_tuple_for_sync_procedure_t<F>>;
 
   51 template <
typename, 
bool>
 
   52 struct arg_specs_tuple_for;
 
   55 struct arg_specs_tuple_for<F, true> {
 
   56     using type = arg_specs_tuple_for_async_procedure_t<F>;
 
   60 struct arg_specs_tuple_for<F, false> {
 
   61     using type = arg_specs_tuple_for_sync_procedure_t<F>;
 
   65 using arg_specs_tuple_for_t =
 
   66     typename arg_specs_tuple_for<F, is_async_procedure_v<F>>::type;
 
   69 struct args_specs_maker;
 
   71 template <
typename... Specs>
 
   72 struct args_specs_maker<std::tuple<Specs...>> {
 
   73     template <
typename... Args>
 
   74     static std::tuple<Specs...> make(Args&&... args)
 
   76         if constexpr (
sizeof...(Args) == 0) {
 
   78             return iota(std::make_index_sequence<
sizeof...(Specs)>());
 
   82                 sizeof...(Args) == 
sizeof...(Specs),
 
   83                 "arguments specification must either match the number of " 
   84                 "arguments or be empty");
 
   85             return {Specs{std::forward<Args>(args)}...};
 
   89     template <std::size_t... Idxs>
 
   90     static std::tuple<Specs...> iota(std::index_sequence<Idxs...>)
 
   92         return {Specs{std::to_string(Idxs)}...};
 
  103     bool allow_extra_arguments = 
false;
 
  108         ret.allow_extra_arguments |= other.allow_extra_arguments;
 
  113 template <
typename SpecsTuple>
 
  121         typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, args_specs_options>>>
 
  124             args_specs_options{},
 
  125             std::forward<T>(arg0),
 
  126             std::forward<Args>(args)...)
 
  130     template <
typename... Args>
 
  131     args_specs(args_specs_options opts, Args&&... args)
 
  132         : specs_{args_specs_maker<SpecsTuple>::make(std::forward<Args>(args)...)},
 
  133           opts_{std::move(opts)}
 
  137     constexpr 
const args_specs_options& options()
 const { 
return opts_; }
 
  139     template <std::
size_t I>
 
  140     constexpr decltype(
auto) get()
 const 
  142         return std::get<I>(specs_);
 
  145     static constexpr std::size_t size()
 
  147         return std::tuple_size_v<SpecsTuple>;
 
  152     args_specs_options opts_{};
 
  170 template <
typename Procedure>
 
  174     : 
public internal::args_specs<internal::arg_specs_tuple_for_t<Procedure>> {
 
  176     using base = internal::args_specs<internal::arg_specs_tuple_for_t<Procedure>>;
 
Procedure arguments specifications.
Definition: args_specs.h:174
 
Class completion_handler.
 
The packio namespace.
Definition: arg.h:14
 
constexpr auto allow_extra_arguments
Option to allo extra arguments, ignoring them.
Definition: args_specs.h:181
 
Options available for the argument specifications.
Definition: args_specs.h:102