filters

kspread/qpro/libqpro/qpro/formula.h
1#ifndef TQPRO_FORMULA_H
2#define TQPRO_FORMULA_H
3
4#include <qpro/tablenames.h>
5#include <qpro/stream.h>
6#include <qpro/record.h>
7
8class QpFormula;
9
10// --------------------------------------------------------------------
11
12class QpFormulaStack
13{
14public:
15 QpFormulaStack();
16 ~QpFormulaStack();
17
18 void bracket(const char* pBefore="(", const char* pAfter=")");
19 void push(const char* pString);
20 void pop(int pCnt=1);
21 void join(int pCnt, const char* pSeparator=",");
22 const char* top();
23
24 const char* operator [] (int pIdx);
25
26protected:
27 int cIdx;
28 int cMax;
29
30 char** cStack;
31};
32
33
34// --------------------------------------------------------------------
35
36struct QpFormulaConv
37{
38 TQP_UINT8 cOperand;
39 void (*cFunc)(QpFormula& pThis, const char* pArg);
40 const char* cArg;
41};
42
43// --------------------------------------------------------------------
44
45class QpFormula
46{
47public:
48 QpFormula(QpRecFormulaCell& pCell, QpTableNames& pTable);
49 ~QpFormula();
50
51 void argSeparator(const char* pArg);
52
53 char* formula();
54
55
56 static void binaryOperand(QpFormula& pThis, const char* pOper)
57 {pThis.binaryOperandReal(pOper);}
58
59 static void floatFunc(QpFormula& pThis, const char* pFunc)
60 {pThis.floatFuncReal(pFunc);}
61
62 void formulaStart(const char* pFirstChar);
63
64 static void absKludge(QpFormula& pThis, const char* pFunc)
65 {pThis.absKludgeReal(pFunc);}
66
67 static void func0(QpFormula& pThis, const char* pFunc)
68 {pThis.func0Real(pFunc);}
69
70 static void func1(QpFormula& pThis, const char* pFunc)
71 {pThis.func1Real(pFunc);}
72
73 static void func2(QpFormula& pThis, const char* pFunc)
74 {pThis.func2Real(pFunc);}
75
76 static void func3(QpFormula& pThis, const char* pFunc)
77 {pThis.func3Real(pFunc);}
78
79 static void func4(QpFormula& pThis, const char* pFunc)
80 {pThis.func4Real(pFunc);}
81
82 static void funcV(QpFormula& pThis, const char* pFunc)
83 {pThis.funcVReal(pFunc);}
84
85 static void intFunc(QpFormula& pThis, const char* pFunc)
86 {pThis.intFuncReal(pFunc);}
87
88 void dropLeadingAt(int pBool=-1);
89
90 static void ref(QpFormula& pThis, const char* pFunc)
91 {pThis.refReal(pFunc);}
92
93 void replaceFunc(QpFormulaConv* pFuncEntry);
94
95 static void stringFunc(QpFormula& pThis, const char* pFunc)
96 {pThis.stringFuncReal(pFunc);}
97
98 static void unaryOperand(QpFormula& pThis, const char* pOper)
99 {pThis.unaryOperandReal(pOper);}
100
101protected:
102 char* cArgSeparator;
103 QpRecFormulaCell& cCell;
104 QpIStream cFormula;
105 QpIStream cFormulaRefs;
106 QpFormulaConv* cReplaceFunc;
107 char* cFormulaStart;
108 int cIdx;
109 QpFormulaStack cStack;
110 int cDropLeadingAt;
111 QpTableNames& cTable;
112
113 void absKludgeReal(const char* pOper);
114 void binaryOperandReal(const char* pOper);
115 void floatFuncReal(const char* pFunc);
116 void func0Real(const char* pFunc);
117 void func1Real(const char* pFunc);
118 void func2Real(const char* pFunc);
119 void func3Real(const char* pFunc);
120 void func4Real(const char* pFunc);
121 void funcVReal(const char* pFunc);
122 void intFuncReal(const char* pFunc);
123 void refReal(const char* pFunc);
124 void stringFuncReal(const char* pFunc);
125 void unaryOperandReal(const char* pOper);
126};
127
128#endif // TQPRO_FORMULA_H