File indexing completed on 2024-04-21 15:29:52

0001 /* This file is part of the KDE project
0002    Copyright (C) 2008 Sharan Rao <sharanrao@gmail.com>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this program; see the file COPYING.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017 * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef XBASECONNECTION_H
0021 #define XBASECONNECTION_H
0022 
0023 #include <QStringList>
0024 
0025 #include "KDbConnection.h"
0026 #include "XbaseCursor.h"
0027 
0028 class xBaseConnectionInternal;
0029 
0030 /*! @short Provides database connection, allowing queries and data modification.
0031 */
0032 class xBaseConnection : public KDbConnection
0033 {
0034 public:
0035     virtual ~xBaseConnection();
0036 
0037     Q_REQUIRED_RESULT KDbCursor *prepareQuery(const KDbEscapedString &sql,
0038                                               int cursor_options = 0) override;
0039     Q_REQUIRED_RESULT KDbCursor *prepareQuery(KDbQuerySchema *query,
0040                                               int cursor_options = 0) override;
0041 
0042     //! @todo returns @c nullptr for now
0043     Q_REQUIRED_RESULT KDbPreparedStatementInterface *prepareStatementInternal() override;
0044 
0045 protected:
0046 
0047     /*! Used by driver */
0048     xBaseConnection(KDbDriver *driver, KDbDriver* internalDriver, const KDbConnectionData& connData);
0049 
0050     virtual bool drv_connect(KDbServerVersionInfo* version);
0051     virtual bool drv_disconnect();
0052     virtual bool drv_getDatabasesList(QStringList* list);
0053     virtual bool drv_createDatabase( const QString &dbName = QString() );
0054     virtual bool drv_useDatabase( const QString &dbName = QString(), bool *cancelled = 0,
0055       KDbMessageHandler* msgHandler = 0 );
0056     virtual bool drv_closeDatabase();
0057     virtual bool drv_dropDatabase(const QString &dbName = QString());
0058     virtual bool drv_executeSql(const KDbEscapedString& sql);
0059     virtual quint64 drv_lastInsertRecordId();
0060 
0061     //! Implemented for KDbResultable
0062     virtual QString serverResultName() const;
0063 //    virtual void drv_clearServerResult();
0064 
0065     //! @todo move this somewhere to low level class (MIGRATION?)
0066     virtual bool drv_getTablesList(QStringList* list);
0067     //! @todo move this somewhere to low level class (MIGRATION?)
0068     virtual bool drv_containsTable(const QString &tableName);
0069 
0070     xBaseConnectionInternal* d;
0071 
0072     friend class xBaseDriver;
0073     friend class xBaseCursor;
0074 };
0075 
0076 #endif