kexi

kexidbparser.cpp
1/***************************************************************************
2 * kexidbparser.cpp
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 * This program 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 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20
21#include "kexidbparser.h"
22#include "kexidbschema.h"
23#include "kexidbconnection.h"
24
25#include <api/variant.h>
26
27using namespace Kross::KexiDB;
28
29KexiDBParser::KexiDBParser(KexiDBConnection* connection, ::KexiDB::Parser* parser)
30 : Kross::Api::Class<KexiDBParser>("KexiDBParser")
31 , m_connection(connection)
32 , m_parser(parser)
33{
34 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("parse", this, &KexiDBParser::parse);
35 this->addFunction0< void >("clear", this, &KexiDBParser::clear);
36
37 this->addFunction0< Kross::Api::Variant >("operation", this, &KexiDBParser::operation);
38
39 this->addFunction0< KexiDBTableSchema >("table", this, &KexiDBParser::table);
40 this->addFunction0< KexiDBQuerySchema >("query", this, &KexiDBParser::query);
41 this->addFunction0< KexiDBConnection >("connection", this, &KexiDBParser::connection);
42 this->addFunction0< Kross::Api::Variant >("statement", this, &KexiDBParser::statement);
43
44 this->addFunction0< Kross::Api::Variant >("errorType", this, &KexiDBParser::errorType);
45 this->addFunction0< Kross::Api::Variant >("errorMsg", this, &KexiDBParser::errorMsg);
46 this->addFunction0< Kross::Api::Variant >("errorAt", this, &KexiDBParser::errorAt);
47}
48
49KexiDBParser::~KexiDBParser()
50{
51}
52
53const TQString KexiDBParser::getClassName() const
54{
55 return "Kross::KexiDB::KexiDBParser";
56}
57
58bool KexiDBParser::parse(const TQString& sql) { return m_parser->parse(sql); }
59void KexiDBParser::clear() { m_parser->clear(); }
60const TQString KexiDBParser::operation() { return m_parser->operationString(); }
61
62KexiDBTableSchema* KexiDBParser::table() {
63 ::KexiDB::TableSchema* t = m_parser->table();
64 return t ? new KexiDBTableSchema(t) : 0;
65}
66
67KexiDBQuerySchema* KexiDBParser::query() {
68 ::KexiDB::QuerySchema* q = m_parser->query();
69 return q ? new KexiDBQuerySchema(q) : 0;
70}
71
72KexiDBConnection* KexiDBParser::connection() { return m_connection; }
73const TQString KexiDBParser::statement() { return m_parser->statement(); }
74
75const TQString KexiDBParser::errorType() { return m_parser->error().type(); }
76const TQString KexiDBParser::errorMsg() { return m_parser->error().error(); }
77int KexiDBParser::errorAt() { return m_parser->error().at(); }
Parser for SQL statements.
Definition parser.h:113
A connection to a database.
The KexiDBParser could be used to parse SQL-statements.
The KexiDBTableSchema object implements a KexiDBSchema for queries.
The KexiDBTableSchema object implements a KexiDBSchema for tables.
KrossKexiDB provides access to the KexiDB database functionality.