29 template<
typename FloatOperator,
typename IntOperation>
30 string calculation(
const string& left,
const string& right, FloatOperator fop, IntOperation iop)
34 if(Conv<int>(left, &i1) && Conv<int>(right, &i2))
36 int res = iop(i1, i2);
40 }
else if(Conv<float>(left, &f1) && Conv<float>(right, &f2))
42 float res = fop(f1, f2);
58 , operation(operation)
67 string first =
left->eval(obj);
68 string second =
right->eval(obj);
81 if( Conv<int>(first, &i1)
82 && Conv<int>(second, &i2)
97 if( Conv<int>(first, &i1)
98 && Conv<int>(second, &i2))
119 if( Conv<float>(first, &f1)
120 && Conv<float>(second, &f2))
134 if( Conv<float>(first, &f1)
135 && Conv<float>(second, &f2))
148 if( Conv<float>(first, &f1)
149 && Conv<float>(second, &f2))
162 if( Conv<float>(first, &f1)
163 && Conv<float>(second, &f2))
194 [](
float f1,
float f2)
209 [](
float f1,
float f2)
223 [](
float f1,
float f2)
237 if(Conv<int>(second, &i) && i == 0)
242 [](
float f1,
float f2)
256 return first + second;
260 assert(!
"Invalid operation executed!");
virtual string eval(GeoObject *obj) const
Evaluates a subtree under this node.
BinaryOperationEnum
Enumeration for all binary operations.
string calculation(const string &left, const string &right, FloatOperator fop, IntOperation iop)
node_ptr left
The left expression of the operator.
op::BinaryOperationEnum operation
The type of the operation.
This file is part of alaCarte.
base_type::node_ptr node_ptr
node_ptr right
The right expression of the operator.
string ToString(const bool &v)
BinaryOperationNode(const node_ptr &left, op::BinaryOperationEnum operation, const node_ptr &right)
Creates a new binary operation.