From d6ecdb434410ffda64058cdb51483786f5af9932 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 23 Nov 2015 12:19:25 +0100 Subject: [PATCH] qsql: move QResult out of header Leaf result classes do not need to be exposed in the headers. The implementations were inconsistent on this point. Change-Id: I5bd41ae9e77b932f6232218a014400a59f2ef5a0 Reviewed-by: Friedemann Kleint --- src/sql/drivers/db2/qsql_db2.cpp | 33 ++++++++++++++++++++++- src/sql/drivers/db2/qsql_db2_p.h | 32 ----------------------- src/sql/drivers/mysql/qsql_mysql.cpp | 39 ++++++++++++++++++++++++++-- src/sql/drivers/mysql/qsql_mysql_p.h | 37 -------------------------- src/sql/drivers/odbc/qsql_odbc.cpp | 36 +++++++++++++++++++++++++ src/sql/drivers/odbc/qsql_odbc_p.h | 37 -------------------------- src/sql/drivers/psql/qsql_psql.cpp | 29 +++++++++++++++++++++ src/sql/drivers/psql/qsql_psql_p.h | 33 ----------------------- 8 files changed, 134 insertions(+), 142 deletions(-) diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp index dd49963d93..7282d3a655 100644 --- a/src/sql/drivers/db2/qsql_db2.cpp +++ b/src/sql/drivers/db2/qsql_db2.cpp @@ -32,7 +32,6 @@ ****************************************************************************/ #include "qsql_db2_p.h" -#include #include #include #include @@ -43,6 +42,8 @@ #include #include #include +#include +#include #if defined(Q_CC_BOR) // DB2's sqlsystm.h (included through sqlcli1.h) defines the SQL_BIGINT_TYPE @@ -72,6 +73,36 @@ public: QString user; }; +class QDB2ResultPrivate; + +class QDB2Result: public QSqlResult +{ +public: + QDB2Result(const QDB2Driver *dr, const QDB2DriverPrivate *dp); + ~QDB2Result(); + bool prepare(const QString &query); + bool exec(); + QVariant handle() const; + +protected: + QVariant data(int field); + bool reset (const QString &query); + bool fetch(int i); + bool fetchNext(); + bool fetchFirst(); + bool fetchLast(); + bool isNull(int i); + int size(); + int numRowsAffected(); + QSqlRecord record() const; + void virtual_hook(int id, void *data); + void detachFromResultSet(); + bool nextResult(); + +private: + QDB2ResultPrivate *d; +}; + class QDB2ResultPrivate { public: diff --git a/src/sql/drivers/db2/qsql_db2_p.h b/src/sql/drivers/db2/qsql_db2_p.h index 7b5d751b89..f3f081f731 100644 --- a/src/sql/drivers/db2/qsql_db2_p.h +++ b/src/sql/drivers/db2/qsql_db2_p.h @@ -53,43 +53,11 @@ #define Q_EXPORT_SQLDRIVER_DB2 Q_SQL_EXPORT #endif -#include #include QT_BEGIN_NAMESPACE -class QDB2Driver; class QDB2DriverPrivate; -class QDB2ResultPrivate; -class QSqlRecord; - -class QDB2Result : public QSqlResult -{ -public: - QDB2Result(const QDB2Driver* dr, const QDB2DriverPrivate* dp); - ~QDB2Result(); - bool prepare(const QString& query); - bool exec(); - QVariant handle() const; - -protected: - QVariant data(int field); - bool reset (const QString& query); - bool fetch(int i); - bool fetchNext(); - bool fetchFirst(); - bool fetchLast(); - bool isNull(int i); - int size(); - int numRowsAffected(); - QSqlRecord record() const; - void virtual_hook(int id, void *data); - void detachFromResultSet(); - bool nextResult(); - -private: - QDB2ResultPrivate* d; -}; class Q_EXPORT_SQLDRIVER_DB2 QDB2Driver : public QSqlDriver { diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 96bdcc42fa..739d605911 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -33,7 +33,6 @@ #include "qsql_mysql_p.h" -#include #include #include #include @@ -46,8 +45,9 @@ #include #include #include - #include +#include +#include #ifdef Q_OS_WIN32 // comment the next line out if you want to use MySQL/embedded on Win32 systems. @@ -156,6 +156,41 @@ static inline QVariant qDateTimeFromString(QString &val) #endif } +class QMYSQLResultPrivate; + +class QMYSQLResult : public QSqlResult +{ + friend class QMYSQLDriver; + friend class QMYSQLResultPrivate; +public: + explicit QMYSQLResult(const QMYSQLDriver *db); + ~QMYSQLResult(); + + QVariant handle() const Q_DECL_OVERRIDE; +protected: + void cleanup(); + bool fetch(int i) Q_DECL_OVERRIDE; + bool fetchNext() Q_DECL_OVERRIDE; + bool fetchLast() Q_DECL_OVERRIDE; + bool fetchFirst() Q_DECL_OVERRIDE; + QVariant data(int field) Q_DECL_OVERRIDE; + bool isNull(int field) Q_DECL_OVERRIDE; + bool reset (const QString& query) Q_DECL_OVERRIDE; + int size() Q_DECL_OVERRIDE; + int numRowsAffected() Q_DECL_OVERRIDE; + QVariant lastInsertId() const Q_DECL_OVERRIDE; + QSqlRecord record() const Q_DECL_OVERRIDE; + void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; + bool nextResult() Q_DECL_OVERRIDE; + +#if MYSQL_VERSION_ID >= 40108 + bool prepare(const QString &stmt) Q_DECL_OVERRIDE; + bool exec() Q_DECL_OVERRIDE; +#endif +private: + QMYSQLResultPrivate *d; +}; + class QMYSQLResultPrivate : public QObject { Q_OBJECT diff --git a/src/sql/drivers/mysql/qsql_mysql_p.h b/src/sql/drivers/mysql/qsql_mysql_p.h index 724cc1fd28..7fb02d202c 100644 --- a/src/sql/drivers/mysql/qsql_mysql_p.h +++ b/src/sql/drivers/mysql/qsql_mysql_p.h @@ -46,7 +46,6 @@ // #include -#include #if defined (Q_OS_WIN32) #include @@ -63,42 +62,6 @@ QT_BEGIN_NAMESPACE class QMYSQLDriverPrivate; -class QMYSQLResultPrivate; -class QMYSQLDriver; -class QSqlRecordInfo; - -class QMYSQLResult : public QSqlResult -{ - friend class QMYSQLDriver; - friend class QMYSQLResultPrivate; -public: - explicit QMYSQLResult(const QMYSQLDriver* db); - ~QMYSQLResult(); - - QVariant handle() const Q_DECL_OVERRIDE; -protected: - void cleanup(); - bool fetch(int i) Q_DECL_OVERRIDE; - bool fetchNext() Q_DECL_OVERRIDE; - bool fetchLast() Q_DECL_OVERRIDE; - bool fetchFirst() Q_DECL_OVERRIDE; - QVariant data(int field) Q_DECL_OVERRIDE; - bool isNull(int field) Q_DECL_OVERRIDE; - bool reset (const QString& query) Q_DECL_OVERRIDE; - int size() Q_DECL_OVERRIDE; - int numRowsAffected() Q_DECL_OVERRIDE; - QVariant lastInsertId() const Q_DECL_OVERRIDE; - QSqlRecord record() const Q_DECL_OVERRIDE; - void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; - bool nextResult() Q_DECL_OVERRIDE; - -#if MYSQL_VERSION_ID >= 40108 - bool prepare(const QString& stmt) Q_DECL_OVERRIDE; - bool exec() Q_DECL_OVERRIDE; -#endif -private: - QMYSQLResultPrivate* d; -}; class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver { diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 8c4ec484cc..19d669b8c3 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -50,6 +50,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -143,6 +144,41 @@ private: QChar quote; }; +class QODBCResultPrivate; + +class QODBCResult: public QSqlResult +{ +public: + QODBCResult(const QODBCDriver *db, QODBCDriverPrivate *p); + virtual ~QODBCResult(); + + bool prepare(const QString &query); + bool exec(); + + QVariant lastInsertId() const; + QVariant handle() const; + virtual void setForwardOnly(bool forward); + +protected: + bool fetchNext(); + bool fetchFirst(); + bool fetchLast(); + bool fetchPrevious(); + bool fetch(int i); + bool reset (const QString &query); + QVariant data(int field); + bool isNull(int field); + int size(); + int numRowsAffected(); + QSqlRecord record() const; + void virtual_hook(int id, void *data); + void detachFromResultSet(); + bool nextResult(); + +private: + QODBCResultPrivate *d; +}; + class QODBCResultPrivate { public: diff --git a/src/sql/drivers/odbc/qsql_odbc_p.h b/src/sql/drivers/odbc/qsql_odbc_p.h index 9c864b467d..407280ebb9 100644 --- a/src/sql/drivers/odbc/qsql_odbc_p.h +++ b/src/sql/drivers/odbc/qsql_odbc_p.h @@ -46,7 +46,6 @@ // #include -#include #if defined (Q_OS_WIN32) #include @@ -75,43 +74,7 @@ QT_BEGIN_NAMESPACE -class QODBCResultPrivate; class QODBCDriverPrivate; -class QODBCDriver; -class QSqlRecordInfo; - -class QODBCResult : public QSqlResult -{ -public: - QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p); - virtual ~QODBCResult(); - - bool prepare(const QString& query); - bool exec(); - - QVariant lastInsertId() const; - QVariant handle() const; - virtual void setForwardOnly(bool forward); - -protected: - bool fetchNext(); - bool fetchFirst(); - bool fetchLast(); - bool fetchPrevious(); - bool fetch(int i); - bool reset (const QString& query); - QVariant data(int field); - bool isNull(int field); - int size(); - int numRowsAffected(); - QSqlRecord record() const; - void virtual_hook(int id, void *data); - void detachFromResultSet(); - bool nextResult(); - -private: - QODBCResultPrivate *d; -}; class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver { diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 5dcabb0646..781317c46a 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -119,6 +119,35 @@ inline void qPQfreemem(void *buffer) PQfreemem(buffer); } +class QPSQLResultPrivate; + +class QPSQLResult: public QSqlResult +{ + Q_DECLARE_PRIVATE(QPSQLResult) + +public: + QPSQLResult(const QPSQLDriver *db); + ~QPSQLResult(); + + QVariant handle() const Q_DECL_OVERRIDE; + void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; + +protected: + void cleanup(); + bool fetch(int i) Q_DECL_OVERRIDE; + bool fetchFirst() Q_DECL_OVERRIDE; + bool fetchLast() Q_DECL_OVERRIDE; + QVariant data(int i) Q_DECL_OVERRIDE; + bool isNull(int field) Q_DECL_OVERRIDE; + bool reset (const QString &query) Q_DECL_OVERRIDE; + int size() Q_DECL_OVERRIDE; + int numRowsAffected() Q_DECL_OVERRIDE; + QSqlRecord record() const Q_DECL_OVERRIDE; + QVariant lastInsertId() const Q_DECL_OVERRIDE; + bool prepare(const QString &query) Q_DECL_OVERRIDE; + bool exec() Q_DECL_OVERRIDE; +}; + class QPSQLDriverPrivate : public QSqlDriverPrivate { Q_DECLARE_PUBLIC(QPSQLDriver) diff --git a/src/sql/drivers/psql/qsql_psql_p.h b/src/sql/drivers/psql/qsql_psql_p.h index 61e201ae5e..d989f70ae3 100644 --- a/src/sql/drivers/psql/qsql_psql_p.h +++ b/src/sql/drivers/psql/qsql_psql_p.h @@ -45,7 +45,6 @@ // We mean it. // -#include #include #ifdef QT_PLUGIN @@ -59,44 +58,12 @@ typedef struct pg_result PGresult; QT_BEGIN_NAMESPACE -class QPSQLResultPrivate; -class QPSQLDriver; -class QSqlRecordInfo; - -class QPSQLResult : public QSqlResult -{ - Q_DECLARE_PRIVATE(QPSQLResult) - -public: - QPSQLResult(const QPSQLDriver* db); - ~QPSQLResult(); - - QVariant handle() const Q_DECL_OVERRIDE; - void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; - -protected: - void cleanup(); - bool fetch(int i) Q_DECL_OVERRIDE; - bool fetchFirst() Q_DECL_OVERRIDE; - bool fetchLast() Q_DECL_OVERRIDE; - QVariant data(int i) Q_DECL_OVERRIDE; - bool isNull(int field) Q_DECL_OVERRIDE; - bool reset (const QString& query) Q_DECL_OVERRIDE; - int size() Q_DECL_OVERRIDE; - int numRowsAffected() Q_DECL_OVERRIDE; - QSqlRecord record() const Q_DECL_OVERRIDE; - QVariant lastInsertId() const Q_DECL_OVERRIDE; - bool prepare(const QString& query) Q_DECL_OVERRIDE; - bool exec() Q_DECL_OVERRIDE; -}; - class QPSQLDriverPrivate; class Q_EXPORT_SQLDRIVER_PSQL QPSQLDriver : public QSqlDriver { friend class QPSQLResultPrivate; Q_DECLARE_PRIVATE(QPSQLDriver) - Q_OBJECT public: enum Protocol {