masters-thesis/op-finder/OperationLog.hpp

56 lines
1.3 KiB
C++

//
// Created by erki on 28.02.21.
//
#ifndef C_ANALYZER_OPERATIONLOG_HPP
#define C_ANALYZER_OPERATIONLOG_HPP
#include <vector>
struct OperationLog
{
std::string operation;
unsigned int line;
std::string operand_lhs;
std::string operand_rhs;
std::string operand_result;
bool is_fallthrough;
std::vector<int> current_for_loops;
};
class IOperationOutput
{
public:
virtual ~IOperationOutput() = default;
virtual void pushOperation(const std::string& filename, const OperationLog& op) = 0;
};
#include <nlohmann/json.hpp>
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},
{"is_fallthrough", l.is_fallthrough},
{"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("is_fallthrough").get_to(l.is_fallthrough);
j.at("current_for_loops").get_to(l.current_for_loops);
}
#endif //C_ANALYZER_OPERATIONLOG_HPP