Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbsql.h
Go to the documentation of this file.
1/* xbsql.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014,2022 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14This class manages a list of open tables, open indices are connected to the open tables
15
16*/
17
18
19#ifndef __XB_XBSQL_H__
20#define __XB_XBSQL_H__
21
22#ifdef CMAKE_COMPILER_IS_GNUCC
23#pragma interface
24#endif
25
26
27#ifdef XB_SQL_SUPPORT
28
29namespace xb{
30
31
32struct XBDLLEXPORT xbSqlFld{
33 char cType; // F - Database field
34 // L - Literal
35 // E - Expression
36 xbInt16 iFldNo; // Field number if db field
37 xbExp * pExp; // If cType=E, pointer to parsed expression
38 xbString sFldAlias; // Alias name for query display
39 xbSqlFld * Next; // Next field in list
40};
41
42class xbStmt;
43
44
45struct XBDLLEXPORT xbTblJoin { // structure for defining joined tables in the query
46
47 xbString sTableName;
48 xbString sAlias;
49 xbString sJoinExp; // table join expression
50 xbDbf *pDbf; // pointer the the dbf structure for this table
51 xbTag *pTag; // pointer to relevant tag for this table, null for record order
52 xbExp *pLinkExp; // pointer to parsed linkage expression
53 char cJoinType; // M - Master
54 // L - Left or Full Left
55 // R - Right or Full Right
56 // I - Inner
57 // O - Outer or Full Outer Outer
58
59 xbTblJoin *pMaster; // pointer to master table, null if this is the primary master
60 xbLinkList<xbTblJoin *> llSubList; // linked list of subordinate tables
61// xbStmt *pSubQuery; // pointer to sub query
62 xbTblJoin *next; // next tbl
63};
64
65
66class XBDLLEXPORT xbStmt : public xbSsv{
67
68 public:
69 xbStmt( xbXBase *x );
70 ~xbStmt();
71
72 #ifdef XB_DEBUG_SUPPORT
73 xbInt16 DumpStmtInternals();
74 xbInt16 Test();
75 #endif
76
77 xbInt16 ExecuteQuery( const xbString &sCmdLine );
78
79// xbInt16 FetchFirst();
80// xbInt16 FetchNext();
81// xbInt16 FetchPrev();
82// xbInt16 FetchLast();
83// xbString &GetField( const xbString sFldName );
84
85 protected:
86
87 private:
88
89 xbInt16 AddQryTbl( const xbString &sTable, const xbString &sAlias, const xbString &sExpression, const char cJoinType );
90 xbInt16 CvtSqlExp2DbaseExp( const xbString &sExpIn, xbString &sExpOut );
91 xbInt16 GetNextFromSeg( const xbString &sLineIn, xbString &sFromSegOut );
92 xbUInt32 GetNextToken( const xbString &sCmdLineIn, xbString &sTokenOut, xbUInt32 ulStartPos );
93 xbInt16 GetParenCnt( const xbString &sToken );
94 xbInt16 ParseFromStmt( const xbString &sFromLine );
95 xbInt16 ParseStmt( const xbString &sCmdLine );
96 xbInt16 ProcessFromSeg( const xbString &sFromStmtSeg );
97 xbInt16 UpdateJoinList( char cType, const xbString &sTableName, const xbString &sAlias, const xbString &sExp, xbDbf *d, xbExp *e ); //, xbTag *t);
98
99 xbXBase *xbase; // pointer to xbase structure
100
101
102 xbTblJoin * pTblList;
103 xbSqlFld *fl; // field list in sql select statement
104 xbString sStmt; // complete query statment
105 xbString sFields; // list of fields
106 xbString sFrom; // from statment
107 xbString sWhere; // where clause
108 xbString sOrderBy; // sort order
109 xbString sGroupBy; // group by
110 xbString sHaving; // having
111 xbUInt32 ulFromPos;
112 xbUInt32 ulWherePos;
113 xbUInt32 ulOrderByPos;
114 xbUInt32 ulGroupByPos;
115 xbUInt32 ulHavingPos;
116
117
118};
119
120
121class XBDLLEXPORT xbSql : public xbSsv {
122 public:
123 // xbSql();
124 xbSql( xbXBase *x );
125 ~xbSql();
126
127 xbInt16 ExecuteNonQuery( const xbString &sCmdLine );
128 xbXBase *GetXbasePtr() const;
129
130 protected:
131
132 private:
133
134 xbInt16 SqlAlterTable( const xbString &sCmdLine );
135 xbInt16 SqlCreateTable( const xbString &sCmdLine );
136 xbInt16 SqlDelete( const xbString &sCmdLine );
137 xbInt16 SqlDropTable( const xbString &sCmdLine );
138
139 #ifdef XB_INDEX_SUPPORT
140 xbInt16 SqlCreateIndex( const xbString &sCmdLine );
141 xbInt16 SqlDropIndex( const xbString &sCmdLine );
142 #endif // XB_INDEX_SUPPORT
143
144// xbInt16 SqlCreateView( const xbString &sCmdLine );
145// xbInt16 SqlDropView( const xbString &sCmdLine );
146// xbInt16 SqlUpdate( const xbString &sCmdLine );
147// xbInt16 SqlSelect( const xbString &sCmdLine );
148
149 void SqlHelp() const;
150 xbInt16 SqlInsert( const xbString &sCmLine );
151 xbInt16 SqlSet( const xbString &sCmdLine );
152 xbInt16 SqlUse( const xbString &sCmdLine );
153
154 xbXBase *xbase;
155 xbUda uda;
156
157};
158
159} /* namespace xb */
160#endif /* XB_SQL_SUPPORT */
161#endif /* __XB_XBSQL_H__ */
Definition: xbdate.cpp:19
class XBDLLEXPORT xbXBase
Definition: xbssv.h:27
class XBDLLEXPORT xbDbf
Definition: xbtblmgr.h:28