45 lines
707 B
C++
45 lines
707 B
C++
//
|
|
// Created by erki on 06.03.21.
|
|
//
|
|
|
|
#include "OperationLog.hpp"
|
|
|
|
namespace
|
|
{
|
|
|
|
template<typename T>
|
|
std::unique_ptr<T> DecodeType(const nlohmann::json& j, const std::string& entry_type)
|
|
{
|
|
if (entry_type == T::TYPE_NAME)
|
|
{
|
|
auto t = std::make_unique<T>();
|
|
j.get_to(*t);
|
|
|
|
return t;
|
|
}
|
|
else
|
|
{
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
nlohmann::json OperationLog::FunctionCall::toJson() const
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
nlohmann::json OperationLog::BasicOperation::toJson() const
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
void OperationLog::DecodeEntry(const nlohmann::json& j)
|
|
{
|
|
if ((entry = DecodeType<BasicOperation>(j, entry_type)))
|
|
return;
|
|
else if ((entry = DecodeType<FunctionCall>(j, entry_type)))
|
|
return;
|
|
}
|