forked from HackerPoet/Beryl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdLine.h
More file actions
30 lines (25 loc) · 893 Bytes
/
Copy pathcmdLine.h
File metadata and controls
30 lines (25 loc) · 893 Bytes
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
#pragma once
#include <iostream>
#include <string>
#include <variant>
#include <vector>
class CmdLine {
public:
typedef std::variant<int32_t*, float*, bool*, std::string*> Value;
explicit CmdLine(const std::string& _description) : description(_description) {}
void addArgument(const std::vector<std::string>& flags, const std::string& help, Value value);
void addCategory(const std::string& category);
void printHelp(std::ostream& os = std::cout) const;
bool parse(int argc, const char* argv[]) const;
private:
struct Argument {
Argument(const std::vector<std::string>& _flags, const std::string& _help, Value _value) :
flags(_flags), help(_help), value(_value) {}
std::vector<std::string> flags;
std::string help;
Value value;
};
std::string description;
std::vector<std::pair<int,std::string>> categories;
std::vector<Argument> arguments;
};