2
0
Fork 0
OB-Xd/Modules/gin/utilities/equationparser.h
2020-05-21 09:14:57 +02:00

52 lines
1.5 KiB
C++
Executable file

/*==============================================================================
Copyright 2018 by Roland Rabien
For more information visit www.rabiensoftware.com
==============================================================================*/
#pragma once
class EquationParser
{
public:
EquationParser();
EquationParser (juce::String equation);
~EquationParser();
void setEquation (juce::String equation);
void addVariable (juce::String name, double* value);
void addConstant (juce::String name, double value);
void addFunction (juce::String name, std::function<double (int id)> fun);
void addFunction (juce::String name, std::function<double (int id, double)> fun);
void addFunction (juce::String name, std::function<double (int id, double, double)> fun);
void addFunction (juce::String name, std::function<double (int id, double, double, double)> fun);
void addFunction (juce::String name, std::function<double (int id, double, double, double, double)> fun);
double evaluate();
bool hasError();
juce::String getError();
private:
class Callback
{
public:
virtual ~Callback() = default;
};
class Callback0;
class Callback1;
class Callback2;
class Callback3;
class Callback4;
OwnedArray<Callback> callbacks;
class EquationParserImpl;
std::unique_ptr<EquationParserImpl> impl;
juce::String errorMessage;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EquationParser)
};