ArithmeticEvaluator();
ArithmeticEvaluator(const QString& _expression) throw(int);
+ //getters
+ inline QList<QString> getVariableNames() { return varNames; }
+
+ // setters
void setExpression(const QString& _expression) throw(int);
- inline void setVariablesValue(const QHash<QString,double>& _varValues) { varValues = _varValues; }
+ void setVariablesValue(const QHash<QString,double>& _varValues);
inline void setVariableValue(const QString& var, double value) { varValues.insert(var,value); }
inline void setVariableMarkers(const QString& _markers) { varMarkers = _markers; }
void print();
double evaluate() throw(int);
+ inline QString getError() { return errorMessage; }
protected:
QStringList expression;
+ QList<QString> varNames; // the names of variables that ARE in the expression
QHash<QString,double> varValues;
QString varMarkers; // a sequence of symbols that are allowed to start a variable. $ is by default
QString opMarkers; // a sequence if symbols used as operators. +-*/ is the hard-coded default
bool checkAfterPar(const QString& _expression, int offset);
double evalFunction(int indexFunc, double value);
+
+ void setVariableNames(const QString &_expression);
+
+ QString errorMessage;
};