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     addFunction("parse", &KexiDBParser::parse,
00035         Kross::Api::ArgumentList() << Kross::Api::Argument("Kross::Api::Variant::String"));
00036     addFunction("clear", &KexiDBParser::clear);
00037     addFunction("operation", &KexiDBParser::operation);
00038 
00039     addFunction("table", &KexiDBParser::table);
00040     addFunction("query", &KexiDBParser::query);
00041     addFunction("connection", &KexiDBParser::connection);
00042     addFunction("statement", &KexiDBParser::statement);
00043 
00044     addFunction("errorType", &KexiDBParser::errorType);
00045     addFunction("errorMsg", &KexiDBParser::errorMsg);
00046     addFunction("errorAt", &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 Kross::Api::Object::Ptr KexiDBParser::parse(Kross::Api::List::Ptr args)
00059 {
00060     return new Kross::Api::Variant(
00061            QVariant(m_parser->parse(Kross::Api::Variant::toString(args->item(0))),0));
00062 }
00063 
00064 Kross::Api::Object::Ptr KexiDBParser::clear(Kross::Api::List::Ptr)
00065 {
00066     m_parser->clear();
00067     return 0;
00068 }
00069 
00070 Kross::Api::Object::Ptr KexiDBParser::operation(Kross::Api::List::Ptr)
00071 {
00072     return new Kross::Api::Variant(m_parser->operationString());
00073     return 0;
00074 }
00075 
00076 Kross::Api::Object::Ptr KexiDBParser::table(Kross::Api::List::Ptr)
00077 {
00078     ::KexiDB::TableSchema* t = m_parser->table();
00079     if(! t) return 0;
00080     return new KexiDBTableSchema(t);
00081 }
00082 
00083 Kross::Api::Object::Ptr KexiDBParser::query(Kross::Api::List::Ptr)
00084 {
00085     ::KexiDB::QuerySchema* q = m_parser->query();
00086     if(! q) return 0;
00087     return new KexiDBQuerySchema(q);
00088 }
00089 
00090 Kross::Api::Object::Ptr KexiDBParser::connection(Kross::Api::List::Ptr)
00091 {
00092     return m_connection;
00093 }
00094 
00095 Kross::Api::Object::Ptr KexiDBParser::statement(Kross::Api::List::Ptr)
00096 {
00097     return new Kross::Api::Variant(m_parser->statement());
00098 }
00099 
00100 Kross::Api::Object::Ptr KexiDBParser::errorType(Kross::Api::List::Ptr)
00101 {
00102     return new Kross::Api::Variant(m_parser->error().type());
00103 }
00104 
00105 Kross::Api::Object::Ptr KexiDBParser::errorMsg(Kross::Api::List::Ptr)
00106 {
00107     return new Kross::Api::Variant(m_parser->error().error());
00108 }
00109 
00110 Kross::Api::Object::Ptr KexiDBParser::errorAt(Kross::Api::List::Ptr)
00111 {
00112     return new Kross::Api::Variant(m_parser->error().at());
00113 }
00114 
KDE Home | KDE Accessibility Home | Description of Access Keys