// // Created by erki on 28.02.21. // #include "OperationStorage.hpp" #include #include #include OperationStorage::OperationStorage(const std::string& output_filename) : _output_filename(output_filename) { } OperationStorage::~OperationStorage() { _dumpToFile(); } void OperationStorage::pushOperation(const std::string& filename, const OperationLog& op) { auto it = _operations.find(filename); if (it == _operations.end()) it = _operations.insert({ filename, {} }).first; it->second.push_back(op); } const std::unordered_map>& OperationStorage::getOperations() const { return _operations; } void OperationStorage::_dumpToFile() { nlohmann::json json = _operations; std::ofstream file(_output_filename); file << json; }