Skip to content

Commit 1c44122

Browse files
author
Hugo Mercier
committed
Style fix (snake case to camel case)
1 parent 1d7b281 commit 1c44122

File tree

4 files changed

+105
-127
lines changed

4 files changed

+105
-127
lines changed

src/providers/virtual/qgsvirtuallayersqlitehelper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString& path, bool withExtension )
2727
{
2828
// register a statically-linked function as extension
2929
// for all future database connection
30-
sqlite3_auto_extension( reinterpret_cast < void( * )() > ( qgsvlayer_module_init ) );
30+
sqlite3_auto_extension( reinterpret_cast < void( * )() > ( qgsvlayerModuleInit ) );
3131
}
3232
int r;
3333
r = sqlite3_open( path.toLocal8Bit().constData(), &db_ );

src/providers/virtual/qgsvirtuallayersqlitehelper.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ extern "C"
2121
{
2222
#include <sqlite3.h>
2323

24-
int qgsvlayer_module_init( sqlite3 *db,
25-
char **pzErrMsg,
26-
void * unused /*const sqlite3_api_routines *pApi*/ );
24+
int qgsvlayerModuleInit( sqlite3 *db,
25+
char **pzErrMsg,
26+
void * unused /*const sqlite3_api_routines *pApi*/ );
2727

2828
}
2929

src/providers/virtual/qgsvirtuallayersqlitemodule.cpp

+82-97
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,13 @@ void getGeometryType( const QgsVectorDataProvider* provider, QString& geometryTy
313313
geometryWkbType = 0;
314314
}
315315

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 )
317317
{
318318
Q_UNUSED( aux );
319-
Q_UNUSED( is_created );
319+
Q_UNUSED( isCreated );
320320

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());}
323323

324324
if ( argc < 4 )
325325
{
@@ -328,7 +328,7 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
328328
return SQLITE_ERROR;
329329
}
330330

331-
QScopedPointer<VTable> new_vtab;
331+
QScopedPointer<VTable> newVtab;
332332
QString vname( argv[2] );
333333
int r;
334334
if ( argc == 4 )
@@ -344,15 +344,15 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
344344
QgsMapLayer *l = QgsMapLayerRegistry::instance()->mapLayer( layerid );
345345
if ( !l || l->type() != QgsMapLayer::VectorLayer )
346346
{
347-
if ( out_err )
347+
if ( outErr )
348348
{
349349
std::string err( "Cannot find layer " );
350350
err += argv[3];
351351
RETURN_CPPSTR_ERROR( err );
352352
}
353353
return SQLITE_ERROR;
354354
}
355-
new_vtab.reset( new VTable( sql, static_cast<QgsVectorLayer*>( l ) ) );
355+
newVtab.reset( new VTable( sql, static_cast<QgsVectorLayer*>( l ) ) );
356356

357357
}
358358
else if ( argc == 5 || argc == 6 )
@@ -381,7 +381,7 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
381381
}
382382
try
383383
{
384-
new_vtab.reset( new VTable( sql, provider, source, argv[2], encoding ) );
384+
newVtab.reset( new VTable( sql, provider, source, argv[2], encoding ) );
385385
}
386386
catch ( std::runtime_error& e )
387387
{
@@ -391,50 +391,50 @@ int vtable_create_connect( sqlite3* sql, void* aux, int argc, const char* const*
391391
}
392392
}
393393

394-
r = sqlite3_declare_vtab( sql, new_vtab->creationString().toLocal8Bit().constData() );
394+
r = sqlite3_declare_vtab( sql, newVtab->creationString().toLocal8Bit().constData() );
395395
if ( r )
396396
{
397397
RETURN_CSTR_ERROR( sqlite3_errmsg( sql ) );
398398
return r;
399399
}
400400

401-
*out_vtab = reinterpret_cast< sqlite3_vtab* >( new_vtab.take() );
401+
*outVtab = reinterpret_cast< sqlite3_vtab* >( newVtab.take() );
402402
return SQLITE_OK;
403403
#undef RETURN_CSTR_ERROR
404404
#undef RETURN_CPPSTR_ERROR
405405
}
406406

407-
void db_init( sqlite3* db )
407+
void dbInit( sqlite3* db )
408408
{
409409
// create metadata tables
410410
initVirtualLayerMetadata( db );
411411
}
412412

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 )
414414
{
415415
try
416416
{
417-
db_init( sql );
417+
dbInit( sql );
418418
}
419419
catch ( std::runtime_error& e )
420420
{
421-
if ( out_err )
421+
if ( outErr )
422422
{
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() );
425425
}
426426
return SQLITE_ERROR;
427427
}
428428

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 );
430430
}
431431

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 )
433433
{
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 );
435435
}
436436

