2019-07-27 17:45:15 +00:00
|
|
|
#ifndef PORYGONLANG_EVALUATERESULT_HPP
|
|
|
|
#define PORYGONLANG_EVALUATERESULT_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
#include "Evaluator/EvalValues/EvalValue.hpp"
|
|
|
|
|
|
|
|
namespace Porygon{
|
|
|
|
struct EvaluateResult{
|
|
|
|
const Evaluation::EvalValue* _value;
|
2019-08-11 14:05:14 +00:00
|
|
|
const uint8_t _result;
|
2019-07-27 17:45:15 +00:00
|
|
|
char * _errorMessage;
|
|
|
|
const size_t _errorSize;
|
|
|
|
public:
|
|
|
|
explicit EvaluateResult(const Evaluation::EvalValue* value)
|
|
|
|
: _result(0), _value(value), _errorMessage(nullptr), _errorSize(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~EvaluateResult(){
|
|
|
|
delete _value;
|
|
|
|
delete _errorMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit EvaluateResult(const std::string& error)
|
|
|
|
: _result(1), _value(nullptr), _errorSize(error.size())
|
|
|
|
{
|
|
|
|
_errorMessage = new char[error.size()]();
|
|
|
|
std::strcpy(_errorMessage, error.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
EvaluateResult& operator= (EvaluateResult b) = delete;
|
|
|
|
EvaluateResult(const EvaluateResult& b) = delete;
|
|
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] const Evaluation::EvalValue* GetValue() const{
|
|
|
|
return _value;
|
|
|
|
}
|
|
|
|
|
2019-08-11 14:05:14 +00:00
|
|
|
[[nodiscard]] uint8_t GetResult() const{
|
2019-07-27 17:45:15 +00:00
|
|
|
return _result;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] const char * GetError() const{
|
|
|
|
return _errorMessage;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //PORYGONLANG_EVALUATERESULT_HPP
|