1 /*
2 / QueryView.cpp
3 / a panel to set SQL queries
4 /
5 / version 1.7, 2013 May 8
6 /
7 / Author: Sandro Furieri a-furieri@lqt.it
8 /
9 / Copyright (C) 2008-2013  Alessandro Furieri
10 /
11 /    This program is free software: you can redistribute it and/or modify
12 /    it under the terms of the GNU General Public License as published by
13 /    the Free Software Foundation, either version 3 of the License, or
14 /    (at your option) any later version.
15 /
16 /    This program is distributed in the hope that it will be useful,
17 /    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 /    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 /    GNU General Public License for more details.
20 /
21 /    You should have received a copy of the GNU General Public License
22 /    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 /
24 */
25 
26 #include "Classdef.h"
27 
28 #include "wx/clipbrd.h"
29 #include "wx/filename.h"
30 
31 //
32 // ICONs in XPM format [universally portable]
33 //
34 #include "icons/sql_go.xpm"
35 #include "icons/sql_abort.xpm"
36 #include "icons/sql_abort_no.xpm"
37 #include "icons/hs_back.xpm"
38 #include "icons/hs_back_no.xpm"
39 #include "icons/hs_forward.xpm"
40 #include "icons/hs_forward_no.xpm"
41 
MyQueryView(MyFrame * parent,wxWindowID id)42 MyQueryView::MyQueryView(MyFrame * parent, wxWindowID id):
43 wxPanel(parent, id, wxDefaultPosition, wxSize(440, 76), wxBORDER_SUNKEN)
44 {
45 //
46 // constructor: a frame for SQL Queries
47 //
48   MainFrame = parent;
49   BracketStart = -1;
50   BracketEnd = -1;
51   IgnoreEvent = false;
52 // SQL statement
53   SqlCtrl =
54     new MySqlControl(this, ID_SQL, wxT(""), wxPoint(40, 5),
55                      wxSize(20, 20),
56                      wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB |
57                      wxHSCROLL | wxTE_RICH);
58   BtnSqlGo =
59     new wxBitmapButton(this, ID_SQL_GO, wxBitmap(sql_go_xpm), wxPoint(340, 5),
60                        wxSize(32, 32));
61   BtnSqlGo->SetToolTip(wxT("Execute SQL statement"));
62   BtnSqlAbort =
63     new wxBitmapButton(this, ID_SQL_ABORT, wxBitmap(sql_abort_xpm),
64                        wxPoint(340, 38), wxSize(32, 32));
65   BtnSqlAbort->SetBitmapDisabled(wxBitmap(sql_abort_no_xpm));
66   BtnSqlAbort->SetToolTip(wxT("Abort SQL query"));
67   BtnHistoryBack =
68     new wxBitmapButton(this, ID_HISTORY_BACK, wxBitmap(hs_back_xpm),
69                        wxPoint(5, 5), wxSize(32, 32));
70   BtnHistoryBack->SetBitmapDisabled(wxBitmap(hs_back_no_xpm));
71   BtnHistoryBack->SetToolTip(wxT("History: previous SQL statement"));
72   BtnHistoryForward =
73     new wxBitmapButton(this, ID_HISTORY_FORWARD, wxBitmap(hs_forward_xpm),
74                        wxPoint(5, 40), wxSize(32, 32));
75   BtnHistoryForward->SetBitmapDisabled(wxBitmap(hs_forward_no_xpm));
76   BtnHistoryForward->SetToolTip(wxT("History: next SQL statement"));
77   SetHistoryStates();
78   BtnSqlAbort->Enable(false);
79 // setting up event handlers
80   Connect(ID_SQL_GO, wxEVT_COMMAND_BUTTON_CLICKED,
81           (wxObjectEventFunction) & MyQueryView::OnSqlGo);
82   Connect(ID_SQL_ABORT, wxEVT_COMMAND_BUTTON_CLICKED,
83           (wxObjectEventFunction) & MyQueryView::OnSqlAbort);
84   Connect(ID_HISTORY_BACK, wxEVT_COMMAND_BUTTON_CLICKED,
85           (wxObjectEventFunction) & MyQueryView::OnHistoryBack);
86   Connect(ID_HISTORY_FORWARD, wxEVT_COMMAND_BUTTON_CLICKED,
87           (wxObjectEventFunction) & MyQueryView::OnHistoryForward);
88   Connect(wxID_ANY, wxEVT_SIZE, (wxObjectEventFunction) & MyQueryView::OnSize);
89   Connect(wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED,
90           (wxObjectEventFunction) & MyQueryView::OnSqlSyntaxColor);
91 }
92 
ShowControls()93 void MyQueryView::ShowControls()
94 {
95 //
96 // making all SQL controls to be visible
97 //
98   SqlCtrl->Show(true);
99   BtnSqlGo->Show(true);
100   BtnSqlAbort->Show(true);
101   BtnHistoryBack->Show(true);
102   BtnHistoryForward->Show(true);
103   SetHistoryStates();
104 }
105 
HideControls()106 void MyQueryView::HideControls()
107 {
108 //
109 // making all controls to be invisible
110 //
111   SqlCtrl->Show(false);
112   BtnSqlGo->Show(false);
113   BtnSqlAbort->Show(false);
114   BtnHistoryBack->Show(false);
115   BtnHistoryForward->Show(false);
116 
117 }
118 
AddToHistory(wxString & sql)119 void MyQueryView::AddToHistory(wxString & sql)
120 {
121 //
122 // adds an SQL statement to history
123 //
124   History.Add(sql);
125   SetHistoryStates();
126 }
127 
SetHistoryStates()128 void MyQueryView::SetHistoryStates()
129 {
130 //
131 // updates the history buttons state
132 //
133   BtnHistoryForward->Enable(History.TestNext());
134   BtnHistoryBack->Enable(History.TestPrev());
135 }
136 
SetSql(wxString & sql,bool execute)137 void MyQueryView::SetSql(wxString & sql, bool execute)
138 {
139 //
140 // sets an SQL statement [and maybe executes it]
141 //
142   int metaDataType = MainFrame->GetMetaDataType();
143   SqlCtrl->SetValue(sql);
144   if (execute == true)
145     {
146       if (metaDataType == METADATA_CURRENT)
147         {
148           // current metadata style >= v.4.0.0
149           MainFrame->InsertIntoLog(sql);
150         }
151       if (MainFrame->GetRsView()->ExecuteSqlPre(sql, 0, true) == false)
152         {
153           if (metaDataType == METADATA_CURRENT)
154             {
155               // current metadata style >= v.4.0.0
156               MainFrame->UpdateLog(MainFrame->GetRsView()->GetSqlErrorMsg());
157             }
158           wxMessageBox(MainFrame->GetRsView()->GetSqlErrorMsg(),
159                        wxT("spatialite_gui"), wxOK | wxICON_ERROR, MainFrame);
160       } else
161         {
162           if (metaDataType == METADATA_CURRENT)
163             {
164               // current metadata style >= v.4.0.0
165               MainFrame->UpdateLog();
166             }
167         }
168     }
169 }
170 
OnSize(wxSizeEvent & WXUNUSED (event))171 void MyQueryView::OnSize(wxSizeEvent & WXUNUSED(event))
172 {
173 //
174 // this window has changed its size
175 //
176   int vert;
177   int vertBack;
178   wxSize sz = GetClientSize();
179 // setting the SQL statement pane size
180   SqlCtrl->SetSize(sz.GetWidth() - 80, sz.GetHeight() - 10);
181 // setting the SQL GO button position
182   BtnSqlGo->Move(sz.GetWidth() - 35, 5);
183 // setting the SQL GO button size
184   vert = sz.GetHeight() - 45;
185   if (vert < 32)
186     vert = 32;
187   BtnSqlGo->SetSize(32, vert);
188 // setting the SQL ABORT button position
189   BtnSqlAbort->Move(sz.GetWidth() - 35, sz.GetHeight() - 37);
190 // setting the SQL ABORT button size
191   BtnSqlAbort->SetSize(32, 32);
192 // setting the HISTORY BACK button position
193   BtnHistoryBack->Move(5, 5);
194 // setting the HISTORY BACK button size
195   vert = (sz.GetHeight() - 15) / 2;
196   if (vert < 32)
197     vert = 32;
198   BtnHistoryBack->SetSize(32, vert);
199   vertBack = 10 + vert;
200 // setting the HISTORY FORWARD button position
201   BtnHistoryForward->Move(5, vertBack);
202 // setting the HISTORY FORWARD button size
203   BtnHistoryForward->SetSize(32, vert);
204 }
205 
OnSqlGo(wxCommandEvent & WXUNUSED (event))206 void MyQueryView::OnSqlGo(wxCommandEvent & WXUNUSED(event))
207 {
208 //
209 // executing an SQL statement
210 //
211   int metaDataType = MainFrame->GetMetaDataType();
212   wxString sql = SqlCtrl->GetValue();
213   if (metaDataType == METADATA_CURRENT)
214     {
215       // current metadata style >= v.4.0.0
216       MainFrame->InsertIntoLog(sql);
217     }
218   if (MainFrame->GetRsView()->ExecuteSqlPre(sql, 0, true) == false)
219     {
220       if (metaDataType == METADATA_CURRENT)
221         {
222           // current metadata style >= v.4.0.0
223           MainFrame->UpdateLog(MainFrame->GetRsView()->GetSqlErrorMsg());
224         }
225       wxMessageBox(MainFrame->GetRsView()->GetSqlErrorMsg(),
226                    wxT("spatialite_gui"), wxOK | wxICON_ERROR, MainFrame);
227   } else
228     {
229       if (metaDataType == METADATA_CURRENT)
230         {
231           // current metadata style >= v.4.0.0
232           MainFrame->UpdateLog();
233         }
234     }
235 }
236 
OnSqlAbort(wxCommandEvent & WXUNUSED (event))237 void MyQueryView::OnSqlAbort(wxCommandEvent & WXUNUSED(event))
238 {
239 //
240 // aborting the current SQL query
241 //
242   MainFrame->GetRsView()->AbortRequested();
243   if (MainFrame->GetMetaDataType() == METADATA_CURRENT)
244     {
245       // current metadata style >= v.4.0.0
246       MainFrame->UpdateAbortedLog();
247     }
248 }
249 
OnHistoryBack(wxCommandEvent & WXUNUSED (event))250 void MyQueryView::OnHistoryBack(wxCommandEvent & WXUNUSED(event))
251 {
252 //
253 // going backward into the SQL Queries History
254 //
255   MySqlQuery *sql = History.GetPrev();
256   if (sql)
257     {
258       SetSql(sql->GetSql(), false);
259       SetHistoryStates();
260     }
261 }
262 
OnHistoryForward(wxCommandEvent & WXUNUSED (event))263 void MyQueryView::OnHistoryForward(wxCommandEvent & WXUNUSED(event))
264 {
265 //
266 // going forward into the SQL Queries History
267 //
268   MySqlQuery *sql = History.GetNext();
269   if (sql)
270     {
271       SetSql(sql->GetSql(), false);
272       SetHistoryStates();
273     }
274 }
275 
IsSqlString(wxString & str)276 bool MyQueryView::IsSqlString(wxString & str)
277 {
278 // checks if this one is an SQL string constant
279   char word[4096];
280   strcpy(word, str.ToUTF8());
281   int len = strlen(word);
282   if (len < 2)
283     return false;
284   if (word[0] == '\'' && word[len - 1] == '\'')
285     return true;
286   if (word[0] == '"' && word[len - 1] == '"')
287     return true;
288   return false;
289 }
290 
IsSqlNumber(wxString & str)291 bool MyQueryView::IsSqlNumber(wxString & str)
292 {
293 // checks if this one is an SQL numeric constant
294   double dbl;
295   return str.ToDouble(&dbl);
296 }
297 
IsSqliteExtra(wxString & str)298 bool MyQueryView::IsSqliteExtra(wxString & str)
299 {
300 // checks if this one is an extra SQLite keyword
301   if (str.CmpNoCase(wxT("asc")) == 0)
302     return true;
303   if (str.CmpNoCase(wxT("desc")) == 0)
304     return true;
305   if (str.CmpNoCase(wxT("null")) == 0)
306     return true;
307   if (str.CmpNoCase(wxT("trigger")) == 0)
308     return true;
309   if (str.CmpNoCase(wxT("for")) == 0)
310     return true;
311   if (str.CmpNoCase(wxT("each")) == 0)
312     return true;
313   if (str.CmpNoCase(wxT("row")) == 0)
314     return true;
315   if (str.CmpNoCase(wxT("begin")) == 0)
316     return true;
317   if (str.CmpNoCase(wxT("end")) == 0)
318     return true;
319   if (str.CmpNoCase(wxT("before")) == 0)
320     return true;
321   if (str.CmpNoCase(wxT("after")) == 0)
322     return true;
323   if (str.CmpNoCase(wxT("virtual")) == 0)
324     return true;
325   return false;
326 }
327 
IsSqlFunction(wxString & str,char next_c)328 bool MyQueryView::IsSqlFunction(wxString & str, char next_c)
329 {
330 // checks if this one is an SQL function
331   if (next_c != '(')
332     return false;
333   if (str.CmpNoCase(wxT("raise")) == 0)
334     return true;
335   if (str.CmpNoCase(wxT("avg")) == 0)
336     return true;
337   if (str.CmpNoCase(wxT("count")) == 0)
338     return true;
339   if (str.CmpNoCase(wxT("group_concat")) == 0)
340     return true;
341   if (str.CmpNoCase(wxT("max")) == 0)
342     return true;
343   if (str.CmpNoCase(wxT("min")) == 0)
344     return true;
345   if (str.CmpNoCase(wxT("sum")) == 0)
346     return true;
347   if (str.CmpNoCase(wxT("total")) == 0)
348     return true;
349   if (str.CmpNoCase(wxT("abs")) == 0)
350     return true;
351   if (str.CmpNoCase(wxT("changes")) == 0)
352     return true;
353   if (str.CmpNoCase(wxT("char")) == 0)
354     return true;
355   if (str.CmpNoCase(wxT("coalesce")) == 0)
356     return true;
357   if (str.CmpNoCase(wxT("glob")) == 0)
358     return true;
359   if (str.CmpNoCase(wxT("ifnull")) == 0)
360     return true;
361   if (str.CmpNoCase(wxT("instr")) == 0)
362     return true;
363   if (str.CmpNoCase(wxT("hex")) == 0)
364     return true;
365   if (str.CmpNoCase(wxT("last_insert_rowid")) == 0)
366     return true;
367   if (str.CmpNoCase(wxT("length")) == 0)
368     return true;
369   if (str.CmpNoCase(wxT("load_extension")) == 0)
370     return true;
371   if (str.CmpNoCase(wxT("lower")) == 0)
372     return true;
373   if (str.CmpNoCase(wxT("ltrim")) == 0)
374     return true;
375   if (str.CmpNoCase(wxT("nullif")) == 0)
376     return true;
377   if (str.CmpNoCase(wxT("quote")) == 0)
378     return true;
379   if (str.CmpNoCase(wxT("random")) == 0)
380     return true;
381   if (str.CmpNoCase(wxT("randomblob")) == 0)
382     return true;
383   if (str.CmpNoCase(wxT("replace")) == 0)
384     return true;
385   if (str.CmpNoCase(wxT("round")) == 0)
386     return true;
387   if (str.CmpNoCase(wxT("rtrim")) == 0)
388     return true;
389   if (str.CmpNoCase(wxT("soundex")) == 0)
390     return true;
391   if (str.CmpNoCase(wxT("sqlite_version")) == 0)
392     return true;
393   if (str.CmpNoCase(wxT("substr")) == 0)
394     return true;
395   if (str.CmpNoCase(wxT("trim")) == 0)
396     return true;
397   if (str.CmpNoCase(wxT("typeof")) == 0)
398     return true;
399   if (str.CmpNoCase(wxT("unicode")) == 0)
400     return true;
401   if (str.CmpNoCase(wxT("upper")) == 0)
402     return true;
403   if (str.CmpNoCase(wxT("zeroblob")) == 0)
404     return true;
405   return false;
406 }
407 
IsSqlGeoFunction(wxString & str,char next_c)408 bool MyQueryView::IsSqlGeoFunction(wxString & str, char next_c)
409 {
410 // checks if this one is an SQL geo-function
411   if (next_c != '(')
412     return false;
413   if (str.CmpNoCase(wxT("spatialite_version")) == 0)
414     return true;
415   if (str.CmpNoCase(wxT("geos_version")) == 0)
416     return true;
417   if (str.CmpNoCase(wxT("proj4_version")) == 0)
418     return true;
419   if (str.CmpNoCase(wxT("lwgeom_version")) == 0)
420     return true;
421   if (str.CmpNoCase(wxT("libxml2_version")) == 0)
422     return true;
423   if (str.CmpNoCase(wxT("hasIconv")) == 0)
424     return true;
425   if (str.CmpNoCase(wxT("hasMathSql")) == 0)
426     return true;
427   if (str.CmpNoCase(wxT("hasGeoCallbacks")) == 0)
428     return true;
429   if (str.CmpNoCase(wxT("hasGeos")) == 0)
430     return true;
431   if (str.CmpNoCase(wxT("hasProj")) == 0)
432     return true;
433   if (str.CmpNoCase(wxT("hasGeosAdvanced")) == 0)
434     return true;
435   if (str.CmpNoCase(wxT("hasGeosTrunk")) == 0)
436     return true;
437   if (str.CmpNoCase(wxT("hasLwGeom")) == 0)
438     return true;
439   if (str.CmpNoCase(wxT("hasEpsg")) == 0)
440     return true;
441   if (str.CmpNoCase(wxT("hasFreeXL")) == 0)
442     return true;
443   if (str.CmpNoCase(wxT("hasLibXML2")) == 0)
444     return true;
445 
446   if (str.CmpNoCase(wxT("GeometryConstraints")) == 0)
447     return true;
448   if (str.CmpNoCase(wxT("CheckSpatialMetaData")) == 0)
449     return true;
450   if (str.CmpNoCase(wxT("AutoFDOStart")) == 0)
451     return true;
452   if (str.CmpNoCase(wxT("AutoFDOStop")) == 0)
453     return true;
454   if (str.CmpNoCase(wxT("InitFDOSpatialMetaData")) == 0)
455     return true;
456   if (str.CmpNoCase(wxT("AddFDOGeometryColumn")) == 0)
457     return true;
458   if (str.CmpNoCase(wxT("RecoverFDOGeometryColumn")) == 0)
459     return true;
460   if (str.CmpNoCase(wxT("DiscardFDOGeometryColumn")) == 0)
461     return true;
462   if (str.CmpNoCase(wxT("InitSpatialMetaData")) == 0)
463     return true;
464   if (str.CmpNoCase(wxT("AddGeometryColumn")) == 0)
465     return true;
466   if (str.CmpNoCase(wxT("RecoverGeometryColumn")) == 0)
467     return true;
468   if (str.CmpNoCase(wxT("DiscardGeometryColumn")) == 0)
469     return true;
470   if (str.CmpNoCase(wxT("RegisterVirtualGeometry")) == 0)
471     return true;
472   if (str.CmpNoCase(wxT("DropVirtualGeometry")) == 0)
473     return true;
474   if (str.CmpNoCase(wxT("UpdateLayerStatistics")) == 0)
475     return true;
476   if (str.CmpNoCase(wxT("GetLayerExtent")) == 0)
477     return true;
478   if (str.CmpNoCase(wxT("CreateSpatialIndex")) == 0)
479     return true;
480   if (str.CmpNoCase(wxT("CreateMbrCache")) == 0)
481     return true;
482   if (str.CmpNoCase(wxT("DisableSpatialIndex")) == 0)
483     return true;
484   if (str.CmpNoCase(wxT("RebuildGeometryTriggers")) == 0)
485     return true;
486   if (str.CmpNoCase(wxT("CheckSpatialIndex")) == 0)
487     return true;
488   if (str.CmpNoCase(wxT("RecoverSpatialIndex")) == 0)
489     return true;
490   if (str.CmpNoCase(wxT("CreateTopologyTables")) == 0)
491     return true;
492   if (str.CmpNoCase(wxT("CreateStylingTables")) == 0)
493     return true;
494   if (str.CmpNoCase(wxT("RegisterExternalGraphic")) == 0)
495     return true;
496   if (str.CmpNoCase(wxT("RegisterVectorStyledLayer")) == 0)
497     return true;
498   if (str.CmpNoCase(wxT("RegisterRasterStyledLayer")) == 0)
499     return true;
500   if (str.CmpNoCase(wxT("RegisterStyledGroup")) == 0)
501     return true;
502   if (str.CmpNoCase(wxT("SetStyledGroupInfos")) == 0)
503     return true;
504   if (str.CmpNoCase(wxT("CreateIsoMetadataTables")) == 0)
505     return true;
506   if (str.CmpNoCase(wxT("GetIsoMetadataId")) == 0)
507     return true;
508   if (str.CmpNoCase(wxT("RegisterIsoMetadata")) == 0)
509     return true;
510   if (str.CmpNoCase(wxT("XB_LoadXML")) == 0)
511     return true;
512   if (str.CmpNoCase(wxT("XB_StoreXML")) == 0)
513     return true;
514   if (str.CmpNoCase(wxT("CountUnsafeTriggers")) == 0)
515     return true;
516   if (str.CmpNoCase(wxT("CastToInteger")) == 0)
517     return true;
518   if (str.CmpNoCase(wxT("CastToDouble")) == 0)
519     return true;
520   if (str.CmpNoCase(wxT("CastToText")) == 0)
521     return true;
522   if (str.CmpNoCase(wxT("CastToBlob")) == 0)
523     return true;
524   if (str.CmpNoCase(wxT("ForceAsNull")) == 0)
525     return true;
526   if (str.CmpNoCase(wxT("CreateUUID")) == 0)
527     return true;
528   if (str.CmpNoCase(wxT("MD5Checksum")) == 0)
529     return true;
530   if (str.CmpNoCase(wxT("MD5TotalChecksum")) == 0)
531     return true;
532   if (str.CmpNoCase(wxT("CreateRasterCoveragesTable")) == 0)
533     return true;
534 
535   if (str.CmpNoCase(wxT("InsertEpsgSrid")) == 0)
536     return true;
537   if (str.CmpNoCase(wxT("Abs")) == 0)
538     return true;
539   if (str.CmpNoCase(wxT("Acos")) == 0)
540     return true;
541   if (str.CmpNoCase(wxT("Asin")) == 0)
542     return true;
543   if (str.CmpNoCase(wxT("Atan")) == 0)
544     return true;
545   if (str.CmpNoCase(wxT("Ceil")) == 0)
546     return true;
547   if (str.CmpNoCase(wxT("Ceiling")) == 0)
548     return true;
549   if (str.CmpNoCase(wxT("Cos")) == 0)
550     return true;
551   if (str.CmpNoCase(wxT("Cot")) == 0)
552     return true;
553   if (str.CmpNoCase(wxT("Degrees")) == 0)
554     return true;
555   if (str.CmpNoCase(wxT("Exp")) == 0)
556     return true;
557   if (str.CmpNoCase(wxT("Floor")) == 0)
558     return true;
559   if (str.CmpNoCase(wxT("Ln")) == 0)
560     return true;
561   if (str.CmpNoCase(wxT("Log")) == 0)
562     return true;
563   if (str.CmpNoCase(wxT("Log2")) == 0)
564     return true;
565   if (str.CmpNoCase(wxT("Log10")) == 0)
566     return true;
567   if (str.CmpNoCase(wxT("PI")) == 0)
568     return true;
569   if (str.CmpNoCase(wxT("Pow")) == 0)
570     return true;
571   if (str.CmpNoCase(wxT("Power")) == 0)
572     return true;
573   if (str.CmpNoCase(wxT("Radians")) == 0)
574     return true;
575   if (str.CmpNoCase(wxT("Round")) == 0)
576     return true;
577   if (str.CmpNoCase(wxT("Sign")) == 0)
578     return true;
579   if (str.CmpNoCase(wxT("Sin")) == 0)
580     return true;
581   if (str.CmpNoCase(wxT("Sqrt")) == 0)
582     return true;
583   if (str.CmpNoCase(wxT("Stddev_pop")) == 0)
584     return true;
585   if (str.CmpNoCase(wxT("Stddev_samp")) == 0)
586     return true;
587   if (str.CmpNoCase(wxT("Var_pop")) == 0)
588     return true;
589   if (str.CmpNoCase(wxT("Var_samp")) == 0)
590     return true;
591   if (str.CmpNoCase(wxT("Tan")) == 0)
592     return true;
593   if (str.CmpNoCase(wxT("IsZipBlob")) == 0)
594     return true;
595   if (str.CmpNoCase(wxT("IsPdfBlob")) == 0)
596     return true;
597   if (str.CmpNoCase(wxT("IsGifBlob")) == 0)
598     return true;
599   if (str.CmpNoCase(wxT("IsPngBlob")) == 0)
600     return true;
601   if (str.CmpNoCase(wxT("IsTiffBlob")) == 0)
602     return true;
603   if (str.CmpNoCase(wxT("IsWaveletBlob")) == 0)
604     return true;
605   if (str.CmpNoCase(wxT("IsJpegBlob")) == 0)
606     return true;
607   if (str.CmpNoCase(wxT("IsExifBlob")) == 0)
608     return true;
609   if (str.CmpNoCase(wxT("IsExifGpsBlob")) == 0)
610     return true;
611   if (str.CmpNoCase(wxT("IsWebpBlob")) == 0)
612     return true;
613   if (str.CmpNoCase(wxT("GetMimeType")) == 0)
614     return true;
615   if (str.CmpNoCase(wxT("BlobFromFile")) == 0)
616     return true;
617   if (str.CmpNoCase(wxT("BlobToFile")) == 0)
618     return true;
619   if (str.CmpNoCase(wxT("ExportDXF")) == 0)
620     return true;
621   if (str.CmpNoCase(wxT("MakePoint")) == 0)
622     return true;
623   if (str.CmpNoCase(wxT("ST_Point")) == 0)
624     return true;
625   if (str.CmpNoCase(wxT("MakeLine")) == 0)
626     return true;
627   if (str.CmpNoCase(wxT("MakeCircle")) == 0)
628     return true;
629   if (str.CmpNoCase(wxT("MakeEllipse")) == 0)
630     return true;
631   if (str.CmpNoCase(wxT("MakeArc")) == 0)
632     return true;
633   if (str.CmpNoCase(wxT("MakeEllipticArc")) == 0)
634     return true;
635   if (str.CmpNoCase(wxT("MakeCircularSector")) == 0)
636     return true;
637   if (str.CmpNoCase(wxT("MakeCircularStripe")) == 0)
638     return true;
639   if (str.CmpNoCase(wxT("MakeEllipticSector")) == 0)
640     return true;
641   if (str.CmpNoCase(wxT("BuildMbr")) == 0)
642     return true;
643   if (str.CmpNoCase(wxT("BuildCircleMbr")) == 0)
644     return true;
645   if (str.CmpNoCase(wxT("Extent")) == 0)
646     return true;
647   if (str.CmpNoCase(wxT("MbrMinX")) == 0)
648     return true;
649   if (str.CmpNoCase(wxT("MbrMinY")) == 0)
650     return true;
651   if (str.CmpNoCase(wxT("MbrMaxX")) == 0)
652     return true;
653   if (str.CmpNoCase(wxT("MbrMaxY")) == 0)
654     return true;
655   if (str.CmpNoCase(wxT("ST_MbrMinX")) == 0)
656     return true;
657   if (str.CmpNoCase(wxT("ST_MbrMinY")) == 0)
658     return true;
659   if (str.CmpNoCase(wxT("ST_MbrMaxX")) == 0)
660     return true;
661   if (str.CmpNoCase(wxT("ST_MbrMaxY")) == 0)
662     return true;
663   if (str.CmpNoCase(wxT("ST_MinX")) == 0)
664     return true;
665   if (str.CmpNoCase(wxT("ST_MinY")) == 0)
666     return true;
667   if (str.CmpNoCase(wxT("ST_MaxX")) == 0)
668     return true;
669   if (str.CmpNoCase(wxT("ST_MaxY")) == 0)
670     return true;
671   if (str.CmpNoCase(wxT("ST_MinZ")) == 0)
672     return true;
673   if (str.CmpNoCase(wxT("ST_MinM")) == 0)
674     return true;
675   if (str.CmpNoCase(wxT("ST_MaxZ")) == 0)
676     return true;
677   if (str.CmpNoCase(wxT("ST_MaxM")) == 0)
678     return true;
679   if (str.CmpNoCase(wxT("GeomFromText")) == 0)
680     return true;
681   if (str.CmpNoCase(wxT("ST_GeomFromText")) == 0)
682     return true;
683   if (str.CmpNoCase(wxT("ST_WKTToSQL")) == 0)
684     return true;
685   if (str.CmpNoCase(wxT("GeometryFromText")) == 0)
686     return true;
687   if (str.CmpNoCase(wxT("ST_GeometryFromText")) == 0)
688     return true;
689   if (str.CmpNoCase(wxT("PointFromText")) == 0)
690     return true;
691   if (str.CmpNoCase(wxT("ST_PointFromText")) == 0)
692     return true;
693   if (str.CmpNoCase(wxT("LineFromText")) == 0)
694     return true;
695   if (str.CmpNoCase(wxT("ST_LineFromText")) == 0)
696     return true;
697   if (str.CmpNoCase(wxT("LineStringFromText")) == 0)
698     return true;
699   if (str.CmpNoCase(wxT("ST_LineStringFromText")) == 0)
700     return true;
701   if (str.CmpNoCase(wxT("PolyFromText")) == 0)
702     return true;
703   if (str.CmpNoCase(wxT("ST_PolyFromText")) == 0)
704     return true;
705   if (str.CmpNoCase(wxT("PolygonFromText")) == 0)
706     return true;
707   if (str.CmpNoCase(wxT("ST_PolygonFromText")) == 0)
708     return true;
709   if (str.CmpNoCase(wxT("MPointFromText")) == 0)
710     return true;
711   if (str.CmpNoCase(wxT("ST_MPointFromText")) == 0)
712     return true;
713   if (str.CmpNoCase(wxT("MultiPointFromText")) == 0)
714     return true;
715   if (str.CmpNoCase(wxT("ST_MultiPointFromText")) == 0)
716     return true;
717   if (str.CmpNoCase(wxT("MLineFromText")) == 0)
718     return true;
719   if (str.CmpNoCase(wxT("ST_MLineFromText")) == 0)
720     return true;
721   if (str.CmpNoCase(wxT("MultiLineStringFromText")) == 0)
722     return true;
723   if (str.CmpNoCase(wxT("ST_MultiLineStringFromText")) == 0)
724     return true;
725   if (str.CmpNoCase(wxT("MPolyFromText")) == 0)
726     return true;
727   if (str.CmpNoCase(wxT("ST_MPolyFromText")) == 0)
728     return true;
729   if (str.CmpNoCase(wxT("MultiPolygonFromText")) == 0)
730     return true;
731   if (str.CmpNoCase(wxT("ST_MultiPolygonFromText")) == 0)
732     return true;
733   if (str.CmpNoCase(wxT("GeomCollFromText")) == 0)
734     return true;
735   if (str.CmpNoCase(wxT("ST_GeomCollFromText")) == 0)
736     return true;
737   if (str.CmpNoCase(wxT("GeometryCollectionFromText")) == 0)
738     return true;
739   if (str.CmpNoCase(wxT("BdPolyFromText")) == 0)
740     return true;
741   if (str.CmpNoCase(wxT("ST_BdPolyFromText")) == 0)
742     return true;
743   if (str.CmpNoCase(wxT("BdMPolyFromText")) == 0)
744     return true;
745   if (str.CmpNoCase(wxT("ST_BdMPolyFromText")) == 0)
746     return true;
747   if (str.CmpNoCase(wxT("GeometryCollectionFromText")) == 0)
748     return true;
749   if (str.CmpNoCase(wxT("GeomFromWKB")) == 0)
750     return true;
751   if (str.CmpNoCase(wxT("ST_GeomFromWKB")) == 0)
752     return true;
753   if (str.CmpNoCase(wxT("ST_WKBToSQL")) == 0)
754     return true;
755   if (str.CmpNoCase(wxT("PointFromWKB")) == 0)
756     return true;
757   if (str.CmpNoCase(wxT("ST_PointFromWKB")) == 0)
758     return true;
759   if (str.CmpNoCase(wxT("LineFromWKB")) == 0)
760     return true;
761   if (str.CmpNoCase(wxT("ST_LineFromWKB")) == 0)
762     return true;
763   if (str.CmpNoCase(wxT("LineStringFromWKB")) == 0)
764     return true;
765   if (str.CmpNoCase(wxT("ST_LineStringFromWKB")) == 0)
766     return true;
767   if (str.CmpNoCase(wxT("PolyFromWKB")) == 0)
768     return true;
769   if (str.CmpNoCase(wxT("ST_PolyFromWKB")) == 0)
770     return true;
771   if (str.CmpNoCase(wxT("PolygonFromWKB")) == 0)
772     return true;
773   if (str.CmpNoCase(wxT("ST_PolygonFromWKB")) == 0)
774     return true;
775   if (str.CmpNoCase(wxT("MPointFromWKB")) == 0)
776     return true;
777   if (str.CmpNoCase(wxT("ST_MPointFromWKB")) == 0)
778     return true;
779   if (str.CmpNoCase(wxT("MultiPointFromWKB")) == 0)
780     return true;
781   if (str.CmpNoCase(wxT("ST_MultiPointFromWKB")) == 0)
782     return true;
783   if (str.CmpNoCase(wxT("MLineFromWKB")) == 0)
784     return true;
785   if (str.CmpNoCase(wxT("ST_MLineFromWKB")) == 0)
786     return true;
787   if (str.CmpNoCase(wxT("MultiLineStringFromWKB")) == 0)
788     return true;
789   if (str.CmpNoCase(wxT("ST_MultiLineStringFromWKB")) == 0)
790     return true;
791   if (str.CmpNoCase(wxT("MPolyFromWKB")) == 0)
792     return true;
793   if (str.CmpNoCase(wxT("ST_MPolyFromWKB")) == 0)
794     return true;
795   if (str.CmpNoCase(wxT("MultiPolygonFromWKB")) == 0)
796     return true;
797   if (str.CmpNoCase(wxT("ST_MultiPolygonFromWKB")) == 0)
798     return true;
799   if (str.CmpNoCase(wxT("GeomCollFromWKB")) == 0)
800     return true;
801   if (str.CmpNoCase(wxT("ST_GeomCollFromWKB")) == 0)
802     return true;
803   if (str.CmpNoCase(wxT("GeometryCollectionFromWKB")) == 0)
804     return true;
805   if (str.CmpNoCase(wxT("ST_GeometryCollectionFromWKB")) == 0)
806     return true;
807   if (str.CmpNoCase(wxT("BdPolyFromWKB")) == 0)
808     return true;
809   if (str.CmpNoCase(wxT("ST_BdPolyFromWKB")) == 0)
810     return true;
811   if (str.CmpNoCase(wxT("BdMPolyFromWKB")) == 0)
812     return true;
813   if (str.CmpNoCase(wxT("ST_BdMPolyFromWKB")) == 0)
814     return true;
815   if (str.CmpNoCase(wxT("AsText")) == 0)
816     return true;
817   if (str.CmpNoCase(wxT("ST_AsText")) == 0)
818     return true;
819   if (str.CmpNoCase(wxT("AsWKT")) == 0)
820     return true;
821   if (str.CmpNoCase(wxT("AsSVG")) == 0)
822     return true;
823   if (str.CmpNoCase(wxT("AsKML")) == 0)
824     return true;
825   if (str.CmpNoCase(wxT("GeomFromKML")) == 0)
826     return true;
827   if (str.CmpNoCase(wxT("AsGML")) == 0)
828     return true;
829   if (str.CmpNoCase(wxT("GeomFromGML")) == 0)
830     return true;
831   if (str.CmpNoCase(wxT("AsGeoJSON")) == 0)
832     return true;
833   if (str.CmpNoCase(wxT("GeomFromGeoJSON")) == 0)
834     return true;
835   if (str.CmpNoCase(wxT("AsFGF")) == 0)
836     return true;
837   if (str.CmpNoCase(wxT("AsBinary")) == 0)
838     return true;
839   if (str.CmpNoCase(wxT("ST_AsBinary")) == 0)
840     return true;
841   if (str.CmpNoCase(wxT("GeomFromFGF")) == 0)
842     return true;
843   if (str.CmpNoCase(wxT("AsEWKB")) == 0)
844     return true;
845   if (str.CmpNoCase(wxT("GeomFromEWKB")) == 0)
846     return true;
847   if (str.CmpNoCase(wxT("AsEWKT")) == 0)
848     return true;
849   if (str.CmpNoCase(wxT("GeomFromEWKT")) == 0)
850     return true;
851   if (str.CmpNoCase(wxT("CompressGeometry")) == 0)
852     return true;
853   if (str.CmpNoCase(wxT("UncompressGeometry")) == 0)
854     return true;
855   if (str.CmpNoCase(wxT("SanitizeGeometry")) == 0)
856     return true;
857   if (str.CmpNoCase(wxT("CastToPoint")) == 0)
858     return true;
859   if (str.CmpNoCase(wxT("CastToLinestring")) == 0)
860     return true;
861   if (str.CmpNoCase(wxT("CastToPolygon")) == 0)
862     return true;
863   if (str.CmpNoCase(wxT("CastToMultiPoint")) == 0)
864     return true;
865   if (str.CmpNoCase(wxT("CastToMultiLinestring")) == 0)
866     return true;
867   if (str.CmpNoCase(wxT("CastToMultiPolygon")) == 0)
868     return true;
869   if (str.CmpNoCase(wxT("CastToGeometryCollection")) == 0)
870     return true;
871   if (str.CmpNoCase(wxT("CastToMulti")) == 0)
872     return true;
873   if (str.CmpNoCase(wxT("ST_Multi")) == 0)
874     return true;
875   if (str.CmpNoCase(wxT("CastToSingle")) == 0)
876     return true;
877   if (str.CmpNoCase(wxT("CastToXY")) == 0)
878     return true;
879   if (str.CmpNoCase(wxT("CastToXYZ")) == 0)
880     return true;
881   if (str.CmpNoCase(wxT("CastToXYM")) == 0)
882     return true;
883   if (str.CmpNoCase(wxT("CastToXYZM")) == 0)
884     return true;
885   if (str.CmpNoCase(wxT("ST_Reverse")) == 0)
886     return true;
887   if (str.CmpNoCase(wxT("ST_ForceLHR")) == 0)
888     return true;
889   if (str.CmpNoCase(wxT("Dimension")) == 0)
890     return true;
891   if (str.CmpNoCase(wxT("ST_Dimension")) == 0)
892     return true;
893   if (str.CmpNoCase(wxT("CoordDimension")) == 0)
894     return true;
895   if (str.CmpNoCase(wxT("ST_NDims")) == 0)
896     return true;
897   if (str.CmpNoCase(wxT("ST_Is3D")) == 0)
898     return true;
899   if (str.CmpNoCase(wxT("ST_IsMeasured")) == 0)
900     return true;
901   if (str.CmpNoCase(wxT("GeometryType")) == 0)
902     return true;
903   if (str.CmpNoCase(wxT("GeometryAliasType")) == 0)
904     return true;
905   if (str.CmpNoCase(wxT("ST_GeometryType")) == 0)
906     return true;
907   if (str.CmpNoCase(wxT("SRID")) == 0)
908     return true;
909   if (str.CmpNoCase(wxT("ST_SRID")) == 0)
910     return true;
911   if (str.CmpNoCase(wxT("SetSRID")) == 0)
912     return true;
913   if (str.CmpNoCase(wxT("ToGARS")) == 0)
914     return true;
915   if (str.CmpNoCase(wxT("GARSMbr")) == 0)
916     return true;
917   if (str.CmpNoCase(wxT("IsEmpty")) == 0)
918     return true;
919   if (str.CmpNoCase(wxT("ST_IsEmpty")) == 0)
920     return true;
921   if (str.CmpNoCase(wxT("IsSimple")) == 0)
922     return true;
923   if (str.CmpNoCase(wxT("ST_IsSimple")) == 0)
924     return true;
925   if (str.CmpNoCase(wxT("IsValid")) == 0)
926     return true;
927   if (str.CmpNoCase(wxT("ST_IsValid")) == 0)
928     return true;
929   if (str.CmpNoCase(wxT("Boundary")) == 0)
930     return true;
931   if (str.CmpNoCase(wxT("ST_Boundary")) == 0)
932     return true;
933   if (str.CmpNoCase(wxT("Envelope")) == 0)
934     return true;
935   if (str.CmpNoCase(wxT("ST_Envelope")) == 0)
936     return true;
937   if (str.CmpNoCase(wxT("ST_Expand")) == 0)
938     return true;
939   if (str.CmpNoCase(wxT("X")) == 0)
940     return true;
941   if (str.CmpNoCase(wxT("ST_X")) == 0)
942     return true;
943   if (str.CmpNoCase(wxT("Y")) == 0)
944     return true;
945   if (str.CmpNoCase(wxT("ST_Y")) == 0)
946     return true;
947   if (str.CmpNoCase(wxT("Z")) == 0)
948     return true;
949   if (str.CmpNoCase(wxT("ST_Z")) == 0)
950     return true;
951   if (str.CmpNoCase(wxT("M")) == 0)
952     return true;
953   if (str.CmpNoCase(wxT("ST_M")) == 0)
954     return true;
955   if (str.CmpNoCase(wxT("StartPoint")) == 0)
956     return true;
957   if (str.CmpNoCase(wxT("ST_StartPoint")) == 0)
958     return true;
959   if (str.CmpNoCase(wxT("EndPoint")) == 0)
960     return true;
961   if (str.CmpNoCase(wxT("ST_EndPoint")) == 0)
962     return true;
963   if (str.CmpNoCase(wxT("GLength")) == 0)
964     return true;
965   if (str.CmpNoCase(wxT("ST_Length")) == 0)
966     return true;
967   if (str.CmpNoCase(wxT("Perimeter")) == 0)
968     return true;
969   if (str.CmpNoCase(wxT("ST_Perimeter")) == 0)
970     return true;
971   if (str.CmpNoCase(wxT("IsClosed")) == 0)
972     return true;
973   if (str.CmpNoCase(wxT("ST_IsClosed")) == 0)
974     return true;
975   if (str.CmpNoCase(wxT("IsRing")) == 0)
976     return true;
977   if (str.CmpNoCase(wxT("ST_IsRing")) == 0)
978     return true;
979   if (str.CmpNoCase(wxT("Simplify")) == 0)
980     return true;
981   if (str.CmpNoCase(wxT("ST_Simplify")) == 0)
982     return true;
983   if (str.CmpNoCase(wxT("ST_Generalize")) == 0)
984     return true;
985   if (str.CmpNoCase(wxT("SimplifyPreserveTopology")) == 0)
986     return true;
987   if (str.CmpNoCase(wxT("ST_SimplifyPreserveTopology")) == 0)
988     return true;
989   if (str.CmpNoCase(wxT("GeodesicLength")) == 0)
990     return true;
991   if (str.CmpNoCase(wxT("GreatCircleLength")) == 0)
992     return true;
993   if (str.CmpNoCase(wxT("NumPoints")) == 0)
994     return true;
995   if (str.CmpNoCase(wxT("ST_NumPoints")) == 0)
996     return true;
997   if (str.CmpNoCase(wxT("PointN")) == 0)
998     return true;
999   if (str.CmpNoCase(wxT("ST_PointN")) == 0)
1000     return true;
1001   if (str.CmpNoCase(wxT("Centroid")) == 0)
1002     return true;
1003   if (str.CmpNoCase(wxT("ST_Centroid")) == 0)
1004     return true;
1005   if (str.CmpNoCase(wxT("PointOnSurface")) == 0)
1006     return true;
1007   if (str.CmpNoCase(wxT("ST_PointOnSurface")) == 0)
1008     return true;
1009   if (str.CmpNoCase(wxT("Area")) == 0)
1010     return true;
1011   if (str.CmpNoCase(wxT("ST_Area")) == 0)
1012     return true;
1013   if (str.CmpNoCase(wxT("ExteriorRing")) == 0)
1014     return true;
1015   if (str.CmpNoCase(wxT("ST_ExteriorRing")) == 0)
1016     return true;
1017   if (str.CmpNoCase(wxT("NumInteriorRing")) == 0)
1018     return true;
1019   if (str.CmpNoCase(wxT("ST_NumInteriorRing")) == 0)
1020     return true;
1021   if (str.CmpNoCase(wxT("NumInteriorRings")) == 0)
1022     return true;
1023   if (str.CmpNoCase(wxT("InteriorRingN")) == 0)
1024     return true;
1025   if (str.CmpNoCase(wxT("ST_InteriorRingN")) == 0)
1026     return true;
1027   if (str.CmpNoCase(wxT("NumGeometries")) == 0)
1028     return true;
1029   if (str.CmpNoCase(wxT("ST_NumGeometries")) == 0)
1030     return true;
1031   if (str.CmpNoCase(wxT("ST_NPoints")) == 0)
1032     return true;
1033   if (str.CmpNoCase(wxT("ST_NRings")) == 0)
1034     return true;
1035   if (str.CmpNoCase(wxT("GeometryN")) == 0)
1036     return true;
1037   if (str.CmpNoCase(wxT("ST_GeometryN")) == 0)
1038     return true;
1039   if (str.CmpNoCase(wxT("AddPoint")) == 0)
1040     return true;
1041   if (str.CmpNoCase(wxT("ST_AddPoint")) == 0)
1042     return true;
1043   if (str.CmpNoCase(wxT("RemovePoint")) == 0)
1044     return true;
1045   if (str.CmpNoCase(wxT("ST_RemovePoint")) == 0)
1046     return true;
1047   if (str.CmpNoCase(wxT("SetPoint")) == 0)
1048     return true;
1049   if (str.CmpNoCase(wxT("ST_SetPoint")) == 0)
1050     return true;
1051   if (str.CmpNoCase(wxT("MbrEqual")) == 0)
1052     return true;
1053   if (str.CmpNoCase(wxT("MbrDisjoint")) == 0)
1054     return true;
1055   if (str.CmpNoCase(wxT("MbrTouches")) == 0)
1056     return true;
1057   if (str.CmpNoCase(wxT("MbrWithin")) == 0)
1058     return true;
1059   if (str.CmpNoCase(wxT("MbrOverlaps")) == 0)
1060     return true;
1061   if (str.CmpNoCase(wxT("MbrIntersects")) == 0)
1062     return true;
1063   if (str.CmpNoCase(wxT("ST_EnvIntersects")) == 0)
1064     return true;
1065   if (str.CmpNoCase(wxT("ST_EnvelopesIntersects")) == 0)
1066     return true;
1067   if (str.CmpNoCase(wxT("MbrContains")) == 0)
1068     return true;
1069   if (str.CmpNoCase(wxT("Equals")) == 0)
1070     return true;
1071   if (str.CmpNoCase(wxT("ST_Equals")) == 0)
1072     return true;
1073   if (str.CmpNoCase(wxT("Disjoint")) == 0)
1074     return true;
1075   if (str.CmpNoCase(wxT("ST_Disjoint")) == 0)
1076     return true;
1077   if (str.CmpNoCase(wxT("Touches")) == 0)
1078     return true;
1079   if (str.CmpNoCase(wxT("ST_Touches")) == 0)
1080     return true;
1081   if (str.CmpNoCase(wxT("Within")) == 0)
1082     return true;
1083   if (str.CmpNoCase(wxT("ST_Within")) == 0)
1084     return true;
1085   if (str.CmpNoCase(wxT("Overlaps")) == 0)
1086     return true;
1087   if (str.CmpNoCase(wxT("ST_Overlaps")) == 0)
1088     return true;
1089   if (str.CmpNoCase(wxT("Crosses")) == 0)
1090     return true;
1091   if (str.CmpNoCase(wxT("ST_Crosses")) == 0)
1092     return true;
1093   if (str.CmpNoCase(wxT("Intersects")) == 0)
1094     return true;
1095   if (str.CmpNoCase(wxT("ST_Intersects")) == 0)
1096     return true;
1097   if (str.CmpNoCase(wxT("Contains")) == 0)
1098     return true;
1099   if (str.CmpNoCase(wxT("ST_Contains")) == 0)
1100     return true;
1101   if (str.CmpNoCase(wxT("Covers")) == 0)
1102     return true;
1103   if (str.CmpNoCase(wxT("ST_Covers")) == 0)
1104     return true;
1105   if (str.CmpNoCase(wxT("CoveredBy")) == 0)
1106     return true;
1107   if (str.CmpNoCase(wxT("ST_CoveredBy")) == 0)
1108     return true;
1109   if (str.CmpNoCase(wxT("OffsetCurve")) == 0)
1110     return true;
1111   if (str.CmpNoCase(wxT("ST_OffsetCurve")) == 0)
1112     return true;
1113   if (str.CmpNoCase(wxT("SingleSidedBuffer")) == 0)
1114     return true;
1115   if (str.CmpNoCase(wxT("ST_SingleSidedBuffer")) == 0)
1116     return true;
1117   if (str.CmpNoCase(wxT("SharedPaths")) == 0)
1118     return true;
1119   if (str.CmpNoCase(wxT("ST_SharedPaths")) == 0)
1120     return true;
1121   if (str.CmpNoCase(wxT("Relate")) == 0)
1122     return true;
1123   if (str.CmpNoCase(wxT("ST_Relate")) == 0)
1124     return true;
1125   if (str.CmpNoCase(wxT("Distance")) == 0)
1126     return true;
1127   if (str.CmpNoCase(wxT("ST_Distance")) == 0)
1128     return true;
1129   if (str.CmpNoCase(wxT("HausdorffDistance")) == 0)
1130     return true;
1131   if (str.CmpNoCase(wxT("ST_HausdorffDistance")) == 0)
1132     return true;
1133   if (str.CmpNoCase(wxT("PtDistWithin")) == 0)
1134     return true;
1135   if (str.CmpNoCase(wxT("Intersection")) == 0)
1136     return true;
1137   if (str.CmpNoCase(wxT("ST_Intersection")) == 0)
1138     return true;
1139   if (str.CmpNoCase(wxT("Difference")) == 0)
1140     return true;
1141   if (str.CmpNoCase(wxT("ST_Difference")) == 0)
1142     return true;
1143   if (str.CmpNoCase(wxT("GUnion")) == 0)
1144     return true;
1145   if (str.CmpNoCase(wxT("ST_Union")) == 0)
1146     return true;
1147   if (str.CmpNoCase(wxT("SymDifference")) == 0)
1148     return true;
1149   if (str.CmpNoCase(wxT("ST_SymDifference")) == 0)
1150     return true;
1151   if (str.CmpNoCase(wxT("Buffer")) == 0)
1152     return true;
1153   if (str.CmpNoCase(wxT("ST_Buffer")) == 0)
1154     return true;
1155   if (str.CmpNoCase(wxT("ConvexHull")) == 0)
1156     return true;
1157   if (str.CmpNoCase(wxT("ST_ConvexHull")) == 0)
1158     return true;
1159   if (str.CmpNoCase(wxT("Transform")) == 0)
1160     return true;
1161   if (str.CmpNoCase(wxT("ST_Transform")) == 0)
1162     return true;
1163   if (str.CmpNoCase(wxT("ST_Shift_Longitude")) == 0)
1164     return true;
1165   if (str.CmpNoCase(wxT("NormalizeLonLat")) == 0)
1166     return true;
1167   if (str.CmpNoCase(wxT("Line_Interpolate_Point")) == 0)
1168     return true;
1169   if (str.CmpNoCase(wxT("ST_Line_Interpolate_Point")) == 0)
1170     return true;
1171   if (str.CmpNoCase(wxT("Line_Interpolate_Equidistant_Points")) == 0)
1172     return true;
1173   if (str.CmpNoCase(wxT("ST_Line_Interpolate_Equidistant_Points")) == 0)
1174     return true;
1175   if (str.CmpNoCase(wxT("Line_Locate_Point")) == 0)
1176     return true;
1177   if (str.CmpNoCase(wxT("ST_Line_Locate_Point")) == 0)
1178     return true;
1179   if (str.CmpNoCase(wxT("Line_Substring")) == 0)
1180     return true;
1181   if (str.CmpNoCase(wxT("ST_Line_Substring")) == 0)
1182     return true;
1183   if (str.CmpNoCase(wxT("ClosestPoint")) == 0)
1184     return true;
1185   if (str.CmpNoCase(wxT("ST_ClosestPoint")) == 0)
1186     return true;
1187   if (str.CmpNoCase(wxT("ShortestLine")) == 0)
1188     return true;
1189   if (str.CmpNoCase(wxT("ST_ShortestLine")) == 0)
1190     return true;
1191   if (str.CmpNoCase(wxT("Snap")) == 0)
1192     return true;
1193   if (str.CmpNoCase(wxT("ST_Snap")) == 0)
1194     return true;
1195   if (str.CmpNoCase(wxT("Collect")) == 0)
1196     return true;
1197   if (str.CmpNoCase(wxT("ST_Collect")) == 0)
1198     return true;
1199   if (str.CmpNoCase(wxT("LineMerge")) == 0)
1200     return true;
1201   if (str.CmpNoCase(wxT("ST_LineMerge")) == 0)
1202     return true;
1203   if (str.CmpNoCase(wxT("BuildArea")) == 0)
1204     return true;
1205   if (str.CmpNoCase(wxT("ST_BuildArea")) == 0)
1206     return true;
1207   if (str.CmpNoCase(wxT("Polygonize")) == 0)
1208     return true;
1209   if (str.CmpNoCase(wxT("ST_Polygonize")) == 0)
1210     return true;
1211   if (str.CmpNoCase(wxT("UnaryUnion")) == 0)
1212     return true;
1213   if (str.CmpNoCase(wxT("ST_UnaryUnion")) == 0)
1214     return true;
1215   if (str.CmpNoCase(wxT("DissolveSegments")) == 0)
1216     return true;
1217   if (str.CmpNoCase(wxT("ST_DissolveSegments")) == 0)
1218     return true;
1219   if (str.CmpNoCase(wxT("DissolvePoints")) == 0)
1220     return true;
1221   if (str.CmpNoCase(wxT("ST_DissolvePoints")) == 0)
1222     return true;
1223   if (str.CmpNoCase(wxT("LinesFromRings")) == 0)
1224     return true;
1225   if (str.CmpNoCase(wxT("ST_LinesFromRings")) == 0)
1226     return true;
1227   if (str.CmpNoCase(wxT("RingsCutAtNodes")) == 0)
1228     return true;
1229   if (str.CmpNoCase(wxT("ST_RingsCutAtNodes")) == 0)
1230     return true;
1231   if (str.CmpNoCase(wxT("LinesCutAtNodes")) == 0)
1232     return true;
1233   if (str.CmpNoCase(wxT("ST_LinesCutAtNodes")) == 0)
1234     return true;
1235   if (str.CmpNoCase(wxT("CollectionExtract")) == 0)
1236     return true;
1237   if (str.CmpNoCase(wxT("ST_CollectionExtract")) == 0)
1238     return true;
1239   if (str.CmpNoCase(wxT("ST_Locate_Along_Measure")) == 0)
1240     return true;
1241   if (str.CmpNoCase(wxT("ST_Locate_Between_Measures")) == 0)
1242     return true;
1243   if (str.CmpNoCase(wxT("SquareGrid")) == 0)
1244     return true;
1245   if (str.CmpNoCase(wxT("ST_SquareGrid")) == 0)
1246     return true;
1247   if (str.CmpNoCase(wxT("TriangularGrid")) == 0)
1248     return true;
1249   if (str.CmpNoCase(wxT("ST_TriangularGrid")) == 0)
1250     return true;
1251   if (str.CmpNoCase(wxT("HexagonalGrid")) == 0)
1252     return true;
1253   if (str.CmpNoCase(wxT("ST_HexagonalGrid")) == 0)
1254     return true;
1255   if (str.CmpNoCase(wxT("DelaunayTriangulation")) == 0)
1256     return true;
1257   if (str.CmpNoCase(wxT("ST_DelaunayTriangulation")) == 0)
1258     return true;
1259   if (str.CmpNoCase(wxT("VoronojDiagram")) == 0)
1260     return true;
1261   if (str.CmpNoCase(wxT("ST_VoronojDiagram")) == 0)
1262     return true;
1263   if (str.CmpNoCase(wxT("ConcaveHull")) == 0)
1264     return true;
1265   if (str.CmpNoCase(wxT("ST_ConcaveHull")) == 0)
1266     return true;
1267   if (str.CmpNoCase(wxT("MakeValid")) == 0)
1268     return true;
1269   if (str.CmpNoCase(wxT("ST_MakeValid")) == 0)
1270     return true;
1271   if (str.CmpNoCase(wxT("MakeValidDiscarded")) == 0)
1272     return true;
1273   if (str.CmpNoCase(wxT("ST_MakeValidDiscarded")) == 0)
1274     return true;
1275   if (str.CmpNoCase(wxT("Segmentize")) == 0)
1276     return true;
1277   if (str.CmpNoCase(wxT("ST_Segmentize")) == 0)
1278     return true;
1279   if (str.CmpNoCase(wxT("Split")) == 0)
1280     return true;
1281   if (str.CmpNoCase(wxT("ST_Split")) == 0)
1282     return true;
1283   if (str.CmpNoCase(wxT("SplitLeft")) == 0)
1284     return true;
1285   if (str.CmpNoCase(wxT("ST_SplitLeft")) == 0)
1286     return true;
1287   if (str.CmpNoCase(wxT("SplitRight")) == 0)
1288     return true;
1289   if (str.CmpNoCase(wxT("ST_SplitRight")) == 0)
1290     return true;
1291   if (str.CmpNoCase(wxT("Azimuth")) == 0)
1292     return true;
1293   if (str.CmpNoCase(wxT("ST_Azimuth")) == 0)
1294     return true;
1295   if (str.CmpNoCase(wxT("Project")) == 0)
1296     return true;
1297   if (str.CmpNoCase(wxT("ST_Project")) == 0)
1298     return true;
1299   if (str.CmpNoCase(wxT("GeoHash")) == 0)
1300     return true;
1301   if (str.CmpNoCase(wxT("ST_GeoHash")) == 0)
1302     return true;
1303   if (str.CmpNoCase(wxT("AsX3D")) == 0)
1304     return true;
1305   if (str.CmpNoCase(wxT("ST_AsX3D")) == 0)
1306     return true;
1307   if (str.CmpNoCase(wxT("ST_3DDistance")) == 0)
1308     return true;
1309   if (str.CmpNoCase(wxT("ST_3DMaxDistance")) == 0)
1310     return true;
1311   if (str.CmpNoCase(wxT("MaxDistance")) == 0)
1312     return true;
1313   if (str.CmpNoCase(wxT("ST_MaxDistance")) == 0)
1314     return true;
1315   if (str.CmpNoCase(wxT("SnapToGrid")) == 0)
1316     return true;
1317   if (str.CmpNoCase(wxT("ST_SnapToGrid")) == 0)
1318     return true;
1319   if (str.CmpNoCase(wxT("SridFromAuthCRS")) == 0)
1320     return true;
1321   if (str.CmpNoCase(wxT("ShiftCoords")) == 0)
1322     return true;
1323   if (str.CmpNoCase(wxT("ShiftCoordinates")) == 0)
1324     return true;
1325   if (str.CmpNoCase(wxT("ST_Translate")) == 0)
1326     return true;
1327   if (str.CmpNoCase(wxT("ScaleCoords")) == 0)
1328     return true;
1329   if (str.CmpNoCase(wxT("ScaleCoordinates")) == 0)
1330     return true;
1331   if (str.CmpNoCase(wxT("RotateCoords")) == 0)
1332     return true;
1333   if (str.CmpNoCase(wxT("RotateCoordinates")) == 0)
1334     return true;
1335   if (str.CmpNoCase(wxT("ReflectCoords")) == 0)
1336     return true;
1337   if (str.CmpNoCase(wxT("ReflectCoordinates")) == 0)
1338     return true;
1339   if (str.CmpNoCase(wxT("SwapCoords")) == 0)
1340     return true;
1341   if (str.CmpNoCase(wxT("SwapCoordinates")) == 0)
1342     return true;
1343   if (str.CmpNoCase(wxT("FilterMbrWithin")) == 0)
1344     return true;
1345   if (str.CmpNoCase(wxT("FilterMbrContains")) == 0)
1346     return true;
1347   if (str.CmpNoCase(wxT("FilterMbrIntersects")) == 0)
1348     return true;
1349   if (str.CmpNoCase(wxT("BuildMbrFilter")) == 0)
1350     return true;
1351   if (str.CmpNoCase(wxT("RTreeWithin")) == 0)
1352     return true;
1353   if (str.CmpNoCase(wxT("RTreeContains")) == 0)
1354     return true;
1355   if (str.CmpNoCase(wxT("RTreeIntersects")) == 0)
1356     return true;
1357   if (str.CmpNoCase(wxT("RTreeDistWithin")) == 0)
1358     return true;
1359   if (str.CmpNoCase(wxT("XB_Create")) == 0)
1360     return true;
1361   if (str.CmpNoCase(wxT("XB_GetPayload")) == 0)
1362     return true;
1363   if (str.CmpNoCase(wxT("XB_GetDocument")) == 0)
1364     return true;
1365   if (str.CmpNoCase(wxT("XB_IsValid")) == 0)
1366     return true;
1367   if (str.CmpNoCase(wxT("XB_SchemaValidate")) == 0)
1368     return true;
1369   if (str.CmpNoCase(wxT("XB_IsCompressed")) == 0)
1370     return true;
1371   if (str.CmpNoCase(wxT("XB_IsIsoMetadata")) == 0)
1372     return true;
1373   if (str.CmpNoCase(wxT("XB_IsSldSeVectorStyle")) == 0)
1374     return true;
1375   if (str.CmpNoCase(wxT("XB_IsSldSeRasterStyle")) == 0)
1376     return true;
1377   if (str.CmpNoCase(wxT("XB_IsSvg")) == 0)
1378     return true;
1379   if (str.CmpNoCase(wxT("XB_Compress")) == 0)
1380     return true;
1381   if (str.CmpNoCase(wxT("XB_Uncompress")) == 0)
1382     return true;
1383   if (str.CmpNoCase(wxT("XB_IsSchemaValidated")) == 0)
1384     return true;
1385   if (str.CmpNoCase(wxT("XB_GetSchemaURI")) == 0)
1386     return true;
1387   if (str.CmpNoCase(wxT("XB_GetInternalSchemaURI")) == 0)
1388     return true;
1389   if (str.CmpNoCase(wxT("XB_GetFileId")) == 0)
1390     return true;
1391   if (str.CmpNoCase(wxT("XB_SetFileId")) == 0)
1392     return true;
1393   if (str.CmpNoCase(wxT("XB_AddFileId")) == 0)
1394     return true;
1395   if (str.CmpNoCase(wxT("XB_GetParentId")) == 0)
1396     return true;
1397   if (str.CmpNoCase(wxT("XB_SetParentId")) == 0)
1398     return true;
1399   if (str.CmpNoCase(wxT("XB_AddParentId")) == 0)
1400     return true;
1401   if (str.CmpNoCase(wxT("XB_GetTitle")) == 0)
1402     return true;
1403   if (str.CmpNoCase(wxT("XB_GetAbstract")) == 0)
1404     return true;
1405   if (str.CmpNoCase(wxT("XB_GetGeometry")) == 0)
1406     return true;
1407   if (str.CmpNoCase(wxT("XB_GetDocumentSize")) == 0)
1408     return true;
1409   if (str.CmpNoCase(wxT("XB_GetEncoding")) == 0)
1410     return true;
1411   if (str.CmpNoCase(wxT("XB_GetLastParseError")) == 0)
1412     return true;
1413   if (str.CmpNoCase(wxT("XB_IsValidXPathExpression")) == 0)
1414     return true;
1415   if (str.CmpNoCase(wxT("XB_GetLastValidateError")) == 0)
1416     return true;
1417   if (str.CmpNoCase(wxT("XB_GetLastXPathError")) == 0)
1418     return true;
1419   if (str.CmpNoCase(wxT("XB_CacheFlush")) == 0)
1420     return true;
1421   return false;
1422 }
1423 
DoSqlSyntaxColor()1424 void MyQueryView::DoSqlSyntaxColor()
1425 {
1426 //
1427 // evidencing a nice colored SQL syntax
1428 //
1429   IgnoreEvent = true;
1430   SqlCtrl->Hide();
1431   wxTextAttr normal_style(wxColour(128, 128, 128), wxColour(255, 255, 255),
1432                           wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL,
1433                                  wxFONTWEIGHT_NORMAL));
1434   wxTextAttr sql_style(wxColour(0, 0, 255), wxColour(255, 255, 255),
1435                        wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL,
1436                               wxFONTWEIGHT_BOLD));
1437   wxTextAttr const_style(wxColour(255, 0, 255), wxColour(255, 255, 255),
1438                          wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL,
1439                                 wxFONTWEIGHT_NORMAL));
1440   wxTextAttr fnct_style(wxColour(192, 128, 0), wxColour(255, 255, 255),
1441                         wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL,
1442                                wxFONTWEIGHT_BOLD));
1443   wxTextAttr bracket_style(wxColour(255, 0, 0), wxColour(192, 192, 192),
1444                            wxFont(12, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL,
1445                                   wxFONTWEIGHT_BOLD));
1446   wxString sql = SqlCtrl->GetValue();
1447 // setting the base style
1448   SqlCtrl->SetStyle(0, sql.Len(), normal_style);
1449   wxString right = sql;
1450   int from;
1451   int to = 0;
1452   int i;
1453   char c;
1454   char next_c;
1455   SqlTokenizer tokenizer(sql);
1456   while (tokenizer.HasMoreTokens())
1457     {
1458       wxString token = tokenizer.GetNextToken();
1459       from = to + right.Find(token);
1460       to = from + token.Len();
1461       // extracting the unparsed portion of the SQL string
1462       right = sql.Mid(to);
1463       next_c = '\0';
1464       for (i = 0; i < (int) right.Len(); i++)
1465         {
1466           c = right.GetChar(i);
1467           if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
1468             continue;
1469           next_c = c;
1470           break;
1471         }
1472       char word[4096];
1473       strcpy(word, token.ToUTF8());
1474       if (gaiaIsReservedSqliteName(word))
1475         {
1476           // setting the SQL keyword style
1477           SqlCtrl->SetStyle(from, to, sql_style);
1478       } else if (IsSqliteExtra(token))
1479         {
1480           // setting the SQL keyword style
1481           SqlCtrl->SetStyle(from, to, sql_style);
1482       } else if (IsSqlString(token) == true)
1483         {
1484           // setting the SQL string constant style
1485           SqlCtrl->SetStyle(from, to, const_style);
1486       } else if (IsSqlNumber(token) == true)
1487         {
1488           // setting the SQL numeric constant style
1489           SqlCtrl->SetStyle(from, to, const_style);
1490       } else if (IsSqlFunction(token, next_c) == true)
1491         {
1492           // setting the SQL function style
1493           SqlCtrl->SetStyle(from, to, fnct_style);
1494       } else if (IsSqlGeoFunction(token, next_c) == true)
1495         {
1496           // setting the SQL geo-function style
1497           SqlCtrl->SetStyle(from, to, fnct_style);
1498         }
1499     }
1500   if (BracketStart >= 0)
1501     {
1502       // evidencing an opening bracket
1503       SqlCtrl->SetStyle(BracketStart, BracketStart + 1, bracket_style);
1504     }
1505   if (BracketEnd >= 0)
1506     {
1507       // evidencing a closing bracket
1508       SqlCtrl->SetStyle(BracketEnd, BracketEnd + 1, bracket_style);
1509     }
1510   SqlCtrl->Show();
1511   SqlCtrl->SetFocus();
1512   IgnoreEvent = false;
1513 }
1514 
OnSqlSyntaxColor(wxCommandEvent & event)1515 void MyQueryView::OnSqlSyntaxColor(wxCommandEvent & event)
1516 {
1517 //
1518 // EVENT: updating the SQL syntax
1519 //
1520   if (IgnoreEvent == true)
1521     {
1522       // processing is still in progress; ignoring any internally generated call
1523       return;
1524     }
1525   event.Skip();
1526   EventBrackets();
1527 }
1528 
EvidBrackets(int on,int off)1529 void MyQueryView::EvidBrackets(int on, int off)
1530 {
1531 // evidencing corresponding brackets [open/close]
1532   BracketStart = -1;
1533   BracketEnd = -1;
1534   if (on >= 0)
1535     BracketStart = on;
1536   if (off >= 0)
1537     BracketEnd = off;
1538   DoSqlSyntaxColor();
1539 }
1540 
EventBrackets()1541 void MyQueryView::EventBrackets()
1542 {
1543 //
1544 // evidencing brackets [balancing open-close pairs]
1545 //
1546   if (IgnoreEvent == true)
1547     {
1548       // processing is still in progress; ignoring any internally generated call
1549       return;
1550     }
1551   int pos = SqlCtrl->GetInsertionPoint();
1552   int on;
1553   int off;
1554   wxString sql = SqlCtrl->GetValue();
1555   char pre = '\0';
1556   char post = '\0';
1557   if (pos > 0)
1558     pre = sql.GetChar(pos - 1);
1559   if (pos < (int) sql.Len())
1560     post = sql.GetChar(pos);
1561   if (post == '(')
1562     {
1563       // positioned before an opening bracket
1564       if (CheckBrackets(pos, false, &on, &off) == true)
1565         EvidBrackets(on, off);
1566       else
1567         EvidBrackets(pos, -1);
1568       return;
1569     }
1570   if (pre == ')')
1571     {
1572       // positioned after a closing bracket
1573       if (CheckBrackets(pos - 1, true, &on, &off) == true)
1574         EvidBrackets(on, off);
1575       else
1576         EvidBrackets(-1, pos - 1);
1577       return;
1578     }
1579   EvidBrackets(-1, -1);
1580 }
1581 
CheckBrackets(int pos,bool reverse_direction,int * on,int * off)1582 bool MyQueryView::CheckBrackets(int pos, bool reverse_direction, int *on,
1583                                 int *off)
1584 {
1585 // trying to balance a brackets pair [opening/closing]
1586   int i;
1587   int len;
1588   int level = 0;
1589   char c;
1590   int single_quoted = 0;
1591   int double_quoted = 0;
1592   wxString sql = SqlCtrl->GetValue();
1593   if (reverse_direction == true)
1594     {
1595       // going backward from CLOSE to OPEN
1596       for (i = pos - 1; i >= 0; i--)
1597         {
1598           c = sql.GetChar(i);
1599           if (c == '\'' && !double_quoted)
1600             {
1601               // single quoting start-stop
1602               if (single_quoted)
1603                 single_quoted = 0;
1604               else
1605                 single_quoted = 1;
1606             }
1607           if (c == '"' && !single_quoted)
1608             {
1609               // double quoting start-stop
1610               if (double_quoted)
1611                 double_quoted = 0;
1612               else
1613                 double_quoted = 1;
1614             }
1615           if (single_quoted || double_quoted)
1616             continue;
1617           if (c == ')')
1618             level++;
1619           if (c == '(')
1620             {
1621               if (level == 0)
1622                 {
1623                   *on = i;
1624                   *off = pos;
1625                   return true;
1626                 }
1627               level--;
1628             }
1629         }
1630   } else
1631     {
1632       // going forward from OPEN to CLOSE
1633       len = sql.Len();
1634       for (i = pos + 1; i < len; i++)
1635         {
1636           c = sql.GetChar(i);
1637           if (c == '\'' && !double_quoted)
1638             {
1639               // single quoting start-stop
1640               if (single_quoted)
1641                 single_quoted = 0;
1642               else
1643                 single_quoted = 1;
1644             }
1645           if (c == '"' && !single_quoted)
1646             {
1647               // double quoting start-stop
1648               if (double_quoted)
1649                 double_quoted = 0;
1650               else
1651                 double_quoted = 1;
1652             }
1653           if (single_quoted || double_quoted)
1654             continue;
1655           if (c == '(')
1656             level++;
1657           if (c == ')')
1658             {
1659               if (level == 0)
1660                 {
1661                   *on = pos;
1662                   *off = i;
1663                   return true;
1664                 }
1665               level--;
1666             }
1667         }
1668     }
1669   return false;
1670 }
1671 
MySqlControl(MyQueryView * parent,wxWindowID id,const wxString & value,const wxPoint & pos,const wxSize & size,long style)1672 MySqlControl::MySqlControl(MyQueryView * parent, wxWindowID id, const wxString & value, const wxPoint & pos, const wxSize & size, long style):
1673 wxTextCtrl(parent, id, value, pos, size,
1674            style)
1675 {
1676 //
1677 // constructor: SQL text control
1678 //
1679   Parent = parent;
1680   Connect(wxID_ANY, wxEVT_LEFT_DOWN,
1681           (wxObjectEventFunction) & MySqlControl::OnSqlMousePosition);
1682   Connect(wxID_ANY, wxEVT_KEY_UP,
1683           (wxObjectEventFunction) & MySqlControl::OnSqlArrowPosition);
1684 }
1685 
OnSqlMousePosition(wxMouseEvent & event)1686 void MySqlControl::OnSqlMousePosition(wxMouseEvent & event)
1687 {
1688 //
1689 // intercepting mouse clicks
1690 //
1691   if (Parent->IsIgnoreEvent() == true)
1692     return;
1693   event.Skip();
1694   Parent->EventBrackets();
1695 }
1696 
OnSqlArrowPosition(wxKeyEvent & event)1697 void MySqlControl::OnSqlArrowPosition(wxKeyEvent & event)
1698 {
1699 //
1700 // intercepting arrow keys
1701 //
1702   if (Parent->IsIgnoreEvent() == true)
1703     return;
1704   event.Skip();
1705   int key_code = event.GetKeyCode();
1706   switch (key_code)
1707     {
1708       case WXK_DELETE:
1709       case WXK_HOME:
1710       case WXK_LEFT:
1711       case WXK_UP:
1712       case WXK_RIGHT:
1713       case WXK_DOWN:
1714       case WXK_PAGEUP:
1715       case WXK_PAGEDOWN:
1716       case WXK_NUMPAD_DELETE:
1717       case WXK_NUMPAD_HOME:
1718       case WXK_NUMPAD_LEFT:
1719       case WXK_NUMPAD_UP:
1720       case WXK_NUMPAD_RIGHT:
1721       case WXK_NUMPAD_DOWN:
1722       case WXK_NUMPAD_PAGEUP:
1723       case WXK_NUMPAD_PAGEDOWN:
1724         Parent->EventBrackets();
1725         break;
1726       default:
1727         break;
1728     };
1729 }
1730 
SqlTokenizer(wxString & sql)1731 SqlTokenizer::SqlTokenizer(wxString & sql)
1732 {
1733 // breaking tokens from an SQL expression
1734   Block = 1024;
1735   Max = Block;
1736   int i;
1737   char c;
1738   int single_quoted = 0;
1739   int double_quoted = 0;
1740   int white_space = 0;
1741   int start = -1;
1742   int len;
1743 // initial allocation for the token list
1744   TokenList = new wxString *[Max];
1745   for (i = 0; i < Max; i++)
1746     TokenList[i] = NULL;
1747   Index = 0;
1748   for (i = 0; i < (int) sql.Len(); i++)
1749     {
1750       // scanning the SQL statement
1751       c = sql.GetChar(i);
1752       if (c == '\'' && !double_quoted)
1753         {
1754           if (single_quoted)
1755             {
1756               single_quoted = 0;
1757               len = i - start;
1758               len++;
1759               wxString *token = new wxString(sql.Mid(start, len));
1760               Insert(token);
1761               start = -1;
1762           } else
1763             {
1764               single_quoted = 1;
1765               start = i;
1766             }
1767           continue;
1768         }
1769       if (c == '"' && !single_quoted)
1770         {
1771           if (double_quoted)
1772             {
1773               double_quoted = 0;
1774               len = i - start;
1775               len++;
1776               wxString *token = new wxString(sql.Mid(start, len));
1777               Insert(token);
1778               start = -1;
1779           } else
1780             {
1781               double_quoted = 1;
1782               start = i;
1783             }
1784           continue;
1785         }
1786       if (single_quoted || double_quoted)
1787         continue;
1788       if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '('
1789           || c == ')' || c == ';' || c == ',')
1790         {
1791           if (white_space)
1792             continue;
1793           if (start >= 0)
1794             {
1795               // ok, we have a valid SQL token
1796               len = i - start;
1797               wxString *token = new wxString(sql.Mid(start, len));
1798               Insert(token);
1799             }
1800           start = -1;
1801           white_space = 1;
1802           continue;
1803         }
1804       white_space = 0;
1805       if (start < 0)
1806         start = i;
1807     }
1808   if (start >= 0)
1809     {
1810       // fetching the last token
1811       i = sql.Len();
1812       len = i - start;
1813       wxString *token = new wxString(sql.Mid(start, len));
1814       Insert(token);
1815     }
1816   Index = 0;
1817 }
1818 
~SqlTokenizer()1819 SqlTokenizer::~SqlTokenizer()
1820 {
1821 // destructor
1822   wxString *token;
1823   Index = 0;
1824   while (1)
1825     {
1826       token = TokenList[Index];
1827       if (token == NULL)
1828         break;
1829       delete token;
1830       Index++;
1831     }
1832   delete[]TokenList;
1833 }
1834 
Expand()1835 void SqlTokenizer::Expand()
1836 {
1837 // expanding the token list
1838   int newSize = Max + Block;
1839   int i;
1840   wxString **newList = new wxString *[newSize];
1841   for (i = 0; i < newSize; i++)
1842     newList[i] = NULL;
1843   for (i = 0; i < Max; i++)
1844     newList[i] = TokenList[i];
1845   delete[]TokenList;
1846   TokenList = newList;
1847   Max = newSize;
1848 }
1849 
Insert(wxString * token)1850 void SqlTokenizer::Insert(wxString * token)
1851 {
1852 // inserting a new token
1853   if (Index == (Max - 1))
1854     Expand();
1855   TokenList[Index++] = token;
1856 }
1857 
HasMoreTokens()1858 bool SqlTokenizer::HasMoreTokens()
1859 {
1860   wxString *token = TokenList[Index];
1861   if (token == NULL)
1862     return false;
1863   return true;
1864 }
1865 
GetNextToken()1866 wxString & SqlTokenizer::GetNextToken()
1867 {
1868 // return the next token
1869   wxString *token = TokenList[Index];
1870   Index++;
1871   CurrentToken = *token;
1872   return CurrentToken;
1873 }
1874