kexi

kexidbdriver.cpp

00001 /***************************************************************************
00002  * kexidbdriver.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 #include "kexidbdriver.h"
00021 #include "kexidbdrivermanager.h"
00022 
00023 #include "kexidbconnection.h"
00024 #include "kexidbconnectiondata.h"
00025 
00026 #include <qvaluelist.h>
00027 #include <qptrlist.h>
00028 #include <kdebug.h>
00029 
00030 #include <kexidb/connection.h>
00031 
00032 using namespace Kross::KexiDB;
00033 
00034 KexiDBDriver::KexiDBDriver(::KexiDB::Driver* driver)
00035     : Kross::Api::Class<KexiDBDriver>("KexiDBDriver", KexiDBDriverManager::self())
00036     , m_driver(driver)
00037 {
00038 
00039     // Return true if this driver is valid else false.
00040     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00041         ("isValid", driver, &::KexiDB::Driver::isValid );
00042 
00043     // The drivers major versionnumber.
00044     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,int> >
00045         ("versionMajor", driver, &::KexiDB::Driver::versionMajor );
00046 
00047     // The drivers minor versionnumber.
00048     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,int> >
00049         ("versionMinor", driver, &::KexiDB::Driver::versionMinor );
00050 
00051     // Driver-specific SQL string escaping. For example the " or ' char may
00052     // need to be escaped for values used within SQL-statements.
00053     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,QString>, Kross::Api::ProxyValue<Kross::Api::Variant,const QString&> >
00054         ("escapeString", driver, (QString(::KexiDB::Driver::*)(const QString&)const) &::KexiDB::Driver::escapeString);
00055 
00056     // Returns true if this driver is file-based.
00057     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00058         ("isFileDriver", driver, &::KexiDB::Driver::isFileDriver );
00059 
00060     // Return a name of MIME type of files handled by this driver if it is a
00061     // file-based database's driver otherwise returns null string.
00062     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,QString> >
00063         ("fileDBDriverMimeType", driver, &::KexiDB::Driver::fileDBDriverMimeType );
00064 
00065     // Returns true if the passed string is a system object's name, eg. name
00066     // of build-in system table that cannot be used or created by a user.
00067     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool>, Kross::Api::ProxyValue<Kross::Api::Variant,const QString&> >
00068         ("isSystemObjectName", driver, &::KexiDB::Driver::isSystemObjectName );
00069 
00070     // Returns true if the passed string is a system database's name, eg. name
00071     // of build-in, system database that cannot be used or created by a user.
00072     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool>, Kross::Api::ProxyValue<Kross::Api::Variant,const QString&> >
00073         ("isSystemDatabaseName", driver, &::KexiDB::Driver::isSystemDatabaseName );
00074 
00075     // Returns true if the passed string is a system field's name, build-in
00076     // system field that cannot be used or created by a user.
00077     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool>, Kross::Api::ProxyValue<Kross::Api::Variant,const QString&> >
00078         ("isSystemFieldName", driver, &::KexiDB::Driver::isSystemFieldName );
00079 
00080     // The as second argument passed string got escaped to be usuable within
00081     // a SQL-statement and those escaped string got returned by the method.
00082     // The first argument defines the fieldtype to what we should escape the
00083     // second argument to.
00084     this->addProxyFunction<
00085         Kross::Api::ProxyValue<Kross::Api::Variant,QString>,
00086         Kross::Api::ProxyValue<Kross::Api::Variant,const QString&>,
00087         Kross::Api::ProxyValue<Kross::Api::Variant,const QVariant&>
00088         > ("valueToSQL", driver, (QString(::KexiDB::Driver::*)(const QString&,const QVariant&)const) &::KexiDB::Driver::valueToSQL );
00089 
00090     // Create a new KexiDBConnection object and return it.
00091     this->addProxyFunction<
00092         Kross::Api::ProxyValue<Kross::KexiDB::KexiDBConnection, ::KexiDB::Connection* >,
00093         Kross::Api::ProxyValue<Kross::KexiDB::KexiDBConnectionData, ::KexiDB::ConnectionData& > >
00094         ("createConnection", driver, &::KexiDB::Driver::createConnection );
00095 
00096     // Return a list of KexiDBConnection objects.
00097     this->addProxyFunction< 
00098         Kross::Api::ProxyValue< Kross::Api::ListT<Kross::KexiDB::KexiDBConnection, ::KexiDB::Connection>, const QPtrList< ::KexiDB::Connection> > >
00099         ("connectionsList", driver, &::KexiDB::Driver::connectionsList );
00100 }
00101 
00102 KexiDBDriver::~KexiDBDriver()
00103 {
00104 }
00105 
00106 const QString KexiDBDriver::getClassName() const
00107 {
00108     return "Kross::KexiDB::KexiDBDriver";
00109 }
00110 
KDE Home | KDE Accessibility Home | Description of Access Keys