Plasma Engine  2.0
Loading...
Searching...
No Matches
MathExpression.h
1#pragma once
2
3#include <Foundation/CodeUtils/Expression/ExpressionByteCode.h>
4#include <Foundation/CodeUtils/Expression/ExpressionVM.h>
5#include <Foundation/Strings/String.h>
6
8
10class PL_FOUNDATION_DLL plMathExpression
11{
12public:
17
23 explicit plMathExpression(plStringView sExpressionString); // [tested]
24
28 void Reset(plStringView sExpressionString);
29
31 bool IsValid() const { return m_bIsValid; }
32
34 plStringView GetExpressionString() const { return m_sOriginalExpression; }
35
36 struct Input
37 {
38 plHashedString m_sName;
39 float m_fValue;
40 };
41
46 float Evaluate(plArrayPtr<Input> inputs = plArrayPtr<Input>()); // [tested]
47
48private:
49 plHashedString m_sOriginalExpression;
50 bool m_bIsValid = false;
51
52 plExpressionByteCode m_ByteCode;
53 plExpressionVM m_VM;
54};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition ExpressionByteCode.h:10
Definition ExpressionVM.h:7
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
Base class for all logging classes.
Definition Log.h:77
A wrapper around plExpression infrastructure to evaluate simple math expressions.
Definition MathExpression.h:11
plMathExpression()
Creates a new invalid math expression.
plStringView GetExpressionString() const
Returns the original expression string that this MathExpression can evaluate.
Definition MathExpression.h:34
bool IsValid() const
Whether the expression is valid and can be evaluated.
Definition MathExpression.h:31
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Definition MathExpression.h:37