#include #include "argparse_util.hpp" namespace argparse { template std::shared_ptr make_singlevalue_argument(ArgValue& dest, std::string long_opt, std::string short_opt) { auto ptr = std::make_shared>(dest, long_opt, short_opt); //If the conversion object specifies a non-empty set of choices //use those by default auto default_choices = Converter().default_choices(); if (!default_choices.empty()) { ptr->choices(default_choices); } return ptr; } template std::shared_ptr make_multivalue_argument(ArgValue& dest, std::string long_opt, std::string short_opt) { auto ptr = std::make_shared>(dest, long_opt, short_opt); //If the conversion object specifies a non-empty set of choices //use those by default auto default_choices = Converter().default_choices(); if (!default_choices.empty()) { ptr->choices(default_choices); } return ptr; } /* * ArgumentParser */ template Argument& ArgumentParser::add_argument(ArgValue& dest, std::string option) { return add_argument(dest, option, std::string()); } template Argument& ArgumentParser::add_argument(ArgValue& dest, std::string long_opt, std::string short_opt) { return argument_groups_[0].add_argument(dest, long_opt, short_opt); } template Argument& ArgumentParser::add_argument(ArgValue>& dest, std::string option) { return add_argument(dest, option, std::string()); } template Argument& ArgumentParser::add_argument(ArgValue>& dest, std::string long_opt, std::string short_opt) { return argument_groups_[0].add_argument(dest, long_opt, short_opt); } /* * ArgumentGroup */ template Argument& ArgumentGroup::add_argument(ArgValue& dest, std::string option) { return add_argument(dest, option, std::string()); } template Argument& ArgumentGroup::add_argument(ArgValue& dest, std::string long_opt, std::string short_opt) { arguments_.push_back(make_singlevalue_argument(dest, long_opt, short_opt)); auto& arg = arguments_[arguments_.size() - 1]; arg->group_name(name()); //Tag the option with the group return *arg; } template Argument& ArgumentGroup::add_argument(ArgValue>& dest, std::string option) { return add_argument(dest, option, std::string()); } template Argument& ArgumentGroup::add_argument(ArgValue>& dest, std::string long_opt, std::string short_opt) { arguments_.push_back(make_multivalue_argument,Converter>(dest, long_opt, short_opt)); auto& arg = arguments_[arguments_.size() - 1]; arg->group_name(name()); //Tag the option with the group return *arg; } } //namespace