filters
formula.h00001 #ifndef QPRO_FORMULA_H
00002 #define QPRO_FORMULA_H
00003
00004 #include <qpro/tablenames.h>
00005 #include <qpro/stream.h>
00006 #include <qpro/record.h>
00007
00008 class QpFormula;
00009
00010
00011
00012 class QpFormulaStack
00013 {
00014 public:
00015 QpFormulaStack();
00016 ~QpFormulaStack();
00017
00018 void bracket(const char* pBefore="(", const char* pAfter=")");
00019 void push(const char* pString);
00020 void pop(int pCnt=1);
00021 void join(int pCnt, const char* pSeparator=",");
00022 const char* top();
00023
00024 const char* operator [] (int pIdx);
00025
00026 protected:
00027 int cIdx;
00028 int cMax;
00029
00030 char** cStack;
00031 };
00032
00033
00034
00035
00036 struct QpFormulaConv
00037 {
00038 QP_INT8 cOperand;
00039 void (*cFunc)(QpFormula& pThis, const char* pArg);
00040 const char* cArg;
00041 };
00042
00043
00044
00045 class QpFormula
00046 {
00047 public:
00048 QpFormula(QpRecFormulaCell& pCell, QpTableNames& pTable);
00049 ~QpFormula();
00050
00051 void argSeparator(const char* pArg);
00052
00053 char* formula();
00054
00055
00056 static void binaryOperand(QpFormula& pThis, const char* pOper)
00057 {pThis.binaryOperandReal(pOper);}
00058
00059 static void floatFunc(QpFormula& pThis, const char* pFunc)
00060 {pThis.floatFuncReal(pFunc);}
00061
00062 void formulaStart(const char* pFirstChar);
00063
00064 static void absKludge(QpFormula& pThis, const char* pFunc)
00065 {pThis.absKludgeReal(pFunc);}
00066
00067 static void func0(QpFormula& pThis, const char* pFunc)
00068 {pThis.func0Real(pFunc);}
00069
00070 static void func1(QpFormula& pThis, const char* pFunc)
00071 {pThis.func1Real(pFunc);}
00072
00073 static void func2(QpFormula& pThis, const char* pFunc)
00074 {pThis.func2Real(pFunc);}
00075
00076 static void func3(QpFormula& pThis, const char* pFunc)
00077 {pThis.func3Real(pFunc);}
00078
00079 static void func4(QpFormula& pThis, const char* pFunc)
00080 {pThis.func4Real(pFunc);}
00081
00082 static void funcV(QpFormula& pThis, const char* pFunc)
00083 {pThis.funcVReal(pFunc);}
00084
00085 static void intFunc(QpFormula& pThis, const char* pFunc)
00086 {pThis.intFuncReal(pFunc);}
00087
00088 void dropLeadingAt(int pBool=-1);
00089
00090 static void ref(QpFormula& pThis, const char* pFunc)
00091 {pThis.refReal(pFunc);}
00092
00093 void replaceFunc(QpFormulaConv* pFuncEntry);
00094
00095 static void stringFunc(QpFormula& pThis, const char* pFunc)
00096 {pThis.stringFuncReal(pFunc);}
00097
00098 static void unaryOperand(QpFormula& pThis, const char* pOper)
00099 {pThis.unaryOperandReal(pOper);}
00100
00101 protected:
00102 char* cArgSeparator;
00103 QpRecFormulaCell& cCell;
00104 QpIStream cFormula;
00105 QpIStream cFormulaRefs;
00106 QpFormulaConv* cReplaceFunc;
00107 char* cFormulaStart;
00108 int cIdx;
00109 QpFormulaStack cStack;
00110 int cDropLeadingAt;
00111 QpTableNames& cTable;
00112
00113 void absKludgeReal(const char* pOper);
00114 void binaryOperandReal(const char* pOper);
00115 void floatFuncReal(const char* pFunc);
00116 void func0Real(const char* pFunc);
00117 void func1Real(const char* pFunc);
00118 void func2Real(const char* pFunc);
00119 void func3Real(const char* pFunc);
00120 void func4Real(const char* pFunc);
00121 void funcVReal(const char* pFunc);
00122 void intFuncReal(const char* pFunc);
00123 void refReal(const char* pFunc);
00124 void stringFuncReal(const char* pFunc);
00125 void unaryOperandReal(const char* pOper);
00126 };
00127
00128 #endif // QPRO_FORMULA_H
|