6 #ifndef vmec_test_commandline_parser_hpp
7 #define vmec_test_commandline_parser_hpp
17 typedef std::map<std::string, std::string>
arg_map;
29 const std::function<void(
void)>
help;
41 const std::function<
void(
void)>
help) {
48 for (
size_t i = 1; i < argc; i++) {
49 std::string arg(argv[i]);
54 size_t eqpos = arg.find(
'=');
55 if (eqpos != std::string::npos) {
56 std::string key = arg.substr(0, eqpos);
57 std::string value = arg.substr(eqpos + 1, std::string::npos);
79 const std::function<
void(
void)>
help) :
88 bool is_set(
const std::string &key)
const {
98 template<
typename TYPE>
99 TYPE
get(
const std::string &key)
const {
104 std::stringstream value_stream(
commands.at(key));
106 value_stream >> temp;
commandline_parser(const size_t argc, const char *argv[], const std::function< void(void)> help)
Construct a commandline_parser object by pasring command line arguments.
Definition: vmec_test_commandline_parser.hpp:77
TYPE get(const std::string &key) const
Get the value of the agument.
Definition: vmec_test_commandline_parser.hpp:99
static arg_map parse_commands(const size_t argc, const char *argv[], const std::function< void(void)> help)
Factory method to parse the commandline and produce the arguments.
Definition: vmec_test_commandline_parser.hpp:39
const std::function< void(void)> help
Help callback function.
Definition: vmec_test_commandline_parser.hpp:29
bool is_set(const std::string &key) const
Check if command arg was set.
Definition: vmec_test_commandline_parser.hpp:88
const arg_map commands
Parsed commands.
Definition: vmec_test_commandline_parser.hpp:27
std::pair< std::string, std::string > arg_element
Type for a key value pair.
Definition: commandline_parser.hpp:84
std::map< std::string, std::string > arg_map
Type for the argument map.
Definition: commandline_parser.hpp:82
Defines the base class of the type commandline_parser_class.
Definition: commandline_parser.f:65
std::map< std::string, std::string > arg_map
Type for the argument map.
Definition: vmec_test_commandline_parser.hpp:17