Mathematical equation parser and evaluator with variable and function support.
More...
|
| | EquationParser () |
| |
| | EquationParser (const juce::String &equation) |
| |
| | ~EquationParser () |
| |
| void | defineNameChars (const juce::String &chars) |
| |
| void | setEquation (const juce::String &equation) |
| |
| void | clearVariables () |
| |
| void | addVariable (const juce::String &name, double *value) |
| |
| void | setVarFactory (std::function< double *(const char *)> fun) |
| |
| juce::StringArray | getUsedVariables () |
| |
| void | clearConstants () |
| |
| void | addConstant (const juce::String &name, double value) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id, const juce::String &)> fun) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id)> fun) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id, double)> fun) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id, double, double)> fun) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id, double, double, double)> fun) |
| |
| void | addFunction (const juce::String &name, std::function< double(int id, double, double, double, double)> fun) |
| |
| double | evaluate () |
| |
| bool | hasError () const |
| |
| juce::String | getError () const |
| |
Mathematical equation parser and evaluator with variable and function support.
EquationParser provides a flexible system for parsing and evaluating mathematical expressions at runtime. It supports variables, constants, custom functions, and standard mathematical operations. Built on top of muParser library.
Key Features:
- Parse and evaluate mathematical expressions
- Dynamic variable binding (pointers to live values)
- Named constants
- Custom functions with 0-4 parameters or string parameters
- Variable factory for on-demand variable creation
- Comprehensive error handling
- Query which variables are used in an equation
Supported Operations:
- Basic arithmetic: +, -, *, /, ^
- Parentheses for grouping
- Standard math functions (via custom function registration)
- User-defined functions and variables
Usage:
double x = 5.0;
x = 10.0;
Mathematical equation parser and evaluator with variable and function support.
Definition gin_equationparser.h:74
void addVariable(const juce::String &name, double *value)
juce::String getError() const
void setEquation(const juce::String &equation)
void addConstant(const juce::String &name, double value)
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
Custom Functions:
parser.
addFunction(
"myFunc", [](
int id,
double a,
double b) {
return a * a + b;
});
void addFunction(const juce::String &name, std::function< double(int id, const juce::String &)> fun)
- See also
- muParser documentation for expression syntax details