-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
executable file
·73 lines (64 loc) · 1.84 KB
/
config.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
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef CONFIG
#define CONFIG
namespace config {
string input, test;
bool found_input = false;
string output;
bool found_output = false;
double time_limit = 300.0;
bool found_time_limit = false;
int max_iter = 50;
bool found_max_iter = false;
void parse_arguments(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
string key = argv[i];
if (key == "--input") {
string value = argv[++i];
input = value;
found_input = true;
}
else
if (key == "--output") {
string value = argv[++i];
output = value;
found_output = true;
}
else
if (key == "--time-limit") {
string value = argv[++i];
time_limit = stof(value);
found_time_limit = true;
}
else
if (key == "--max-iter") {
string value = argv[++i];
max_iter = stoi(value);
found_max_iter = true;
}
else {
cerr << "Invalid argument !!!";
exit(0);
}
}
if (!found_input) {
cerr << "Input is required !!!\n";
exit(0);
}
if (!found_output) {
cerr << "Warning: Output is missing !!!!\n";
}
if (!found_time_limit) {
cerr << "Warning: time_limit default = 300.0s\n";
}
if (!found_max_iter) {
cerr << "Warning: max_iter default = 50\n";
}
/// test
for (int i = (int) input.length()-1; i >= 0; --i) {
if (input[i] == '/') break;
test += input[i];
}
reverse(test.begin(), test.end());
}
}
#endif // CONFIG