// // Created by erki on 28.02.21. // #ifndef C_ANALYZER_OPERATIONLOG_HPP #define C_ANALYZER_OPERATIONLOG_HPP #include struct OperationLog { std::string operation; unsigned int line; std::string operand_lhs; std::string operand_rhs; std::string operand_result; std::vector current_for_loops; }; class IOperationOutput { public: virtual ~IOperationOutput() = default; virtual void pushOperation(const std::string& filename, const OperationLog& op) = 0; }; #include inline void to_json(nlohmann::json& j, const OperationLog& l) { j = nlohmann::json{ {"operation", l.operation}, {"line", l.line}, {"operand_lhs", l.operand_lhs}, {"operand_rhs", l.operand_rhs}, {"operand_result", l.operand_result}, {"current_for_loops", l.current_for_loops} }; } inline void from_json(const nlohmann::json& j, OperationLog& l) { j.at("operation").get_to(l.operation); j.at("line").get_to(l.line); j.at("operand_lhs").get_to(l.operand_lhs); j.at("operand_rhs").get_to(l.operand_rhs); j.at("operand_result").get_to(l.operand_result); j.at("current_for_loops").get_to(l.current_for_loops); } #endif //C_ANALYZER_OPERATIONLOG_HPP