kexi
parser.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KEXIDBPARSER_H
00022 #define KEXIDBPARSER_H
00023
00024 #include <qobject.h>
00025 #include <qptrlist.h>
00026
00027 #include <kexidb/field.h>
00028 #include <kexidb/expression.h>
00029
00030 namespace KexiDB
00031 {
00032
00033 class Connection;
00034 class QuerySchema;
00035 class TableSchema;
00036 class Field;
00037
00041 class KEXI_DB_EXPORT ParserError
00042 {
00043 public:
00044
00048 ParserError();
00049
00058 ParserError(const QString &type, const QString &error, const QString &hint, int at);
00059
00063 ~ParserError();
00064
00068 QString type() { return m_type; }
00069
00073 QString error() { return m_error; }
00074
00078 int at() { return m_at; }
00079
00080 private:
00081 QString m_type;
00082 QString m_error;
00083 QString m_hint;
00084 int m_at;
00085
00086 };
00087
00088 class ParserPrivate;
00089
00093 class KEXI_DB_EXPORT Parser
00094 {
00095 public:
00096
00100 enum OPCode
00101 {
00102 OP_None = 0,
00103 OP_Error,
00104 OP_CreateTable,
00105 OP_AlterTable,
00106 OP_Select,
00107 OP_Insert,
00108 OP_Update,
00109 OP_Delete
00110 };
00111
00116 Parser(Connection *connection);
00117 ~Parser();
00118
00122 bool parse(const QString &statement);
00123
00127 void clear();
00128
00132 OPCode operation() const;
00133
00137 QString operationString() const;
00138
00145 TableSchema *table();
00146
00153 QuerySchema *query();
00154
00160 Connection *db() const;
00161
00166 ParserError error() const;
00167
00171 QString statement() const;
00172
00177 void setOperation(OPCode op);
00178
00183 void createTable(const char *t);
00184
00189
00190 void setQuerySchema(QuerySchema *query);
00191
00196 QuerySchema *select() const;
00197
00202 void setError(const ParserError &err);
00203
00209 bool isReservedKeyword(const char *str);
00210
00211 protected:
00212 void init();
00213
00214 ParserError m_error;
00215 ParserPrivate *d;
00216 };
00217
00218 }
00219
00220 #endif
00221
|