-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdline.h
41 lines (33 loc) · 862 Bytes
/
cmdline.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
#ifndef CMDLINE_H
#define CMDLINE_H
#include "string_view.h"
#include <map>
#include <vector>
struct cmdline_entry
{
int id;
char short_name;
string_view long_name;
string_view def;
int arg_count;
int subparser;
string_view desc;
};
class cmdline
{
public:
cmdline(cmdline_entry const * entry_first, cmdline_entry const * entry_last, int argc, char const * const argv[]);
size_t has_arg(int id) const;
std::string pop_string(int id);
bool pop_string(int id, std::string & res);
std::string pop_string(int id, string_view def);
bool pop_switch(int id);
void set_subparser(int subparser_id);
std::vector<std::string> const & args() const;
private:
cmdline_entry const * m_entry_first;
cmdline_entry const * m_entry_last;
std::map<int, std::vector<std::string> > m_opts;
std::vector<std::string> m_additional_opts;
};
#endif // CMDLINE_H