forked from JonathanMeans/EvilC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArgumentParser.h
42 lines (36 loc) · 925 Bytes
/
ArgumentParser.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
#ifndef EVILC_ARGUMENT_PARSER_H
#define EVILC_ARGUMENT_PARSER_H
#include <exception>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
class ArgumentParser
{
struct Option
{
std::string name;
bool takesArgument;
};
public:
class ParseError : public std::runtime_error
{
public:
ParseError(const char* message);
};
class InvalidOption : public std::runtime_error
{
public:
InvalidOption(const char* message);
};
explicit ArgumentParser(const std::string& programName);
void addOption(const std::string& name, bool takesArgument = false);
std::map<std::string, std::string> parse(int argc, char** argv);
private:
std::string mProgramName;
std::vector<Option> mOptions;
std::vector<std::string> mPositionalArguments;
std::map<std::string, std::string> mDefaultResults;
};
#endif