1
/* This file is part of the KDE project
2
Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3
Copyright (C) 2004 Jarosław Staniek <staniek@kde.org>
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.
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.
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.
21
#include <connection.h>
22
#include <tableschema.h>
25
#include "sqlparser.h"
29
K_GLOBAL_STATIC_WITH_ARGS(StaticSetOfStrings, _reservedKeywords, (_tokens))
32
//--------------------
34
using namespace KexiDB;
36
Parser::Parser(Connection *db)
47
Parser::OPCode Parser::operation() const
49
return (OPCode)d->operation;
53
Parser::operationString() const
55
switch ((OPCode)d->operation) {
75
TableSchema *Parser::table()
77
TableSchema *t = d->table; d->table = 0; return t;
80
QuerySchema *Parser::query()
82
QuerySchema *s = d->select; d->select = 0; return s;
85
Connection *Parser::db() const
90
ParserError Parser::error() const
95
QString Parser::statement() const
100
void Parser::setOperation(OPCode op)
105
QuerySchema *Parser::select() const
110
void Parser::setError(const ParserError &err)
116
Parser::createTable(const char *t)
121
d->table = new KexiDB::TableSchema(t);
125
Parser::setQuerySchema(QuerySchema *query)
138
d->initialized = true;
142
bool Parser::isReservedKeyword(const QByteArray& str)
144
return _reservedKeywords->contains(str.toUpper());
148
Parser::parse(const QString &statement)
152
d->statement = statement;
154
KexiDB::Parser *oldParser = parser;
155
KexiDB::Field *oldField = field;
156
bool res = parseData(this, statement.toUtf8());
168
//-------------------------------------
170
ParserError::ParserError()
176
ParserError::ParserError(const QString &type, const QString &error, const QString &hint, int at)
184
ParserError::~ParserError()