-
Notifications
You must be signed in to change notification settings - Fork 0
/
Args.cpp
60 lines (49 loc) · 1.27 KB
/
Args.cpp
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
#include "Args.h"
#include <string>
#include <string.h>
Args::~Args() {
delete address;
}
void Args::usage(char *msg, int exit_status) {
fprintf(exit_status == 0 ? stdout : stderr, "%s", USAGE_TXT);
if (msg) {
fprintf(exit_status == 0 ? stdout : stderr, "\n%s\n", msg);
}
exit(exit_status);
}
void Args::parse_args(int argc, char **argv) {
int c;
opterr = 0;
if (argc < 2) {
usage(nullptr, 0);
}
while ((c = getopt(argc, argv, "g:t:h:k:p:")) != -1) {
switch (c) {
case 'g': {
printf("%s\n", optarg);
address = strdup(optarg);
break;
}
case 't': {
sscanf(optarg, "%d", &NT);
break;
}
case 'h': {
sscanf(optarg, "%d", &h);
break;
}
case 'k': {
sscanf(optarg, "%d", &topk);
break;
}
case 'p': {
sscanf(optarg, "%d", &p);
}
default:
break;
}
}
std::string data_name(address+10, strlen(address)-14);
sprintf(ds_address, "output/%s-%d.txt", data_name.c_str(), topk);
printf("%s\n", ds_address);
}