@@ -313,13 +313,13 @@ void getGeometryType( const QgsVectorDataProvider* provider, QString& geometryTy
313
313
geometryWkbType = 0 ;
314
314
}
315
315
316
- int vtable_create_connect ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **out_vtab , char ** out_err , bool is_created )
316
+ int vtableCreateConnect ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **outVtab , char ** outErr , bool isCreated )
317
317
{
318
318
Q_UNUSED ( aux );
319
- Q_UNUSED ( is_created );
319
+ Q_UNUSED ( isCreated );
320
320
321
- #define RETURN_CSTR_ERROR (err ) if (out_err ) {size_t s = strlen (err); *out_err =reinterpret_cast <char *>(sqlite3_malloc ( static_cast <int >( s ) +1 )); strncpy (*out_err , err, s);}
322
- #define RETURN_CPPSTR_ERROR (err ) if (out_err ) {*out_err =reinterpret_cast <char *>(sqlite3_malloc ( static_cast <int >( err.size () )+1 )); strncpy (*out_err , err.c_str (), err.size ());}
321
+ #define RETURN_CSTR_ERROR (err ) if (outErr ) {size_t s = strlen (err); *outErr =reinterpret_cast <char *>(sqlite3_malloc ( static_cast <int >( s ) +1 )); strncpy (*outErr , err, s);}
322
+ #define RETURN_CPPSTR_ERROR (err ) if (outErr ) {*outErr =reinterpret_cast <char *>(sqlite3_malloc ( static_cast <int >( err.size () )+1 )); strncpy (*outErr , err.c_str (), err.size ());}
323
323
324
324
if ( argc < 4 )
325
325
{
@@ -328,7 +328,7 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
328
328
return SQLITE_ERROR;
329
329
}
330
330
331
- QScopedPointer<VTable> new_vtab ;
331
+ QScopedPointer<VTable> newVtab ;
332
332
QString vname ( argv[2 ] );
333
333
int r;
334
334
if ( argc == 4 )
@@ -344,15 +344,15 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
344
344
QgsMapLayer *l = QgsMapLayerRegistry::instance ()->mapLayer ( layerid );
345
345
if ( !l || l->type () != QgsMapLayer::VectorLayer )
346
346
{
347
- if ( out_err )
347
+ if ( outErr )
348
348
{
349
349
std::string err ( " Cannot find layer " );
350
350
err += argv[3 ];
351
351
RETURN_CPPSTR_ERROR ( err );
352
352
}
353
353
return SQLITE_ERROR;
354
354
}
355
- new_vtab .reset ( new VTable ( sql, static_cast <QgsVectorLayer*>( l ) ) );
355
+ newVtab .reset ( new VTable ( sql, static_cast <QgsVectorLayer*>( l ) ) );
356
356
357
357
}
358
358
else if ( argc == 5 || argc == 6 )
@@ -381,7 +381,7 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
381
381
}
382
382
try
383
383
{
384
- new_vtab .reset ( new VTable ( sql, provider, source, argv[2 ], encoding ) );
384
+ newVtab .reset ( new VTable ( sql, provider, source, argv[2 ], encoding ) );
385
385
}
386
386
catch ( std::runtime_error& e )
387
387
{
@@ -391,50 +391,50 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
391
391
}
392
392
}
393
393
394
- r = sqlite3_declare_vtab ( sql, new_vtab ->creationString ().toLocal8Bit ().constData () );
394
+ r = sqlite3_declare_vtab ( sql, newVtab ->creationString ().toLocal8Bit ().constData () );
395
395
if ( r )
396
396
{
397
397
RETURN_CSTR_ERROR ( sqlite3_errmsg ( sql ) );
398
398
return r;
399
399
}
400
400
401
- *out_vtab = reinterpret_cast < sqlite3_vtab* >( new_vtab .take () );
401
+ *outVtab = reinterpret_cast < sqlite3_vtab* >( newVtab .take () );
402
402
return SQLITE_OK;
403
403
#undef RETURN_CSTR_ERROR
404
404
#undef RETURN_CPPSTR_ERROR
405
405
}
406
406
407
- void db_init ( sqlite3* db )
407
+ void dbInit ( sqlite3* db )
408
408
{
409
409
// create metadata tables
410
410
initVirtualLayerMetadata ( db );
411
411
}
412
412
413
- int vtable_create ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **out_vtab , char ** out_err )
413
+ int vtableCreate ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **outVtab , char ** outErr )
414
414
{
415
415
try
416
416
{
417
- db_init ( sql );
417
+ dbInit ( sql );
418
418
}
419
419
catch ( std::runtime_error& e )
420
420
{
421
- if ( out_err )
421
+ if ( outErr )
422
422
{
423
- *out_err = reinterpret_cast < char * >( sqlite3_malloc ( static_cast < int >( strlen ( e.what () ) ) + 1 ) );
424
- strcpy ( *out_err , e.what () );
423
+ *outErr = reinterpret_cast < char * >( sqlite3_malloc ( static_cast < int >( strlen ( e.what () ) ) + 1 ) );
424
+ strcpy ( *outErr , e.what () );
425
425
}
426
426
return SQLITE_ERROR;
427
427
}
428
428
429
- return vtable_create_connect ( sql, aux, argc, argv, out_vtab, out_err , /* is_created */ true );
429
+ return vtableCreateConnect ( sql, aux, argc, argv, outVtab, outErr , /* is_created */ true );
430
430
}
431
431
432
- int vtable_connect ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **out_vtab , char ** out_err )
432
+ int vtableConnect ( sqlite3* sql, void * aux, int argc, const char * const * argv, sqlite3_vtab **outVtab , char ** outErr )
433
433
{
434
- return vtable_create_connect ( sql, aux, argc, argv, out_vtab, out_err , /* is_created */ false );
434
+ return vtableCreateConnect ( sql, aux, argc, argv, outVtab, outErr , /* is_created */ false );
435
435
}
436
436
437
- int vtable_destroy ( sqlite3_vtab *vtab )
437
+ int vtableDestroy ( sqlite3_vtab *vtab )
438
438
{
439
439
if ( vtab )
440
440
{
@@ -443,7 +443,7 @@ int vtable_destroy( sqlite3_vtab *vtab )
443
443
return SQLITE_OK;
444
444
}
445
445
446
- int vtable_disconnect ( sqlite3_vtab *vtab )
446
+ int vtableDisconnect ( sqlite3_vtab *vtab )
447
447
{
448
448
if ( vtab )
449
449
{
@@ -452,65 +452,65 @@ int vtable_disconnect( sqlite3_vtab *vtab )
452
452
return SQLITE_OK;
453
453
}
454
454
455
- int vtable_rename ( sqlite3_vtab *vtab, const char *new_name )
455
+ int vtableRename ( sqlite3_vtab *vtab, const char *newName )
456
456
{
457
457
Q_UNUSED ( vtab );
458
- Q_UNUSED ( new_name );
458
+ Q_UNUSED ( newName );
459
459
460
460
return SQLITE_OK;
461
461
}
462
462
463
- int vtable_bestindex ( sqlite3_vtab *pvtab, sqlite3_index_info* index_info )
463
+ int vtableBestIndex ( sqlite3_vtab *pvtab, sqlite3_index_info* indexInfo )
464
464
{
465
465
VTable *vtab = reinterpret_cast < VTable* >( pvtab );
466
- for ( int i = 0 ; i < index_info ->nConstraint ; i++ )
466
+ for ( int i = 0 ; i < indexInfo ->nConstraint ; i++ )
467
467
{
468
- if (( index_info ->aConstraint [i].usable ) &&
469
- ( vtab->pkColumn () == index_info ->aConstraint [i].iColumn ) &&
470
- ( index_info ->aConstraint [i].op == SQLITE_INDEX_CONSTRAINT_EQ ) )
468
+ if (( indexInfo ->aConstraint [i].usable ) &&
469
+ ( vtab->pkColumn () == indexInfo ->aConstraint [i].iColumn ) &&
470
+ ( indexInfo ->aConstraint [i].op == SQLITE_INDEX_CONSTRAINT_EQ ) )
471
471
{
472
472
// request for primary key filter
473
- index_info ->aConstraintUsage [i].argvIndex = 1 ;
474
- index_info ->aConstraintUsage [i].omit = 1 ;
475
- index_info ->idxNum = 1 ; // PK filter
476
- index_info ->estimatedCost = 1.0 ; // ??
477
- // index_info ->estimatedRows = 1;
478
- index_info ->idxStr = nullptr ;
479
- index_info ->needToFreeIdxStr = 0 ;
473
+ indexInfo ->aConstraintUsage [i].argvIndex = 1 ;
474
+ indexInfo ->aConstraintUsage [i].omit = 1 ;
475
+ indexInfo ->idxNum = 1 ; // PK filter
476
+ indexInfo ->estimatedCost = 1.0 ; // ??
477
+ // indexInfo ->estimatedRows = 1;
478
+ indexInfo ->idxStr = nullptr ;
479
+ indexInfo ->needToFreeIdxStr = 0 ;
480
480
return SQLITE_OK;
481
481
}
482
- if (( index_info ->aConstraint [i].usable ) &&
483
- ( 0 == index_info ->aConstraint [i].iColumn ) &&
484
- ( index_info ->aConstraint [i].op == SQLITE_INDEX_CONSTRAINT_EQ ) )
482
+ if (( indexInfo ->aConstraint [i].usable ) &&
483
+ ( 0 == indexInfo ->aConstraint [i].iColumn ) &&
484
+ ( indexInfo ->aConstraint [i].op == SQLITE_INDEX_CONSTRAINT_EQ ) )
485
485
{
486
486
// request for rtree filtering
487
- index_info ->aConstraintUsage [i].argvIndex = 1 ;
487
+ indexInfo ->aConstraintUsage [i].argvIndex = 1 ;
488
488
// do not test for equality, since it is used for filtering, not to return an actual value
489
- index_info ->aConstraintUsage [i].omit = 1 ;
490
- index_info ->idxNum = 2 ; // RTree filter
491
- index_info ->estimatedCost = 1.0 ; // ??
492
- // index_info ->estimatedRows = 1;
493
- index_info ->idxStr = nullptr ;
494
- index_info ->needToFreeIdxStr = 0 ;
489
+ indexInfo ->aConstraintUsage [i].omit = 1 ;
490
+ indexInfo ->idxNum = 2 ; // RTree filter
491
+ indexInfo ->estimatedCost = 1.0 ; // ??
492
+ // indexInfo ->estimatedRows = 1;
493
+ indexInfo ->idxStr = nullptr ;
494
+ indexInfo ->needToFreeIdxStr = 0 ;
495
495
return SQLITE_OK;
496
496
}
497
497
}
498
- index_info ->idxNum = 0 ;
499
- index_info ->estimatedCost = 10.0 ;
500
- // index_info ->estimatedRows = 10;
501
- index_info ->idxStr = nullptr ;
502
- index_info ->needToFreeIdxStr = 0 ;
498
+ indexInfo ->idxNum = 0 ;
499
+ indexInfo ->estimatedCost = 10.0 ;
500
+ // indexInfo ->estimatedRows = 10;
501
+ indexInfo ->idxStr = nullptr ;
502
+ indexInfo ->needToFreeIdxStr = 0 ;
503
503
return SQLITE_OK;
504
504
}
505
505
506
- int vtable_open ( sqlite3_vtab *vtab, sqlite3_vtab_cursor **out_cursor )
506
+ int vtableOpen ( sqlite3_vtab *vtab, sqlite3_vtab_cursor **outCursor )
507
507
{
508
508
VTableCursor *ncursor = new VTableCursor ( reinterpret_cast < VTable* >( vtab ) );
509
- *out_cursor = reinterpret_cast < sqlite3_vtab_cursor* >( ncursor );
509
+ *outCursor = reinterpret_cast < sqlite3_vtab_cursor* >( ncursor );
510
510
return SQLITE_OK;
511
511
}
512
512
513
- int vtable_close ( sqlite3_vtab_cursor * cursor )
513
+ int vtableClose ( sqlite3_vtab_cursor * cursor )
514
514
{
515
515
if ( cursor )
516
516
{
@@ -519,7 +519,7 @@ int vtable_close( sqlite3_vtab_cursor * cursor )
519
519
return SQLITE_OK;
520
520
}
521
521
522
- int vtable_filter ( sqlite3_vtab_cursor * cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv )
522
+ int vtableFilter ( sqlite3_vtab_cursor * cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv )
523
523
{
524
524
Q_UNUSED ( argc );
525
525
Q_UNUSED ( idxStr );
@@ -543,28 +543,28 @@ int vtable_filter( sqlite3_vtab_cursor * cursor, int idxNum, const char *idxStr,
543
543
return SQLITE_OK;
544
544
}
545
545
546
- int vtable_next ( sqlite3_vtab_cursor *cursor )
546
+ int vtableNext ( sqlite3_vtab_cursor *cursor )
547
547
{
548
548
VTableCursor* c = reinterpret_cast <VTableCursor*>( cursor );
549
549
c->next ();
550
550
return SQLITE_OK;
551
551
}
552
552
553
- int vtable_eof ( sqlite3_vtab_cursor *cursor )
553
+ int vtableEof ( sqlite3_vtab_cursor *cursor )
554
554
{
555
555
VTableCursor* c = reinterpret_cast <VTableCursor*>( cursor );
556
556
return c->eof ();
557
557
}
558
558
559
- int vtable_rowid ( sqlite3_vtab_cursor *cursor, sqlite3_int64 *out_rowid )
559
+ int vtableRowId ( sqlite3_vtab_cursor *cursor, sqlite3_int64 *outRowid )
560
560
{
561
561
VTableCursor* c = reinterpret_cast <VTableCursor*>( cursor );
562
- *out_rowid = c->currentId ();
562
+ *outRowid = c->currentId ();
563
563
564
564
return SQLITE_OK;
565
565
}
566
566
567
- int vtable_column ( sqlite3_vtab_cursor *cursor, sqlite3_context* ctxt, int idx )
567
+ int vtableColumn ( sqlite3_vtab_cursor *cursor, sqlite3_context* ctxt, int idx )
568
568
{
569
569
VTableCursor* c = reinterpret_cast <VTableCursor*>( cursor );
570
570
if ( idx == 0 )
@@ -611,29 +611,14 @@ int vtable_column( sqlite3_vtab_cursor *cursor, sqlite3_context* ctxt, int idx )
611
611
return SQLITE_OK;
612
612
}
613
613
614
- int vtable_findfunction ( sqlite3_vtab *pVtab,
615
- int nArg,
616
- const char *zName,
617
- void ( **pxFunc )( sqlite3_context*, int , sqlite3_value** ),
618
- void **ppArg )
619
- {
620
- Q_UNUSED ( pVtab );
621
- Q_UNUSED ( nArg );
622
- Q_UNUSED ( zName );
623
- Q_UNUSED ( pxFunc );
624
- Q_UNUSED ( ppArg );
625
- return SQLITE_OK;
626
- }
627
-
628
-
629
614
630
- static QCoreApplication* core_app = nullptr ;
615
+ static QCoreApplication* coreApp = nullptr ;
631
616
632
- void module_destroy ( void * )
617
+ void moduleDestroy ( void * )
633
618
{
634
- if ( core_app )
619
+ if ( coreApp )
635
620
{
636
- delete core_app ;
621
+ delete coreApp ;
637
622
}
638
623
}
639
624
@@ -809,7 +794,7 @@ void registerQgisFunctions( sqlite3* db )
809
794
qgisFunctionExpressionContext << QgsExpressionContextUtils::projectScope ();
810
795
}
811
796
812
- int qgsvlayer_module_init ( sqlite3 *db, char **pzErrMsg, void * unused /* const sqlite3_api_routines *pApi*/ )
797
+ int qgsvlayerModuleInit ( sqlite3 *db, char **pzErrMsg, void * unused /* const sqlite3_api_routines *pApi*/ )
813
798
{
814
799
Q_UNUSED ( pzErrMsg );
815
800
Q_UNUSED ( unused );
@@ -820,28 +805,28 @@ int qgsvlayer_module_init( sqlite3 *db, char **pzErrMsg, void * unused /*const s
820
805
if ( !QCoreApplication::instance () )
821
806
{
822
807
// if run standalone
823
- static int module_argc = 1 ;
824
- static char module_name [] = " qgsvlayer_module" ;
825
- static char * module_argv [] = { module_name };
826
- core_app = new QCoreApplication ( module_argc, module_argv );
808
+ static int moduleArgc = 1 ;
809
+ static char moduleName [] = " qgsvlayer_module" ;
810
+ static char * moduleArgv [] = { moduleName };
811
+ coreApp = new QCoreApplication ( moduleArgc, moduleArgv );
827
812
QgsApplication::init ();
828
813
QgsApplication::initQgis ();
829
814
}
830
815
831
816
static sqlite3_module module;
832
- module.xCreate = vtable_create ;
833
- module.xConnect = vtable_connect ;
834
- module.xBestIndex = vtable_bestindex ;
835
- module.xDisconnect = vtable_disconnect ;
836
- module.xDestroy = vtable_destroy ;
837
- module.xOpen = vtable_open ;
838
- module.xClose = vtable_close ;
839
- module.xFilter = vtable_filter ;
840
- module.xNext = vtable_next ;
841
- module.xEof = vtable_eof ;
842
- module.xColumn = vtable_column ;
843
- module.xRowid = vtable_rowid ;
844
- module.xRename = vtable_rename ;
817
+ module.xCreate = vtableCreate ;
818
+ module.xConnect = vtableConnect ;
819
+ module.xBestIndex = vtableBestIndex ;
820
+ module.xDisconnect = vtableDisconnect ;
821
+ module.xDestroy = vtableDestroy ;
822
+ module.xOpen = vtableOpen ;
823
+ module.xClose = vtableClose ;
824
+ module.xFilter = vtableFilter ;
825
+ module.xNext = vtableNext ;
826
+ module.xEof = vtableEof ;
827
+ module.xColumn = vtableColumn ;
828
+ module.xRowid = vtableRowId ;
829
+ module.xRename = vtableRename ;
845
830
846
831
module.xUpdate = nullptr ;
847
832
module.xBegin = nullptr ;
@@ -853,7 +838,7 @@ int qgsvlayer_module_init( sqlite3 *db, char **pzErrMsg, void * unused /*const s
853
838
module.xRelease = nullptr ;
854
839
module.xRollbackTo = nullptr ;
855
840
856
- sqlite3_create_module_v2 ( db, " QgsVLayer" , &module, nullptr , module_destroy );
841
+ sqlite3_create_module_v2 ( db, " QgsVLayer" , &module, nullptr , moduleDestroy );
857
842
858
843
registerQgisFunctions ( db );
859
844
0 commit comments