437-
int vtable_destroy( sqlite3_vtab *vtab )
437+
int vtableDestroy( sqlite3_vtab *vtab )
438438
{
439439
if ( vtab )
440440
{
@@ -443,7 +443,7 @@ int vtable_destroy( sqlite3_vtab *vtab )
443443
return SQLITE_OK;
444444
}
445445

446-
int vtable_disconnect( sqlite3_vtab *vtab )
446+
int vtableDisconnect( sqlite3_vtab *vtab )
447447
{
448448
if ( vtab )
449449
{
@@ -452,65 +452,65 @@ int vtable_disconnect( sqlite3_vtab *vtab )
452452
return SQLITE_OK;
453453
}
454454

455-
int vtable_rename( sqlite3_vtab *vtab, const char *new_name )
455+
int vtableRename( sqlite3_vtab *vtab, const char *newName )
456456
{
457457
Q_UNUSED( vtab );
458-
Q_UNUSED( new_name );
458+
Q_UNUSED( newName );
459459

460460
return SQLITE_OK;
461461
}
462462

463-
int vtable_bestindex( sqlite3_vtab *pvtab, sqlite3_index_info* index_info )
463+
int vtableBestIndex( sqlite3_vtab *pvtab, sqlite3_index_info* indexInfo )
464464
{
465465
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++ )
467467
{
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 ) )
471471
{
472472
// 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;
480480
return SQLITE_OK;
481481
}
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 ) )
485485
{
486486
// request for rtree filtering
487-
index_info->aConstraintUsage[i].argvIndex = 1;
487+
indexInfo->aConstraintUsage[i].argvIndex = 1;
488488
// 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;
495495
return SQLITE_OK;
496496
}
497497
}
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;
503503
return SQLITE_OK;
504504
}
505505

506-
int vtable_open( sqlite3_vtab *vtab, sqlite3_vtab_cursor **out_cursor )
506+
int vtableOpen( sqlite3_vtab *vtab, sqlite3_vtab_cursor **outCursor )
507507
{
508508
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 );
510510
return SQLITE_OK;
511511
}
512512

513-
int vtable_close( sqlite3_vtab_cursor * cursor )
513+
int vtableClose( sqlite3_vtab_cursor * cursor )
514514
{
515515
if ( cursor )
516516
{
@@ -519,7 +519,7 @@ int vtable_close( sqlite3_vtab_cursor * cursor )
519519
return SQLITE_OK;
520520
}
521521

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 )
523523
{
524524
Q_UNUSED( argc );
525525
Q_UNUSED( idxStr );
@@ -543,28 +543,28 @@ int vtable_filter( sqlite3_vtab_cursor * cursor, int idxNum, const char *idxStr,
543543
return SQLITE_OK;
544544
}
545545

546-
int vtable_next( sqlite3_vtab_cursor *cursor )
546+
int vtableNext( sqlite3_vtab_cursor *cursor )
547547
{
548548
VTableCursor* c = reinterpret_cast<VTableCursor*>( cursor );
549549
c->next();
550550
return SQLITE_OK;
551551
}
552552

553-
int vtable_eof( sqlite3_vtab_cursor *cursor )
553+
int vtableEof( sqlite3_vtab_cursor *cursor )
554554
{
555555
VTableCursor* c = reinterpret_cast<VTableCursor*>( cursor );
556556
return c->eof();
557557
}
558558

559-
int vtable_rowid( sqlite3_vtab_cursor *cursor, sqlite3_int64 *out_rowid )
559+
int vtableRowId( sqlite3_vtab_cursor *cursor, sqlite3_int64 *outRowid )
560560
{
561561
VTableCursor* c = reinterpret_cast<VTableCursor*>( cursor );
562-
*out_rowid = c->currentId();
562+
*outRowid = c->currentId();
563563

564564
return SQLITE_OK;
565565
}
566566

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 )
568568
{
569569
VTableCursor* c = reinterpret_cast<VTableCursor*>( cursor );
570570
if ( idx == 0 )
@@ -611,29 +611,14 @@ int vtable_column( sqlite3_vtab_cursor *cursor, sqlite3_context* ctxt, int idx )
611611
return SQLITE_OK;
612612
}
613613

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-
629614

630-
static QCoreApplication* core_app = nullptr;
615+
static QCoreApplication* coreApp = nullptr;
631616

632-
void module_destroy( void* )
617+
void moduleDestroy( void* )
633618
{
634-
if ( core_app )
619+
if ( coreApp )
635620
{
636-
delete core_app;
621+
delete coreApp;
637622
}
638623
}
639624

@@ -809,7 +794,7 @@ void registerQgisFunctions( sqlite3* db )
809794
qgisFunctionExpressionContext << QgsExpressionContextUtils::projectScope();
810795
}
811796

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*/ )
813798
{
814799
Q_UNUSED( pzErrMsg );
815800
Q_UNUSED( unused );
@@ -820,28 +805,28 @@ int qgsvlayer_module_init( sqlite3 *db, char **pzErrMsg, void * unused /*const s
820805
if ( !QCoreApplication::instance() )
821806
{
822807
// 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 );
827812
QgsApplication::init();
828813
QgsApplication::initQgis();
829814
}
830815

831816
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;
845830

846831
module.xUpdate = nullptr;
847832
module.xBegin = nullptr;
@@ -853,7 +838,7 @@ int qgsvlayer_module_init( sqlite3 *db, char **pzErrMsg, void * unused /*const s
853838
module.xRelease = nullptr;
854839
module.xRollbackTo = nullptr;
855840

856-
sqlite3_create_module_v2( db, "QgsVLayer", &module, nullptr, module_destroy );
841+
sqlite3_create_module_v2( db, "QgsVLayer", &module, nullptr, moduleDestroy );
857842

858843
registerQgisFunctions( db );
859844

0 commit comments

Comments
 (0)