A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Option.cc
1#include "Option.hh"
2
3#include <cstring>
4
5namespace Host::Option {
6
7std::optional<EOption> CheckFlag(const char *arg) {
8 ASSERT(arg);
9 if (arg[0] != '-') {
10 return std::nullopt;
11 }
12
13 // Verbose flag
14 if (arg[1] == '-') {
15 const char *verbose_arg = &arg[2];
16
17 if (strcmp(verbose_arg, "suite") == 0) {
18 return EOption::Suite;
19 }
20
21 if (strcmp(verbose_arg, "ghost") == 0) {
22 return EOption::Ghost;
23 }
24
25 if (strcmp(verbose_arg, "krkg") == 0) {
26 return EOption::KRKG;
27 }
28
29 if (strcmp(verbose_arg, "framecount") == 0) {
30 return EOption::TargetFrame;
31 }
32
33 return EOption::Invalid;
34 } else {
35 switch (arg[1]) {
36 case 'S':
37 case 's':
38 return EOption::Suite;
39 case 'G':
40 case 'g':
41 return EOption::Ghost;
42 case 'K':
43 case 'k':
44 return EOption::KRKG;
45 case 'F':
46 case 'f':
47 return EOption::TargetFrame;
48 default:
49 return EOption::Invalid;
50 }
51 }
52
53 // This is unreachable
54 return std::nullopt;
55}
56
57} // namespace Host::Option