-
Notifications
You must be signed in to change notification settings - Fork 0
/
argsparser_iface.h
60 lines (52 loc) · 2.56 KB
/
argsparser_iface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) 2018-2024 Alexey V. Medvedev
* This code is an extension of the parts of Intel(R) MPI Benchmarks project.
* It keeps the same 3-Clause BSD License.
*/
#pragma once
#include <string>
#include <vector>
#include <iostream>
#include <memory>
namespace parser_iface {
struct parser
{
enum { MAX_VEC_SIZE = 1024 };
void *ptr;
parser();
parser(int argc, char **argv);
~parser();
bool parse();
void add_bool(const std::string &s);
bool get_bool(const std::string &s);
bool get_flag(const std::string &s);
void add_string(const std::string &s);
std::string get_string(const std::string &s);
void add_int(const std::string &s);
int get_int(const std::string &s);
void add_float(const std::string &s);
float get_float(const std::string &s);
void add_bool(const std::string &s, bool v);
void add_string(const std::string &s, std::string v);
void add_int(const std::string &s, int v);
void add_float(const std::string &s, float v);
void add_flag(const std::string &s);
void add_bool_vector(const std::string &s, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
std::vector<bool> get_bool_vector(const std::string &s);
void add_string_vector(const std::string &s, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
std::vector<std::string> get_string_vector(const std::string &s);
void add_int_vector(const std::string &s, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
std::vector<int> get_int_vector(const std::string &s);
void add_float_vector(const std::string &s, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
std::vector<float> get_float_vector(const std::string &s);
void add_bool_vector(const std::string &s, const std::string &def, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
void add_string_vector(const std::string &s, const std::string &def, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
void add_int_vector(const std::string &s, const std::string &def, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
void add_float_vector(const std::string &s, const std::string &def, char delim = ',', int min = 0, int max = MAX_VEC_SIZE);
bool load(std::istream &st);
std::string dump();
bool is_option_defaulted(const std::string &s);
};
std::shared_ptr<parser> parser_create();
std::shared_ptr<parser> parser_create(int argc, char **argv);
}