-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArgParser.h
48 lines (40 loc) · 1.07 KB
/
ArgParser.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
/*
Header file for ArgParser project.
24/10/2020, Jack Shendrikov
*/
#include <vector>
#include <memory>
#include <string>
#include <map>
using namespace std;
struct Argument {
Argument() : hasValue(false), parsed(false) {}
string short_arg;
string long_arg;
string description;
bool hasValue;
string value;
bool parsed;
};
class ArgParser {
vector<unique_ptr<Argument>> args;
map<string, Argument*> argNames;
bool parsed = false;
int flagCounter = 0;
string execName;
string description;
string usage;
vector<string> textArguments;
public:
void setArgument(string short_arg, string long_arg, string descr, bool hasVal);
void setArguments(vector<Argument> args);
bool parseArguments(int argc, char** argv);
bool getFlag(string arg_flag, string& arg_value);
bool exists(string arg_flag);
bool getTextArgument(uint32_t index, string& value);
void printHelp();
void setDescription(string descr) { this->description = descr; }
void setUsage(string use) { this->usage = use; }
int flagCount() { return flagCounter; }
string executableName() { return execName; }
};