muParserScript.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef MUPARSER_SCRIPT_H
00031 #define MUPARSER_SCRIPT_H
00032
00033 #include "ScriptingEnv.h"
00034 #include "Script.h"
00035
00036 #include <MyParser.h>
00037 #include "math.h"
00038 #include <gsl/gsl_sf.h>
00039 #include <q3asciidict.h>
00040
00042 class muParserScript: public Script
00043 {
00044 Q_OBJECT
00045
00046 public:
00047 muParserScript(ScriptingEnv *env, const QString &code, QObject *context=0, const QString &name="<input>");
00048
00049 public slots:
00050 bool compile(bool asFunction=true);
00051 QVariant eval();
00052 double evalSingleLine();
00053 QString evalSingleLineToString(const QLocale& locale, char f, int prec);
00054 bool exec();
00055 bool setQObject(QObject *val, const char *name);
00056 bool setInt(int val, const char* name);
00057 bool setDouble(double val, const char* name);
00058 double* defineVariable(const char *name, double val = 0.0);
00059 int codeLines(){return muCode.size();};
00060
00061 private:
00062 double col(const QString &arg);
00063 double tablecol(const QString &arg);
00064 double cell(int row, int col);
00065 double tableCell(int col, int row);
00066 double *addVariable(const char *name);
00067 double *addVariableR(const char *name);
00068 static double *mu_addVariableR(const char *name) { return current->addVariableR(name); }
00069 static double mu_col(const char *arg) { return current->col(arg); }
00070 static double mu_cell(double row, double col) { return current->cell(qRound(row), qRound(col)); }
00071 static double mu_tableCell(double col, double row) { return current->tableCell(qRound(col), qRound(row)); }
00072 static double mu_tablecol(const char *arg) { return current->tablecol(arg); }
00073 static double *mu_addVariable(const char *name, void *){ return current->addVariable(name); }
00074 static double *mu_addVariableR(const char *name, void *) { return current->addVariableR(name); }
00075 static QString compileColArg(const QString& in);
00076
00077 MyParser parser, rparser;
00078 Q3AsciiDict<double> variables, rvariables;
00079 QStringList muCode;
00080
00081 public:
00082 static muParserScript *current;
00083 };
00084
00085 #endif