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 #include <qvariant.h>
00027
00028 #include <kexidb/field.h>
00029 #include <kexidb/expression.h>
00030
00031 namespace KexiDB
00032 {
00033
00034 class Connection;
00035 class QuerySchema;
00036 class TableSchema;
00037 class Field;
00038
00042 class KEXI_DB_EXPORT ParserError
00043 {
00044 public:
00045
00049 ParserError();
00050
00059 ParserError(const QString &type, const QString &error, const QString &hint, int at);
00060
00064 ~ParserError();
00065
00069 QString type() { return m_type; }
00070
00074 QString error() { return m_error; }
00075
00079 int at() { return m_at; }
00080
00081 private:
00082 QString m_type;
00083 QString m_error;
00084 QString m_hint;
00085 int m_at;
00086
00087 };
00088
00089 class ParserPrivate;
00090
00112 class KEXI_DB_EXPORT Parser
00113 {
00114 public:
00115
00119 enum OPCode
00120 {
00121 OP_None = 0,
00122 OP_Error,
00123 OP_CreateTable,
00124 OP_AlterTable,
00125 OP_Select,
00126 OP_Insert,
00127 OP_Update,
00128 OP_Delete
00129 };
00130
00135 Parser(Connection *connection);
00136 ~Parser();
00137
00141 bool parse(const QString &statement);
00142
00146 void clear();
00147
00151 OPCode operation() const;
00152
00156 QString operationString() const;
00157
00164 TableSchema *table();
00165
00172 QuerySchema *query();
00173
00179 Connection *db() const;
00180
00185 ParserError error() const;
00186
00190 QString statement() const;
00191
00196 void setOperation(OPCode op);
00197
00202 void createTable(const char *t);
00203
00208
00209 void setQuerySchema(QuerySchema *query);
00210
00215 QuerySchema *select() const;
00216
00221 void setError(const ParserError &err);
00222
00228 bool isReservedKeyword(const char *str);
00229
00230 protected:
00231 void init();
00232
00233 ParserError m_error;
00234 ParserPrivate *d;
00235 };
00236
00237 }
00238
00239 #endif
00240
|