kexi

parser.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KEXIDBPARSER_H
22#define KEXIDBPARSER_H
23
24#include <tqobject.h>
25#include <tqptrlist.h>
26#include <tqvariant.h>
27
28#include <kexidb/field.h>
29#include <kexidb/expression.h>
30
31namespace KexiDB
32{
33
34class Connection;
35class QuerySchema;
36class TableSchema;
37class Field;
38
42class KEXI_DB_EXPORT ParserError
43{
44 public:
45
50
59 ParserError(const TQString &type, const TQString &error, const TQString &hint, int at);
60
65
69 TQString type() { return m_type; }
70
74 TQString error() { return m_error; }
75
79 int at() { return m_at; }
80
81 private:
82 TQString m_type;
83 TQString m_error;
84 TQString m_hint;
85 int m_at;
86// bool m_isNull;
87};
88
89class ParserPrivate;
90
112class KEXI_DB_EXPORT Parser
113{
114 public:
115
130
135 Parser(Connection *connection);
136 ~Parser();
137
141 bool parse(const TQString &statement);
142
146 void clear();
147
151 OPCode operation() const;
152
156 TQString operationString() const;
157
164 TableSchema *table();
165
172 QuerySchema *query();
173
179 Connection *db() const;
180
185 ParserError error() const;
186
190 TQString statement() const;
191
196 void setOperation(OPCode op);
197
202 void createTable(const char *t);
203
208//todo: other query types
209 void setQuerySchema(QuerySchema *query);
210
215 QuerySchema *select() const;
216
221 void setError(const ParserError &err);
222
228 bool isReservedKeyword(const char *str);
229
230 protected:
231 void init();
232
234 ParserPrivate *d;
235};
236
237}
238
239#endif
240
Provides database connection, allowing queries and data modification.
Definition connection.h:62
Meta-data for a field.
Definition field.h:73
Provides detailed i18n'ed error description about the Parser .
Definition parser.h:43
TQString type()
Definition parser.h:69
TQString error()
Definition parser.h:74
ParserError()
Empty constructor.
Definition parser.cpp:138
Parser for SQL statements.
Definition parser.h:113
Parser(Connection *connection)
constructs an empty object of the parser
Definition parser.cpp:31
ParserError m_error
detailed information about last error.
Definition parser.h:233
OPCode
The operation-code of the statement.
Definition parser.h:120
@ OP_Select
Alter an existing table.
Definition parser.h:125
@ OP_Update
Insert new content.
Definition parser.h:127
@ OP_Insert
Query-statement.
Definition parser.h:126
@ OP_CreateTable
Error while parsing.
Definition parser.h:123
@ OP_AlterTable
Create a table.
Definition parser.h:124
@ OP_Delete
Update existing content.
Definition parser.h:128
@ OP_Error
No statement parsed or reseted.
Definition parser.h:122
KexiDB::QuerySchema provides information about database query.
High-level database connectivity library with database backend drivers.