-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParamaters.cpp
More file actions
33 lines (25 loc) · 874 Bytes
/
Paramaters.cpp
File metadata and controls
33 lines (25 loc) · 874 Bytes
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
#include "Parameters.h"
namespace RobotParams {
toml::table parameters;
// Save parameter file location.
std::string param_file =
frc::filesystem::GetDeployDirectory() + "/parameters.toml";
bool LoadParameters(const std::string &path) {
// Load the parameters from a file.
try {
parameters = toml::parse_file(path.c_str());
} catch (const toml::parse_error &err) {
std::cerr << "Parsing failed:\n" << err << "\n";
return false;
}
return true;
}
bool SaveParameters(const std::string &path) {
// Output the parameters table to the file.
std::ofstream file;
file.open(path, std::ofstream::out | std::ofstream::trunc);
file << parameters << std::flush;
file.close();
return true;
}
} // namespace RobotParams