AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions
Aqua::Tokenizer Class Reference

Tool to evaluate math expressions. More...

#include <Tokenizer/Tokenizer.h>

Public Member Functions

 Tokenizer ()
 Constructor.
 
 ~Tokenizer ()
 Destructor.
 
bool registerVariable (const std::string name, float value)
 Register a variable.
 
void clearVariables ()
 Clear/unregister all the registered variables.
 
bool isVariable (const std::string name)
 Checks if a variable has been registered.
 
float variable (const std::string name)
 Returns a variable value.
 
float solve (const std::string eq)
 Solve a math expression.
 

Protected Member Functions

virtual void defaultVariables ()
 Register the default variables.
 

Detailed Description

Tool to evaluate math expressions.

This tool is based in libmatheval, to learn more please visit the following web page:

http://www.gnu.org/software/libmatheval

Constructor & Destructor Documentation

◆ Tokenizer()

Aqua::Tokenizer::Tokenizer ( )

Constructor.

Here is the call graph for this function:

◆ ~Tokenizer()

Aqua::Tokenizer::~Tokenizer ( )

Destructor.

Member Function Documentation

◆ clearVariables()

void Aqua::Tokenizer::clearVariables ( )

Clear/unregister all the registered variables.

Here is the call graph for this function:

◆ defaultVariables()

void Aqua::Tokenizer::defaultVariables ( )
protectedvirtual

Register the default variables.

After the libmatheval implementation, variables like \( e \) or \( \pi \) are defined out of the box, but the function is retained just in case.

◆ isVariable()

bool Aqua::Tokenizer::isVariable ( const std::string  name)

Checks if a variable has been registered.

Parameters
nameName of the variable
Returns
true if already exist a variable with the given name, false otherwise.

◆ registerVariable()

bool Aqua::Tokenizer::registerVariable ( const std::string  name,
float  value 
)

Register a variable.

In case that the variable already exist, it will be modified.

The registered variables can be used later in the expression to be evaluated.

Parameters
nameName of the variable.
valueValue of the variable.
Returns
true if the variable already exists, false otherwise.
Here is the call graph for this function:

◆ solve()

float Aqua::Tokenizer::solve ( const std::string  eq)

Solve a math expression.

Parameters
eqMath expression to solve.
Returns
Expression value, 0.0 if the evaluation failed (it will be reported by terminal).

◆ variable()

float Aqua::Tokenizer::variable ( const std::string  name)

Returns a variable value.

Parameters
nameName of the variable
Returns
The Value of the variable, or 0.0 if the variable cannot be found.
Here is the call graph for this function:

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