|
- #pragma once
-
- #include <cpputils/mp.h>
- #include <cppargs/parser/parser.h>
- #include <cppargs/group/simple_group.inl>
-
- namespace cppargs
- {
-
- template<typename... T_args>
- simple_parser::simple_parser(
- option_ptr_type&& p_default,
- T_args&&... args)
- : base_type (std::move(p_default), _group)
- , _group ({ }, std::forward<T_args>(args)...)
- { update_map(); }
-
- void simple_parser::parse(int argc, char const * argv[]) const
- { parser::parse(argc, argv); }
-
- template<typename... T_args>
- constexpr decltype(auto) simple_parser::make_group(const group_meta& meta, T_args&&... args)
- {
- return std::make_unique<simple_group>(meta, std::forward<T_args>(args)...);
- }
-
- template<typename T_predicate>
- constexpr decltype(auto) simple_parser::make_predicate_option(const option_meta& meta, T_predicate&& predicate)
- {
- using predicate_type = T_predicate;
- using simple_predicate_option_type = simple_predicate_option<predicate_type>;
- return std::make_unique<simple_predicate_option_type>(meta, std::forward<predicate_type>(predicate));
- }
-
- template<typename T_value>
- constexpr decltype(auto) simple_parser::make_reference_option(const option_meta& meta, T_value& value)
- {
- using value_type = T_value;
-
- auto predicate = [&value](context& c)
- {
- using executor_type = option_parser<value_type>;
- executor_type { c, value } ( );
- };
-
- using predicate_type = decltype(predicate);
- using simple_predicate_option_type = simple_predicate_option<predicate_type>;
- return std::make_unique<simple_predicate_option_type>(
- option_meta::prepare_arguments<T_value>(meta),
- std::move(predicate));
- }
-
- }
|