-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlparse.h
More file actions
127 lines (100 loc) · 2.04 KB
/
sqlparse.h
File metadata and controls
127 lines (100 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef SQLPARSE_H
#define SQLPARSE_H
#include <QString>
#include <QVector>
#include <QMap>
class SqlScanner;
enum SqliteConflict
{
Undefine,
Rollback,
Abort,
Fail,
Ignore,
Replace
};
struct SqliteNotNullConstraint
{
bool value;
SqliteConflict conflict;
};
struct SqliteColumn
{
SqliteColumn();
SqliteColumn& operator=(const SqliteColumn &other);
QString name;
QString type;
int length;
int length2;
bool notnull;
QString notnullconflict;
bool isPK;
bool auto_inc;
QString pksort_order;
QString pkconflict;
bool isUnique;
QString unique_conflict;
QString defaultValue;
QString check;
QString conlate;
int state;
};
struct SqlitePKey{
QVector<QString> column_list;
QString conflict;
};
struct SqliteUnique{
QVector<QString> column_list;
QString conflict;
};
struct SqliteIndexColumn
{
QString name;
QString collate;
QString sort;
};
struct SqliteIndex{
QString name;
QString tbname;
bool unique;
QList<SqliteIndexColumn*> collist;
};
struct SqliteTable
{
QString name;
QVector<SqliteColumn*> column_list;
SqlitePKey pkey;
SqliteUnique uq;
QString check_expr;
};
enum ParseState
{
Prepair,
ParseColumnList,
ParsePKey,
ParsePKeyCol,
ParsePKeyColEnd,
ParseUnique,
ParseUniqueCol,
ParseUniqueColEnd,
ParseCheck,
ParseCheckEnd,
ParseEnd
};
class SqlParse
{
public:
bool parse(const QString &sql);
bool parse_index(const QString &src,
const QString &dbname,
SqliteIndex &index);
SqliteTable table;
private:
void reset();
bool parse_table(SqlScanner *scanner);
bool parse_column(SqlScanner *scanner,SqliteColumn *col);
bool parse_conflict(SqlScanner *scanner,QString &conflict);
//SqliteColumn* findBy(const QString &col_name);
ParseState state;
};
#endif // SQLPARSE_H