54 std::shared_ptr<MathNode>
left =
nullptr;
56 std::shared_ptr<MathNode>
right =
nullptr;
70 auto realValue =
strip(val);
71 isNegative = realValue.find(
'-') != std::string::npos && realValue.size() > 1;
72 value =
new char[realValue.size() + 1];
73 std::copy(realValue.begin(), realValue.end(),
value);
74 value[realValue.size()] =
'\0';
98 [[nodiscard]]
virtual double Evaluate()
const = 0;
105 std::stringstream out;
128 if(other.
left !=
nullptr) ostr << other.
left;
130 if(other.
right !=
nullptr) ostr << other.
right;
142 if(other ==
nullptr)
return ostr;
145 if(other->
left !=
nullptr) ostr << other->
left;
147 if(other->
right !=
nullptr) ostr << other->
right;
std::regex GetRegex(MathNodeType type)
NodeConnectionType
Definition: MathNode.h:23
@ ConnectionType_Right
Definition: MathNode.h:26
@ ConnectionType_Dual
Definition: MathNode.h:24
@ ConnectionType_None
Definition: MathNode.h:27
@ ConnectionType_Unknown
Definition: MathNode.h:28
@ ConnectionType_Left
Definition: MathNode.h:25
MathNodeType
Definition: MathNode.h:12
@ NodeType_Operator
Definition: MathNode.h:13
@ NodeType_Symbolic
Definition: MathNode.h:14
@ NodeType_Any
Definition: MathNode.h:19
@ NodeType_Functional
Definition: MathNode.h:17
@ NodeType_DefaultSymbol
Definition: MathNode.h:18
@ NodeType_Operator_or_Parentheses
Definition: MathNode.h:20
@ NodeType_Parentheses
Definition: MathNode.h:16
@ NodeType_Numeric
Definition: MathNode.h:15
Definition: MathNode.h:43
MathNode(const MathNode &other)
Definition: MathNode.h:82
friend std::ostream & operator<<(std::ostream &ostr, const MathNode &other)
Definition: MathNode.h:126
bool isNegative
helper to determine whether a node is negated or not
Definition: MathNode.h:46
char * value
char representation of value
Definition: MathNode.h:58
MathNode(const std::string &val)
Definition: MathNode.h:69
size_t valSize
helper to store size of value
Definition: MathNode.h:62
friend std::ostream & operator<<(std::ostream &ostr, MathNode *other)
Definition: MathNode.h:140
friend bool operator==(const MathNode &lhs, const MathNode &rhs)
Definition: MathNode.h:114
std::shared_ptr< MathNode > left
next node on left side
Definition: MathNode.h:54
bool operator==(MathNode *rhs)
Definition: MathNode.h:118
bool hasParentheses
helper to determine if node is within parentheses
Definition: MathNode.h:48
MathNodeType type
node type representation
Definition: MathNode.h:50
std::string GetString() const
Definition: MathNode.h:104
virtual double Evaluate() const =0
std::shared_ptr< MathNode > right
next node on right side
Definition: MathNode.h:56
NodeConnectionType connectionType
type of connection allowed for this node
Definition: MathNode.h:52