54 #include <QStaticStringData>
55 #include <QStringData>
56 #include <QStringDataPtr>
57 #include <QStringList>
59 #include "../vmisc/def.h"
60 #include "../qmuparser/qmuparsererror.h"
62 #include <QSharedPointer>
115 if (tokens.isEmpty())
122 if (tokens.isEmpty())
146 while (i != tokens.constEnd())
149 if (vars->contains(i.value()))
151 DefineVar(i.value(), vars->value(i.value())->GetValue());
qreal EvalFormula(const QHash< QString, QSharedPointer< VInternalVariable > > *vars, const QString &formula)
eval calculate formula.
void InitVariables(const QHash< QString, QSharedPointer< VInternalVariable > > *vars, const QMap< int, QString > &tokens, const QString &formula)
Calculator::InitVariables add variables to parser.
Calculator()
Calculator class wraper for QMuParser. Make easy initialization math parser.
void setAllowSubexpressions(bool value)
QMap< int, QString > GetTokens() const
void DefineVar(const QString &a_sName, qreal *a_pVar)
Add a user defined variable.
void SetExpr(const QString &a_sExpr)
Set the formula.
void SetVarFactory(facfun_type a_pFactory, void *pUserData=nullptr)
Set a function that can create variable pointer for unknown expression variables.
qreal Eval() const
Calculate the result.
Error class of the parser.
const QStringList builInFunctions
@ ecUNASSIGNABLE_TOKEN
Token cant be identified.