1 #ifndef _ORACLEACTION_H_INCLUDED_
2 #define _ORACLEACTION_H_INCLUDED_
3 ///////////////////////////////////////////////////////////////////////////////
4 //
5 // OracleAction.h
6 // ------------------
7 // Oracle semantic actions interface definition
8 //
9 // Design and Implementation by Bjoern Lemke
10 //
11 // (C)opyright 2015 Bjoern Lemke
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2, or (at your option)
16 // any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; see the file COPYING.  If not, write to
25 // the Free Software Foundation, 59 Temple Place - Suite 330,
26 // Boston, MA 02111-1307, USA.
27 //
28 // INTERFACE MODULE
29 //
30 // Class: OracleAction
31 //
32 // Description:
33 //
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #include <lfcbase/StackT.h>
38 #include <lfcbase/ListT.h>
39 #include <lfcbase/File.h>
40 
41 #include <cego/CegoNet.h>
42 #include "OracleParser.h"
43 
44 #define ORACLE_MAXSTRINGLEN 500000
45 
46 class OracleAction : public OracleParser {
47 
48 public:
49 
50     OracleAction(const Chain& fileName, CegoNet *pCegoNet, bool isCaseSensitive = false);
51     ~OracleAction();
52 
53     void cleanUp();
54     bool moreData();
55     void setFile(const Chain& fileName);
56     char nextChar();
57     void readChain();
58     void backChar();
59 
60     void printTokenList();
61 
62     /////////////////////////////////////////////////
63     /////////// start of semantic actions ///////////
64     /////////////////////////////////////////////////
65 
66     void postAction();
67 
68     void execCreate();
69     void execInsert();
70     void setInsertTable();
71     void execDrop();
72     void dropOpt1();
73     void dropOpt2();
74     void storeAttrColumn();
75     void storeTable();
76 
77     void storePrimaryKey();
78     void storeUniqueKey();
79     void storeKey();
80     void storeKeyColumn();
81     void storeNullOpt();
82     void storeNotNullOpt();
83     void storeDefaultOpt();
84     void storeDefaultNullOpt();
85     void insertConstValue();
86     void insertPreAction();
87     void insertPostAction();
88     void storeIntType();
89     void storeDecimalType();
90     void storeUnsignedType();
91     void storeVarcharType();
92     void storeTimestampType();
93     void storeDatetimeType();
94     void storeMediumTextType();
95     void storeEnumType();
96     void storeIntValue();
97     void storeNegIntValue();
98     void storeVarcharValue();
99     void storeNullValue();
100     void storeDim();
101     void storeDecimalDim();
102 
103 private:
104 
105     class TypeInfo {
106 
107     public:
108 
TypeInfo()109 	TypeInfo()
110 	{
111 	}
112 
TypeInfo(const Chain & tableName,int pos)113 	TypeInfo(const Chain& tableName, int pos)
114 	{
115 	    _tableName = tableName;
116 	    _pos = pos;
117 	}
118 
TypeInfo(const Chain & tableName,int pos,const Chain & type)119 	TypeInfo(const Chain& tableName, int pos, const Chain& type)
120 	{
121 	    _tableName = tableName;
122 	    _pos = pos;
123 	    _type = type;
124 	}
125 
getTable()126 	const Chain& getTable()
127 	{
128 	    return _tableName;
129 	}
130 
getPos()131 	int getPos()
132 	{
133 	    return _pos;
134 	}
135 
getType()136 	const Chain& getType()
137 	{
138 	    return _type;
139 	}
140 
141 	TypeInfo& operator = ( const TypeInfo& ti)
142 	{
143 	    _tableName = ti._tableName;
144 	    _pos = ti._pos;
145 	    _type = ti._type;
146 	    return *this;
147 	}
148 
149 	bool operator == ( const TypeInfo& ti) const
150 	{
151 	    return ti._tableName == _tableName && ti._pos == _pos;
152 	}
153 
154     private:
155 
156 	Chain _tableName;
157 	int _pos;
158 	Chain _type;
159     };
160 
161     ListT<TypeInfo> _typeList;
162 
163     void putTypeInfo(TypeInfo ti);
164     TypeInfo* getTypeInfo(const Chain& tableName, int pos);
165 
166     int _i;
167     char *_pC;
168     Chain _line;
169 
170     int _stringBufLen;
171     char _stringBuf[ORACLE_MAXSTRINGLEN];
172 
173     File* _pFile;
174     CegoNet* _pCegoNet;
175 
176     bool _isFirst;
177     bool _isCaseSensitive;
178 
179     ListT<Chain> _colList;
180     ListT<Chain> _keyColList;
181     ListT<Chain> _valList;
182 
183     ListT<Chain> _postList;
184 
185     Chain _dataTypeString;
186     Chain _nullOptString;
187     Chain _defaultOptString;
188     Chain _table;
189     Chain _constValue;
190     int _dim;
191     int _decDim;
192 
193 };
194 
195 #endif
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210