#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;
        const uint8_t _result;
        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;
        }

        [[nodiscard]] uint8_t GetResult() const{
            return _result;
        }

        [[nodiscard]] const char * GetError() const{
            return _errorMessage;
        }
    };
}

#endif //PORYGONLANG_EVALUATERESULT_HPP
