-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgumentParser.cpp
More file actions
40 lines (36 loc) · 1.38 KB
/
Copy pathArgumentParser.cpp
File metadata and controls
40 lines (36 loc) · 1.38 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
#include "ArgumentParser.h"
#include <cstdlib> // for std::atoi, std::atof
#include <iostream>
ProgramOptions parseArguments(int argc, char *argv[]) {
ProgramOptions options;
// 初始化默认值
options.seed = -1;
options.q_MBHB = -1.0;
options.Mp = -1.0;
options.Ms = -1.0;
options.a_CM = -1.0;
options.a_b = -1.0;
options.I_CM = -1.0;
options.tau = -1.0;
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg.find("--seed=") == 0) {
options.seed = std::atoi(arg.substr(7).c_str());
} else if (arg.find("--M_IMBH=") == 0) {
options.q_MBHB = std::atof(arg.substr(9).c_str());
} else if (arg.find("--Mp=") == 0) {
options.Mp = std::atof(arg.substr(5).c_str());
} else if (arg.find("--Ms=") == 0) {
options.Ms = std::atof(arg.substr(5).c_str());
} else if (arg.find("--a_CM=") == 0) {
options.a_CM = std::atof(arg.substr(7).c_str());
} else if (arg.find("--a_b=") == 0) {
options.a_b = std::atof(arg.substr(5).c_str());
} else if (arg.find("--I_CM=") == 0) {
options.I_CM = std::atof(arg.substr(7).c_str());
} else if (arg.find("--tau=") == 0) {
options.tau = std::atof(arg.substr(6).c_str());
}
}
return options;
}