Skip to content

Commit f3e0438

Browse files
committedApr 13, 2016
spatialite provider: remove m prefixes in extern functions (followup 1050174)
1 parent 23daead commit f3e0438

File tree

1 file changed

+42
-59
lines changed

1 file changed

+42
-59
lines changed
 

‎src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 42 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,12 @@ QgsSpatiaLiteProvider::createEmptyLayer(
121121

122122
// create the table
123123
{
124-
QgsSqliteHandle *handle;
125-
sqlite3 *mSqliteHandle = nullptr;
126124
char *errMsg = nullptr;
127125
int toCommit = false;
128126
QString sql;
129127

130128
// trying to open the SQLite DB
131-
handle = QgsSqliteHandle::openDb( sqlitePath );
129+
QgsSqliteHandle *handle = QgsSqliteHandle::openDb( sqlitePath );
132130
if ( !handle )
133131
{
134132
QgsDebugMsg( "Connection to database failed. Import of layer aborted." );
@@ -137,7 +135,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
137135
return QgsVectorLayerImport::ErrConnectionFailed;
138136
}
139137

140-
mSqliteHandle = handle->handle();
138+
sqlite3 *sqliteHandle = handle->handle();
141139

142140
// get the pk's name and type
143141
if ( primaryKey.isEmpty() )
@@ -190,7 +188,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
190188

191189
try
192190
{
193-
int ret = sqlite3_exec( mSqliteHandle, "BEGIN", nullptr, nullptr, &errMsg );
191+
int ret = sqlite3_exec( sqliteHandle, "BEGIN", nullptr, nullptr, &errMsg );
194192
if ( ret != SQLITE_OK )
195193
throw SLException( errMsg );
196194

@@ -202,14 +200,14 @@ QgsSpatiaLiteProvider::createEmptyLayer(
202200
sql = QString( "DROP TABLE IF EXISTS %1" )
203201
.arg( quotedIdentifier( tableName ) );
204202

205-
ret = sqlite3_exec( mSqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
203+
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
206204
if ( ret != SQLITE_OK )
207205
throw SLException( errMsg );
208206

209207
sql = QString( "DELETE FROM geometry_columns WHERE upper(f_table_name) = upper(%1)" )
210208
.arg( quotedValue( tableName ) );
211209

212-
ret = sqlite3_exec( mSqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
210+
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
213211
if ( ret != SQLITE_OK )
214212
throw SLException( errMsg );
215213
}
@@ -219,7 +217,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
219217
quotedIdentifier( primaryKey ),
220218
primaryKeyType );
221219

222-
ret = sqlite3_exec( mSqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
220+
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
223221
if ( ret != SQLITE_OK )
224222
throw SLException( errMsg );
225223

@@ -291,7 +289,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
291289
.arg( QgsSpatiaLiteProvider::quotedValue( geometryType ) )
292290
.arg( dim );
293291

294-
ret = sqlite3_exec( mSqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
292+
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
295293
if ( ret != SQLITE_OK )
296294
throw SLException( errMsg );
297295
}
@@ -300,7 +298,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
300298
geometryColumn = QString();
301299
}
302300

303-
ret = sqlite3_exec( mSqliteHandle, "COMMIT", nullptr, nullptr, &errMsg );
301+
ret = sqlite3_exec( sqliteHandle, "COMMIT", nullptr, nullptr, &errMsg );
304302
if ( ret != SQLITE_OK )
305303
throw SLException( errMsg );
306304

@@ -321,7 +319,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
321319
if ( toCommit )
322320
{
323321
// ROLLBACK after some previous error
324-
sqlite3_exec( mSqliteHandle, "ROLLBACK", nullptr, nullptr, nullptr );
322+
sqlite3_exec( sqliteHandle, "ROLLBACK", nullptr, nullptr, nullptr );
325323
}
326324

327325
QgsSqliteHandle::closeDb( handle );
@@ -5259,32 +5257,29 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
52595257
const QString& styleName, const QString& styleDescription,
52605258
const QString& uiFileContent, bool useAsDefault, QString& errCause )
52615259
{
5262-
QgsSqliteHandle *handle;
5263-
sqlite3 *mSqliteHandle = nullptr;
5264-
char **results;
5265-
int rows;
5266-
int columns;
5267-
char *errMsg = nullptr;
5268-
52695260
QgsDataSourceURI dsUri( uri );
52705261
QString sqlitePath = dsUri.database();
52715262
QgsDebugMsg( "Database is: " + sqlitePath );
52725263

52735264
// trying to open the SQLite DB
5274-
handle = QgsSqliteHandle::openDb( sqlitePath );
5265+
QgsSqliteHandle *handle = QgsSqliteHandle::openDb( sqlitePath );
52755266
if ( !handle )
52765267
{
52775268
QgsDebugMsg( "Connection to database failed. Save style aborted." );
52785269
errCause = QObject::tr( "Connection to database failed" );
52795270
return false;
52805271
}
52815272

5282-
mSqliteHandle = handle->handle();
5273+
sqlite3 *sqliteHandle = handle->handle();
52835274

52845275
// check if layer_styles table already exist
52855276
QString countIfExist = QString( "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='%1';" ).arg( "layer_styles" );
52865277

5287-
int ret = sqlite3_get_table( mSqliteHandle, countIfExist.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5278+
char **results;
5279+
int rows;
5280+
int columns;
5281+
char *errMsg = nullptr;
5282+
int ret = sqlite3_get_table( sqliteHandle, countIfExist.toUtf8().constData(), &results, &rows, &columns, &errMsg );
52885283
if ( SQLITE_OK != ret )
52895284
{
52905285
QgsSqliteHandle::closeDb( handle );
@@ -5320,7 +5315,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53205315
",ui text"
53215316
",update_time timestamp DEFAULT CURRENT_TIMESTAMP"
53225317
")" );
5323-
ret = sqlite3_exec( mSqliteHandle, createQuery.toUtf8().constData(), nullptr, nullptr, &errMsg );
5318+
ret = sqlite3_exec( sqliteHandle, createQuery.toUtf8().constData(), nullptr, nullptr, &errMsg );
53245319
if ( SQLITE_OK != ret )
53255320
{
53265321
QgsSqliteHandle::closeDb( handle );
@@ -5368,7 +5363,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
53685363
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) )
53695364
.arg( QgsSpatiaLiteProvider::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) );
53705365

5371-
ret = sqlite3_get_table( mSqliteHandle, checkQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5366+
ret = sqlite3_get_table( sqliteHandle, checkQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
53725367
if ( SQLITE_OK != ret )
53735368
{
53745369
QgsSqliteHandle::closeDb( handle );
@@ -5428,7 +5423,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
54285423
sql = QString( "BEGIN; %1; %2; COMMIT;" ).arg( removeDefaultSql, sql );
54295424
}
54305425

5431-
ret = sqlite3_exec( mSqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
5426+
ret = sqlite3_exec( sqliteHandle, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
54325427
if ( SQLITE_OK != ret )
54335428
{
54345429
QgsSqliteHandle::closeDb( handle );
@@ -5447,28 +5442,20 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
54475442

54485443
QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
54495444
{
5450-
QgsSqliteHandle *handle;
5451-
sqlite3 *mSqliteHandle = nullptr;
5452-
char **results;
5453-
int rows;
5454-
int columns;
5455-
char *errMsg = nullptr;
5456-
QString sql;
5457-
54585445
QgsDataSourceURI dsUri( uri );
54595446
QString sqlitePath = dsUri.database();
54605447
QgsDebugMsg( "Database is: " + sqlitePath );
54615448

54625449
// trying to open the SQLite DB
5463-
handle = QgsSqliteHandle::openDb( sqlitePath );
5450+
QgsSqliteHandle *handle = QgsSqliteHandle::openDb( sqlitePath );
54645451
if ( !handle )
54655452
{
54665453
QgsDebugMsg( "Connection to database failed. Save style aborted." );
54675454
errCause = QObject::tr( "Connection to database failed" );
54685455
return "";
54695456
}
54705457

5471-
mSqliteHandle = handle->handle();
5458+
sqlite3 *sqliteHandle = handle->handle();
54725459

54735460
QString selectQmlQuery = QString( "SELECT styleQML"
54745461
" FROM layer_styles"
@@ -5483,7 +5470,11 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
54835470
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
54845471
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
54855472

5486-
int ret = sqlite3_get_table( mSqliteHandle, selectQmlQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5473+
char **results;
5474+
int rows;
5475+
int columns;
5476+
char *errMsg = nullptr;
5477+
int ret = sqlite3_get_table( sqliteHandle, selectQmlQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
54875478
if ( SQLITE_OK != ret )
54885479
{
54895480
QgsSqliteHandle::closeDb( handle );
@@ -5502,33 +5493,29 @@ QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
55025493
QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &names,
55035494
QStringList &descriptions, QString& errCause )
55045495
{
5505-
QgsSqliteHandle *handle;
5506-
sqlite3 *mSqliteHandle = nullptr;
5507-
char **results;
5508-
int rows;
5509-
int columns;
5510-
char *errMsg = nullptr;
5511-
QString sql;
5512-
55135496
QgsDataSourceURI dsUri( uri );
55145497
QString sqlitePath = dsUri.database();
55155498
QgsDebugMsg( "Database is: " + sqlitePath );
55165499

55175500
// trying to open the SQLite DB
5518-
handle = QgsSqliteHandle::openDb( sqlitePath );
5501+
QgsSqliteHandle *handle = QgsSqliteHandle::openDb( sqlitePath );
55195502
if ( !handle )
55205503
{
55215504
QgsDebugMsg( "Connection to database failed. Save style aborted." );
55225505
errCause = QObject::tr( "Connection to database failed" );
55235506
return -1;
55245507
}
55255508

5526-
mSqliteHandle = handle->handle();
5509+
sqlite3 *sqliteHandle = handle->handle();
55275510

55285511
// check if layer_styles table already exist
55295512
QString countIfExist = QString( "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='%1';" ).arg( "layer_styles" );
55305513

5531-
int ret = sqlite3_get_table( mSqliteHandle, countIfExist.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5514+
char **results;
5515+
int rows;
5516+
int columns;
5517+
char *errMsg = nullptr;
5518+
int ret = sqlite3_get_table( sqliteHandle, countIfExist.toUtf8().constData(), &results, &rows, &columns, &errMsg );
55325519
if ( SQLITE_OK != ret )
55335520
{
55345521
QgsSqliteHandle::closeDb( handle );
@@ -5564,7 +5551,7 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55645551
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55655552
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
55665553

5567-
ret = sqlite3_get_table( mSqliteHandle, selectRelatedQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5554+
ret = sqlite3_get_table( sqliteHandle, selectRelatedQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
55685555
if ( SQLITE_OK != ret )
55695556
{
55705557
QgsSqliteHandle::closeDb( handle );
@@ -5591,7 +5578,7 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
55915578
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.table() ) )
55925579
.arg( QgsSpatiaLiteProvider::quotedValue( dsUri.geometryColumn() ) );
55935580

5594-
ret = sqlite3_get_table( mSqliteHandle, selectOthersQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5581+
ret = sqlite3_get_table( sqliteHandle, selectOthersQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
55955582
if ( SQLITE_OK != ret )
55965583
{
55975584
QgsSqliteHandle::closeDb( handle );
@@ -5614,32 +5601,28 @@ QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &na
56145601

56155602
QGISEXTERN QString getStyleById( const QString& uri, QString styleId, QString& errCause )
56165603
{
5617-
QgsSqliteHandle *handle;
5618-
sqlite3 *mSqliteHandle = nullptr;
5619-
char **results;
5620-
int rows;
5621-
int columns;
5622-
char *errMsg = nullptr;
5623-
QString sql;
5624-
56255604
QgsDataSourceURI dsUri( uri );
56265605
QString sqlitePath = dsUri.database();
56275606
QgsDebugMsg( "Database is: " + sqlitePath );
56285607

56295608
// trying to open the SQLite DB
5630-
handle = QgsSqliteHandle::openDb( sqlitePath );
5609+
QgsSqliteHandle *handle = QgsSqliteHandle::openDb( sqlitePath );
56315610
if ( !handle )
56325611
{
56335612
QgsDebugMsg( "Connection to database failed. Save style aborted." );
56345613
errCause = QObject::tr( "Connection to database failed" );
56355614
return "";
56365615
}
56375616

5638-
mSqliteHandle = handle->handle();
5617+
sqlite3 *sqliteHandle = handle->handle();
56395618

56405619
QString style;
56415620
QString selectQmlQuery = QString( "SELECT styleQml FROM layer_styles WHERE id=%1" ).arg( QgsSpatiaLiteProvider::quotedValue( styleId ) );
5642-
int ret = sqlite3_get_table( mSqliteHandle, selectQmlQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
5621+
char **results;
5622+
int rows;
5623+
int columns;
5624+
char *errMsg = nullptr;
5625+
int ret = sqlite3_get_table( sqliteHandle, selectQmlQuery.toUtf8().constData(), &results, &rows, &columns, &errMsg );
56435626
if ( SQLITE_OK == ret )
56445627
{
56455628
if ( 1 == rows )

0 commit comments

Comments
 (0)
Please sign in to comment.