1 #ifndef _CEGODATABASEFORMATER_H_INCLUDED_
2 #define _CEGODATABASEFORMATER_H_INCLUDED_
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 // CegoDatabaseFormater.h
6 // ----------------------
7 // Cego database formater super class
8 //
9 // Design and Implementation by Bjoern Lemke
10 //
11 // (C)opyright 2000-2019 Bjoern Lemke
12 //
13 // INTERFACE MODULE
14 //
15 // Class: CegoDatabaseFormater
16 //
17 // Description: Abstract class which is implemented by database specific database export classes
18 //
19 // Status: CLEAN
20 //
21 ///////////////////////////////////////////////////////////////////////////////
22 
23 // CEGO INCLUDES
24 #include "CegoProcBlock.h"
25 #include "CegoDataType.h"
26 #include "CegoProcedure.h"
27 #include "CegoProcAssignStmt.h"
28 #include "CegoProcCond.h"
29 #include "CegoProcPred.h"
30 #include "CegoQuery.h"
31 #include "CegoSelect.h"
32 #include "CegoExpr.h"
33 #include "CegoTerm.h"
34 #include "CegoFactor.h"
35 #include "CegoFunction.h"
36 #include "CegoAggregation.h"
37 #include "CegoException.h"
38 
39 class CegoDatabaseFormater {
40 
41 public:
42 
43     CegoDatabaseFormater();
44     ~CegoDatabaseFormater();
45 
46     virtual Chain formatProcedure(const Chain& procName, CegoProcedure::ProcType procType, CegoDataType returnType, int returnTypeLen, int returnTypeDim, CegoProcBlock* pBlock) = 0;
47     virtual Chain formatProcVar(const Chain& varName, CegoProcVar::VarType varType, CegoDataType dt, int dtlen, int dtdim) = 0;
48     virtual Chain formatProcBlock(const ListT<CegoProcVar>& varList, const ListT<CegoProcStmt*>& stmtList,  const ListT<CegoProcException*>& exceptionList) = 0;
49     virtual Chain formatProcAssignStmt(CegoProcAssignStmt::AssignmentMode mode, const Chain paramName, CegoExpr* pExpr) = 0;
50     virtual Chain formatProcThrowStmt(CegoExpr* pExpr) = 0;
51     virtual Chain formatProcBlockStmt(CegoProcBlock* pBlock) = 0;
52     virtual Chain formatProcCursorCreateStmt(const Chain& name, CegoSelect* pSelect) = 0;
53     virtual Chain formatProcCursorCloseStmt(const Chain& name) = 0;
54     virtual Chain formatProcIfStmt(const ListT<CegoProcCond*>& condList, const ListT<CegoProcBlock*>& ifBlockList) = 0;
55     virtual Chain formatProcNoopStmt() = 0;
56     virtual Chain formatProcQueryStmt(CegoQuery *pQuery) = 0;
57     virtual Chain formatProcReturnStmt(CegoExpr *pExpr) = 0;
58     virtual Chain formatProcWhileStmt(CegoProcCond* pCond, CegoProcBlock* pBlock) = 0;
59     virtual Chain formatProcCond(CegoProcCond::ConditionMode mode, CegoProcCond* pCond, CegoProcPred* pPred) = 0;
60     virtual Chain formatProcPred(CegoProcPred::PredicateMode mode, CegoExpr* pExpr1, CegoExpr* pExpr2, CegoComparison comp, CegoProcCond* pCond, bool isNegate) = 0;
61     virtual Chain formatProcException(CegoException excep) = 0;
62 
63     virtual Chain formatExpr(CegoExpr::ExpType expType, CegoExpr* pExpr, CegoTerm* pTerm) = 0;
64     virtual Chain formatTerm(CegoTerm::TermType termType, CegoTerm* pTerm, CegoFactor* pFactor) = 0;
65     virtual Chain formatFactor(CegoFactor::FacType facType,
66 			       const CegoFieldValue& fv,
67 			       CegoAttrDesc* pAttrDesc,
68 			       const Chain varName,
69 			       CegoExpr* pExpr,
70 			       CegoProcFetch *pFetch,
71 			       CegoAggregation* pAggr,
72 			       CegoFunction* pFunction,
73 			       CegoSelect* pSelect,
74 			       CegoCaseCond* pCaseCond ) = 0;
75 
76     virtual Chain formatSelect(CegoSelect::SelectMode mode,
77 			       bool isDistinct,
78 			       const ListT<CegoExpr*>& exprList,
79 			       const ListT<CegoContentObject*>& coList,
80 			       CegoPredDesc *pPred,
81 			       ListT<CegoAttrDesc*> *pGroupList,
82 			       CegoHavingDesc* pHaving,
83 			       ListT<CegoExpr*> *pOrderList,
84 			       int rowLimit,
85 			       CegoSelect* pUnionSelect) = 0;
86 
87     virtual Chain formatProcFetch(const Chain& curName, const ListT<Chain>& varList) = 0;
88 
89     virtual Chain formatHaving(CegoExpr *pAggExpr, CegoExpr* pExpr, CegoComparison comp) = 0;
90 
91     virtual Chain formatPred(CegoPredDesc::CompMode mode,
92 			     CegoExpr* pExpr1,
93 			     CegoExpr *pExpr2,
94 			     CegoExpr* pExpr3,
95 			     ListT<CegoExpr*>& exprList,
96 			     CegoComparison comp,
97 			     const Chain& pattern,
98 			     CegoCondDesc* pCond,
99 			     CegoPredDesc* pPred,
100 			     CegoSelect *pSelect) = 0;
101 
102 
103     virtual Chain formatQuery(CegoQuery::QueryMode mode,
104 			      const Chain& tableName,
105 			      const Chain& tableAlias,
106 			      const ListT<CegoField>& schema,
107 			      const ListT<ListT<CegoExpr*> >& exprListArray,
108 			      const ListT<CegoExpr*>& updList,
109 			      const ListT<CegoReturnVar*>& retVarList,
110 			      const ListT<CegoAlterDesc>& alterList,
111 			      CegoPredDesc *pPred,
112 			      CegoSelect *pSelect,
113 			      const Chain& objName,
114 			      CegoObject::ObjectType objType,
115 			      const Chain& newObjName) = 0;
116 
117 
118     virtual Chain formatAttr(const Chain& tableName, const Chain& attrName) = 0;
119     virtual Chain formatFunction(CegoFunction::FunctionType type, const ListT<CegoExpr*>& exprList, const Chain& funcName, const Chain& counterId) = 0;
120     virtual Chain formatAggregation(CegoAggregation::AggType type, CegoExpr *pExpr, bool isDistinct) = 0;
121     virtual Chain formatCaseCond(const ListT<CegoPredDesc*>& predList, const ListT<CegoExpr*>& exprList, CegoExpr* elseExpr) = 0;
122 
123     virtual Chain formatReturnValue(const Chain& varName, CegoExpr* pExpr) = 0;
124     virtual Chain formatAlter(CegoAlterDesc::AlterType type, const CegoField& f, const Chain& attrName) = 0;
125 
126     virtual Chain formatFieldValue(CegoDataType type, void *pV, int len ) = 0;
127 
128     virtual Chain formatTrigger(const Chain& triggerName,
129 				bool isBefore,
130 				bool isOnInsert,
131 				bool isOnUpdate,
132 				bool isOnDelete,
133 				const Chain& tableName,
134 				CegoProcBlock* pBlock) = 0;
135 
136 };
137 
138 #endif
139