WarpX
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
QedTablesUtils
Source
ArgParser
QedTablesArgParser.H
Go to the documentation of this file.
1
#ifndef QED_TABLES_ARG_PARSER_
2
#define QED_TABLES_ARG_PARSER_
3
4
#include <optional>
5
#include <string>
6
#include <tuple>
7
#include <unordered_map>
8
#include <utility>
9
#include <variant>
10
#include <vector>
11
12
namespace
ArgParser
13
{
14
/* Possible types of parameters of command line arguments (no argument, int, double, or std::string) */
15
enum class
ArgType
{
NoArg
,
Integer
,
Double
,
String
};
16
17
/* This type represents the type of a command line argument: if it exists it is either an int, a double, or a std::string */
18
using
ArgVal
= std::optional<std::variant<int, double, std::string>>;
19
20
/* The type of a possible command line argument */
21
using
Key
= std::tuple<std::string, ArgType, std::string>;
22
23
/* The type of the map of the parsed command line arguments */
24
using
ParsedArgs
= std::unordered_map<std::string, ArgVal>;
25
33
template
<
typename
T>
34
T
GetVal
(
const
ArgVal
& arg_val)
35
{
36
return
std::get<T>(*arg_val);
37
}
38
47
ParsedArgs
ParseArgs
(
const
std::vector<Key>& keys,
const
int
argc,
char
const
*
const
* argv);
48
54
void
PrintHelp
(
const
std::vector<Key>& cmd_list);
55
};
56
57
58
#endif
//QED_TABLES_ARG_PARSER_
ArgParser
Definition
QedTablesArgParser.H:13
ArgParser::GetVal
T GetVal(const ArgVal &arg_val)
Gets the value out of an ArgVal (std::optional<std::variant<int, double, std::string>>) object.
Definition
QedTablesArgParser.H:34
ArgParser::PrintHelp
void PrintHelp(const std::vector< Key > &cmd_list)
Prints the command line options.
Definition
QedTablesArgParser.cpp:86
ArgParser::ParsedArgs
std::unordered_map< std::string, ArgVal > ParsedArgs
Definition
QedTablesArgParser.H:24
ArgParser::Key
std::tuple< std::string, ArgType, std::string > Key
Definition
QedTablesArgParser.H:21
ArgParser::ArgVal
std::optional< std::variant< int, double, std::string > > ArgVal
Definition
QedTablesArgParser.H:18
ArgParser::ParseArgs
ParsedArgs ParseArgs(const std::vector< Key > &keys, const int argc, char const *const *argv)
Function to parse the command line arguments.
Definition
QedTablesArgParser.cpp:62
ArgParser::ArgType
ArgType
Definition
QedTablesArgParser.H:15
ArgParser::ArgType::NoArg
@ NoArg
Definition
QedTablesArgParser.H:15
ArgParser::ArgType::String
@ String
Definition
QedTablesArgParser.H:15
ArgParser::ArgType::Integer
@ Integer
Definition
QedTablesArgParser.H:15
ArgParser::ArgType::Double
@ Double
Definition
QedTablesArgParser.H:15
Generated by
1.17.0