File indexing completed on 2024-05-19 12:25:42
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 KDB_SYBASECLIENT_P_H 0021 #define KDB_SYBASECLIENT_P_H 0022 0023 #include <QMap> 0024 0025 #include "KDbConnection_p.h" 0026 0027 //#include <config.h> 0028 #include <sqlfront.h> 0029 #include <sqldb.h> 0030 0031 class KDbConnectionData; 0032 0033 //! Internal Sybase connection data. 0034 /*! Provides a low-level API for accessing Sybase databases, that can 0035 be shared by any module that needs direct access to the underlying 0036 database. Used by the KDb and KexiMigration drivers. 0037 */ 0038 class SybaseConnectionInternal : public KDbConnectionInternal 0039 { 0040 0041 public: 0042 explicit SybaseConnectionInternal(KDbConnection* connection); 0043 virtual ~SybaseConnectionInternal(); 0044 0045 //! Connects to a Sybase database 0046 /*! Connects to the Sybase server on host as the given user using the specified 0047 password. If host is "localhost", then a socket on the local file system 0048 can be specified to connect to the server (several defaults will be tried if 0049 none is specified). If the server is on a remote machine, then a port is 0050 the port that the remote server is listening on. 0051 */ 0052 bool db_connect(const KDbConnectionData& data); 0053 0054 //! Disconnects from the database 0055 bool db_disconnect(); 0056 0057 //! Selects a database that is about to be used 0058 bool useDatabase(const QString &dbName = QString()); 0059 0060 //! Executes query for a raw SQL statement @a sql on the database 0061 bool executeSql(const KDbEscapedString& sql); 0062 0063 //! Stores last operation's result 0064 virtual void storeResult(); 0065 0066 //! Escapes a table, database or column name 0067 QString escapeIdentifier(const QString& str) const; 0068 0069 // message handler called by call back function 0070 void messageHandler(DBINT msgno, int msgstate, int severity, char* msgtext 0071 , char* srvname, char* procname, int line); 0072 0073 // dbProcess-KDbConnection map 0074 static QMap<DBPROCESS*, SybaseConnectionInternal*> dbProcessConnectionMap; 0075 0076 // Server specific stuff 0077 DBPROCESS *dbProcess; 0078 0079 bool sybase_owned; //!< true if dbprocess should be closed on destruction 0080 QString errmsg; //!< server-specific message of last operation 0081 int res; //!< result code of last operation on server 0082 0083 }; 0084 0085 0086 //! Internal Sybase cursor data. 0087 /*! Provides a low-level abstraction for iterating over Sybase result sets. */ 0088 class SybaseCursorData : public SybaseConnectionInternal 0089 { 0090 public: 0091 explicit SybaseCursorData(KDbConnection* connection); 0092 virtual ~SybaseCursorData(); 0093 0094 //unsigned long *lengths; 0095 unsigned long numRows; 0096 }; 0097 0098 #endif