-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgs.h
More file actions
61 lines (48 loc) · 1.27 KB
/
Args.h
File metadata and controls
61 lines (48 loc) · 1.27 KB
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
61
#ifndef _ARGS_H_
#define _ARGS_H_
#include <vector>
typedef struct ParseOpt {
const char *optStr;
int flags;
void *target;
char shortOpt;
} parseopt_t;
typedef struct Option {
char *option;
char *valStr;
int optType;
int flags;
} option_t;
class Args {
private:
std::vector<option_t *> options;
char *longName;
char *shortName;
protected:
public:
enum argType {short_switch, long_switch, argument};
enum flags {inverted=1};
enum optionFlags {requires_argument=1, optional_argument=2, boolean_argument=4, numeric_argument=8};
private:
const char *getFlagStr(option_t *opt);
int argIndex(const char *arg, int argType);
int argIndex(const char *arg);
int argIndex(const char shortArg);
void pairShortArg(char argCh, bool required);
void pairShortArgs(const char *shortArgStr);
void associateShortArgs(parseopt_t *opts);
void processArgs(parseopt_t *opts);
protected:
public:
Args(int argc, char **argv);
void dump();
void parseArgs(parseopt_t *mandatory, parseopt_t *optional, bool fussy);
int getArgC();
int getArgC(int argType);
option_t *getArg(int argNum);
option_t *getArg(int argNum, int argType);
bool hasArg(const char *arg, int argType);
bool hasArg(const char *arg);
bool hasArg(const char shortArg);
};
#endif