kexi

kexidbparser.cpp

00001 /***************************************************************************
00002  * kexidbparser.cpp
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 
00021 #include "kexidbparser.h"
00022 #include "kexidbschema.h"
00023 #include "kexidbconnection.h"
00024 
00025 #include <api/variant.h>
00026 
00027 using namespace Kross::KexiDB;
00028 
00029 KexiDBParser::KexiDBParser(KexiDBConnection* connection, ::KexiDB::Parser* parser)
00030     : Kross::Api::Class<KexiDBParser>("KexiDBParser")
00031     , m_connection(connection)
00032     , m_parser(parser)
00033 {
00034     this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("parse", this, &KexiDBParser::parse);
00035     this->addFunction0< void >("clear", this, &KexiDBParser::clear);
00036 
00037     this->addFunction0< Kross::Api::Variant >("operation", this, &KexiDBParser::operation);
00038 
00039     this->addFunction0< KexiDBTableSchema >("table", this, &KexiDBParser::table);
00040     this->addFunction0< KexiDBQuerySchema >("query", this, &KexiDBParser::query);
00041     this->addFunction0< KexiDBConnection >("connection", this, &KexiDBParser::connection);
00042     this->addFunction0< Kross::Api::Variant >("statement", this, &KexiDBParser::statement);
00043 
00044     this->addFunction0< Kross::Api::Variant >("errorType", this, &KexiDBParser::errorType);
00045     this->addFunction0< Kross::Api::Variant >("errorMsg", this, &KexiDBParser::errorMsg);
00046     this->addFunction0< Kross::Api::Variant >("errorAt", this, &KexiDBParser::errorAt);
00047 }
00048 
00049 KexiDBParser::~KexiDBParser()
00050 {
00051 }
00052 
00053 const QString KexiDBParser::getClassName() const
00054 {
00055     return "Kross::KexiDB::KexiDBParser";
00056 }
00057 
00058 bool KexiDBParser::parse(const QString& sql) { return m_parser->parse(sql); }
00059 void KexiDBParser::clear() { m_parser->clear(); }
00060 const QString KexiDBParser::operation() { return m_parser->operationString(); }
00061 
00062 KexiDBTableSchema* KexiDBParser::table() {
00063     ::KexiDB::TableSchema* t = m_parser->table();
00064     return t ? new KexiDBTableSchema(t) : 0;
00065 }
00066 
00067 KexiDBQuerySchema* KexiDBParser::query() {
00068     ::KexiDB::QuerySchema* q = m_parser->query();
00069     return q ? new KexiDBQuerySchema(q) : 0;
00070 }
00071 
00072 KexiDBConnection* KexiDBParser::connection() { return m_connection; }
00073 const QString KexiDBParser::statement() { return m_parser->statement(); }
00074 
00075 const QString KexiDBParser::errorType() { return m_parser->error().type(); }
00076 const QString KexiDBParser::errorMsg() { return m_parser->error().error(); }
00077 int KexiDBParser::errorAt() { return m_parser->error().at(); }
KDE Home | KDE Accessibility Home | Description of Access Keys