Plasma Engine  2.0
Loading...
Searching...
No Matches
plMathExpression Class Reference

A wrapper around plExpression infrastructure to evaluate simple math expressions. More...

#include <MathExpression.h>

Classes

struct  Input
 

Public Member Functions

 plMathExpression ()
 Creates a new invalid math expression.
 
 plMathExpression (plStringView sExpressionString)
 Initializes using a given expression.
 
void Reset (plStringView sExpressionString)
 Reinitializes using the given expression.
 
bool IsValid () const
 Whether the expression is valid and can be evaluated.
 
plStringView GetExpressionString () const
 Returns the original expression string that this MathExpression can evaluate.
 
float Evaluate (plArrayPtr< Input > inputs=plArrayPtr< Input >())
 Evaluates parsed expression with the given inputs.
 

Detailed Description

A wrapper around plExpression infrastructure to evaluate simple math expressions.

Constructor & Destructor Documentation

◆ plMathExpression() [1/2]

plMathExpression::plMathExpression ( )
default

Creates a new invalid math expression.

Need to call Reset before you can do anything with it.

◆ plMathExpression() [2/2]

plMathExpression::plMathExpression ( plStringView sExpressionString)
explicit

Initializes using a given expression.

If anything goes wrong it is logged and the math expression is in an invalid state.

Parameters
logIf null, default log interface will be used.

Member Function Documentation

◆ Evaluate()

float plMathExpression::Evaluate ( plArrayPtr< Input > inputs = plArrayPtr<Input>())

Evaluates parsed expression with the given inputs.

Only way this function can fail is if the expression was not valid.

See also
IsValid

◆ Reset()

void plMathExpression::Reset ( plStringView sExpressionString)

Reinitializes using the given expression.

An empty string or nullptr are considered to be 'invalid' expressions.


The documentation for this class was generated from the following files: