mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
oracle provider: update qocispatial driver for/from Qt5
* handling of private data * rely on implicit byte array sharing instead of using data pointers * sync with qoci
This commit is contained in:
parent
febff07fde
commit
bd58bc337c
@ -9,12 +9,15 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
|
||||
ADD_DEFINITIONS(-DQT_NO_DEBUG)
|
||||
ADD_DEFINITIONS(-DQT_SHARED)
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${OCI_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(SYSTEM
|
||||
${OCI_INCLUDE_DIR}
|
||||
${Qt5Sql_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET(QSQLOCISPATIAL_SRC qsql_ocispatial.cpp main.cpp)
|
||||
QT5_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h main.h)
|
||||
QT5_WRAP_CPP(QSQLOCISPATIAL_MOC_SRC qsql_ocispatial.h main.h)
|
||||
|
||||
ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC})
|
||||
ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC} ${QSQLOCISPATIAL_MOC_SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(qsqlocispatial
|
||||
${QT_QTCORE_LIBRARY}
|
||||
|
@ -42,10 +42,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "main.h"
|
||||
#include <qsqldriverplugin.h>
|
||||
#include "qsql_ocispatial.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QOCISpatialDriverPlugin::QOCISpatialDriverPlugin()
|
||||
: QSqlDriverPlugin()
|
||||
{
|
||||
@ -60,12 +59,3 @@ QSqlDriver* QOCISpatialDriverPlugin::create( const QString &name )
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QStringList QOCISpatialDriverPlugin::keys() const
|
||||
{
|
||||
QStringList l;
|
||||
l << QLatin1String( "QOCISPATIAL8" ) << QLatin1String( "QOCISPATIAL" );
|
||||
return l;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -41,21 +41,16 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QOCISPATIAL_MAIN_H
|
||||
#define QOCISPATIAL_MAIN_H
|
||||
|
||||
#include <QSqlDriverPlugin>
|
||||
#include <QStringList>
|
||||
#include <qsqldriverplugin.h>
|
||||
#include "qsql_ocispatial.h"
|
||||
|
||||
class QOCISpatialDriverPlugin : public QSqlDriverPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA( IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "qocispatial.json" )
|
||||
|
||||
public:
|
||||
QOCISpatialDriverPlugin();
|
||||
|
||||
QSqlDriver* create( const QString & );
|
||||
QStringList keys() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,9 +42,7 @@
|
||||
#ifndef QSQL_OCISPATIAL_H
|
||||
#define QSQL_OCISPATIAL_H
|
||||
|
||||
#include <QtSql/qsqlresult.h>
|
||||
#include <QtSql/qsqldriver.h>
|
||||
#include "qsqlcachedresult_p.h"
|
||||
|
||||
#ifdef QT_PLUGIN
|
||||
#define Q_EXPORT_SQLDRIVER_OCISPATIAL
|
||||
@ -52,78 +50,48 @@
|
||||
#define Q_EXPORT_SQLDRIVER_OCISPATIAL Q_SQL_EXPORT
|
||||
#endif
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
typedef struct OCIEnv OCIEnv;
|
||||
typedef struct OCISvcCtx OCISvcCtx;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOCISpatialDriver;
|
||||
class QOCISpatialCols;
|
||||
struct QOCISpatialDriverPrivate;
|
||||
struct QOCISpatialResultPrivate;
|
||||
|
||||
class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialResult : public QSqlCachedResult
|
||||
{
|
||||
friend class QOCISpatialDriver;
|
||||
friend struct QOCISpatialResultPrivate;
|
||||
friend class QOCISpatialCols;
|
||||
public:
|
||||
QOCISpatialResult( const QOCISpatialDriver * db, const QOCISpatialDriverPrivate* p );
|
||||
~QOCISpatialResult();
|
||||
bool prepare( const QString& query );
|
||||
bool exec();
|
||||
QVariant handle() const;
|
||||
|
||||
protected:
|
||||
bool gotoNext( ValueCache &values, int index );
|
||||
bool reset( const QString& query );
|
||||
int size();
|
||||
int numRowsAffected();
|
||||
QSqlRecord record() const;
|
||||
QVariant lastInsertId() const;
|
||||
|
||||
private:
|
||||
QOCISpatialResultPrivate *d = nullptr;
|
||||
};
|
||||
class QSqlResult;
|
||||
class QOCISpatialDriverPrivate;
|
||||
|
||||
class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialDriver : public QSqlDriver
|
||||
{
|
||||
Q_DECLARE_PRIVATE( QOCISpatialDriver )
|
||||
Q_OBJECT
|
||||
friend struct QOCISpatialResultPrivate;
|
||||
friend class QOCISpatialPrivate;
|
||||
friend class QOCISpatialCols;
|
||||
friend class QOCISpatialResultPrivate;
|
||||
|
||||
public:
|
||||
explicit QOCISpatialDriver( QObject* parent = 0 );
|
||||
QOCISpatialDriver( OCIEnv* env, OCISvcCtx* ctx, QObject* parent = 0 );
|
||||
explicit QOCISpatialDriver( QObject* parent = nullptr );
|
||||
QOCISpatialDriver( OCIEnv* env, OCISvcCtx* ctx, QObject* parent = nullptr );
|
||||
~QOCISpatialDriver();
|
||||
bool hasFeature( DriverFeature f ) const;
|
||||
bool open( const QString & db,
|
||||
const QString & user,
|
||||
const QString & password,
|
||||
const QString & host,
|
||||
bool open( const QString &db,
|
||||
const QString &user,
|
||||
const QString &password,
|
||||
const QString &host,
|
||||
int port,
|
||||
const QString& connOpts );
|
||||
const QString &connOpts ) override;
|
||||
void close();
|
||||
QSqlResult *createResult() const;
|
||||
QStringList tables( QSql::TableType ) const;
|
||||
QSqlRecord record( const QString& tablename ) const;
|
||||
QSqlIndex primaryIndex( const QString& tablename ) const;
|
||||
QStringList tables( QSql::TableType ) const override;
|
||||
QSqlRecord record( const QString& tablename ) const override;
|
||||
QSqlIndex primaryIndex( const QString& tablename ) const override;
|
||||
QString formatValue( const QSqlField &field,
|
||||
bool trimStrings ) const;
|
||||
bool trimStrings ) const override;
|
||||
QVariant handle() const;
|
||||
QString escapeIdentifier( const QString &identifier, IdentifierType ) const;
|
||||
QString escapeIdentifier( const QString &identifier, IdentifierType ) const override;
|
||||
|
||||
protected:
|
||||
bool beginTransaction();
|
||||
bool commitTransaction();
|
||||
bool rollbackTransaction();
|
||||
private:
|
||||
QOCISpatialDriverPrivate *d = nullptr;
|
||||
bool beginTransaction() override;
|
||||
bool commitTransaction() override;
|
||||
bool rollbackTransaction() override;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QSQL_OCISPATIAL_H
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define WKBPTR_H
|
||||
|
||||
#include <QSharedData>
|
||||
#include <QVector>
|
||||
|
||||
union wkbPtr
|
||||
{
|
||||
|
@ -267,11 +267,11 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
|
||||
|
||||
if ( mFetchGeometry )
|
||||
{
|
||||
QByteArray *ba = static_cast<QByteArray*>( mQry.value( col++ ).data() );
|
||||
if ( ba->size() > 0 )
|
||||
QByteArray ba( mQry.value( col++ ).toByteArray() );
|
||||
if ( ba.size() > 0 )
|
||||
{
|
||||
QgsGeometry g;
|
||||
g.fromWkb( *ba );
|
||||
g.fromWkb( ba );
|
||||
feature.setGeometry( g );
|
||||
}
|
||||
else
|
||||
@ -375,11 +375,11 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
|
||||
QVariant v = mQry.value( col );
|
||||
if ( fld.type() == QVariant::ByteArray && fld.typeName().endsWith( ".SDO_GEOMETRY" ) )
|
||||
{
|
||||
QByteArray *ba = static_cast<QByteArray*>( v.data() );
|
||||
if ( ba->size() > 0 )
|
||||
QByteArray ba( v.toByteArray() );
|
||||
if ( ba.size() > 0 )
|
||||
{
|
||||
QgsGeometry g;
|
||||
g.fromWkb( *ba );
|
||||
g.fromWkb( ba );
|
||||
v = g.exportToWkt();
|
||||
}
|
||||
else
|
||||
|
@ -2244,9 +2244,9 @@ QgsRectangle QgsOracleProvider::extent() const
|
||||
|
||||
if ( ok && qry.next() )
|
||||
{
|
||||
QByteArray *ba = static_cast<QByteArray*>( qry.value( 0 ).data() );
|
||||
QByteArray ba( qry.value( 0 ).toByteArray() );
|
||||
QgsGeometry g;
|
||||
g.fromWkb( *ba );
|
||||
g.fromWkb( ba );
|
||||
mLayerExtent = g.boundingBox();
|
||||
QgsDebugMsg( "extent: " + mLayerExtent.toString() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user