4#include <boost/endian/conversion.hpp>
8 std::array<uint8_t, 8>
data;
12 const std::vector<Action> &record) {
13 std::ofstream outfile(filename, std::ios::binary);
14 if (!outfile.is_open()) {
15 spdlog::error(
"Could not open file: {}", filename);
18 for (
auto action : record) {
19 boost::endian::native_to_little_inplace(action.time);
20 outfile.write(
reinterpret_cast<char *
>(&action),
sizeof(action));
24 std::vector<Action> res;
25 std::ifstream infile(filename, std::ios::binary);
26 if (!infile.is_open()) {
27 spdlog::error(
"Could not open file: {}", filename);
31 while (infile.readsome(
reinterpret_cast<char *
>(&action),
sizeof(action)) ==
33 boost::endian::little_to_native_inplace(action.
time);
34 res.push_back(action);
void saveActionVector(const std::string &filename, const std::vector< Action > &record)
Definition: Action.h:11
std::vector< Action > loadActionVector(const std::string &filename)
Definition: Action.h:23
std::array< uint8_t, 8 > data
Definition: Action.h:8
uint64_t time
Definition: Action.h:7