Better handling of creating EvalValues in UserData templates
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
60
src/Evaluator/EvalValues/EvalValueHelper.hpp
Normal file
60
src/Evaluator/EvalValues/EvalValueHelper.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <utility>
|
||||
|
||||
#ifndef PORYGONLANG_EVALVALUEHELPER_HPP
|
||||
#define PORYGONLANG_EVALVALUEHELPER_HPP
|
||||
|
||||
#include "EvalValue.hpp"
|
||||
#include "NumericEvalValue.hpp"
|
||||
#include "StringEvalValue.hpp"
|
||||
|
||||
namespace Porygon::Evaluation{
|
||||
class EvalValueHelper{
|
||||
public:
|
||||
static EvalValue* Create(unsigned char i){
|
||||
return new IntegerEvalValue((long)i);
|
||||
}
|
||||
static EvalValue* Create(signed char i){
|
||||
return new IntegerEvalValue((long)i);
|
||||
}
|
||||
static EvalValue* Create(short int i){
|
||||
return new IntegerEvalValue(i);
|
||||
}
|
||||
static EvalValue* Create(unsigned short int i){
|
||||
return new IntegerEvalValue(i);
|
||||
}
|
||||
static EvalValue* Create(signed int i){
|
||||
return new IntegerEvalValue(i);
|
||||
}
|
||||
static EvalValue* Create(unsigned int i){
|
||||
return new IntegerEvalValue(i);
|
||||
}
|
||||
static EvalValue* Create(signed long l){
|
||||
return new IntegerEvalValue(l);
|
||||
}
|
||||
static EvalValue* Create(unsigned long l){
|
||||
return new IntegerEvalValue(l);
|
||||
}
|
||||
|
||||
static EvalValue* Create(float f){
|
||||
return new FloatEvalValue(f);
|
||||
}
|
||||
static EvalValue* Create(double f){
|
||||
return new FloatEvalValue(f);
|
||||
}
|
||||
static EvalValue* Create(long double f){
|
||||
return new FloatEvalValue(f);
|
||||
}
|
||||
|
||||
static EvalValue* Create(bool b){
|
||||
return new BooleanEvalValue(b);
|
||||
}
|
||||
static EvalValue* Create(const string& s){
|
||||
return new StringEvalValue(Utilities::StringUtils::StringToU16String(s));
|
||||
}
|
||||
static EvalValue* Create(u16string s){
|
||||
return new StringEvalValue(std::move(s));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_EVALVALUEHELPER_HPP
|
||||
Reference in New Issue
Block a user