File indexing completed on 2024-05-05 16:47:17

0001 /* This file is part of the KDE project
0002    Copyright (C) 2007 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 SYBASECONNECTION_H
0021 #define SYBASECONNECTION_H
0022 
0023 #include <qstringlist.h>
0024 
0025 #include "KDbConnection.h"
0026 #include "SybaseCursor.h"
0027 
0028 class SybaseConnectionInternal;
0029 
0030 /*! @short Provides database connection, allowing queries and data modification.
0031 */
0032 class SybaseConnection : public KDbConnection
0033 {
0034 public:
0035     virtual ~SybaseConnection();
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     KDbPreparedStatement prepareStatement(KDbPreparedStatement::StatementType type,
0043                                           KDbFieldList *fields) override;
0044 
0045 protected:
0046 
0047     /*! Used by driver */
0048     SybaseConnection(KDbDriver *driver, 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     virtual bool drv_beforeInsert(const QString& table, KDbFieldList* fields);
0071     virtual bool drv_afterInsert(const QString& table, KDbFieldList* fields);
0072 
0073     virtual bool drv_beforeUpdate(const QString& table, KDbFieldList* fields);
0074     virtual bool drv_afterUpdate(const QString& table, KDbFieldList* fields);
0075 
0076     SybaseConnectionInternal* d;
0077 
0078     friend class SybaseDriver;
0079     friend class SybaseCursor;
0080 };
0081 
0082 #endif