QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCSqlHelper::ScopedConnection Class Reference

RAII wrapper around QSqlDatabase::addDatabase / removeDatabase. More...

#include <QGCSqlHelper.h>

Public Member Functions

 ScopedConnection (const QString &dbPath, bool readOnly=false, const QString &prefix=QStringLiteral("QGCSql"))
 
 ~ScopedConnection ()
 
 ScopedConnection (const ScopedConnection &)=delete
 
ScopedConnectionoperator= (const ScopedConnection &)=delete
 
 ScopedConnection (ScopedConnection &&)=delete
 
ScopedConnectionoperator= (ScopedConnection &&)=delete
 
bool isValid () const
 
QSqlDatabase database () const
 

Detailed Description

RAII wrapper around QSqlDatabase::addDatabase / removeDatabase.

Creates a uniquely-named connection on construction, removes it on destruction. Avoids the common pitfall of reusing connection names or forgetting to call removeDatabase.

Definition at line 40 of file QGCSqlHelper.h.

Constructor & Destructor Documentation

◆ ScopedConnection() [1/3]

QGCSqlHelper::ScopedConnection::ScopedConnection ( const QString &  dbPath,
bool  readOnly = false,
const QString &  prefix = QStringLiteral("QGCSql") 
)
explicit

Opens a connection to dbPath using the QSQLITE driver. prefix is prepended to the auto-generated connection name; useful for distinguishing concurrent connections in logs / Qt's connection registry. If readOnly is true, QSQLITE_OPEN_READONLY is set.

Definition at line 60 of file QGCSqlHelper.cc.

References QGCSqlHelper::applySqlitePragmas().

◆ ~ScopedConnection()

QGCSqlHelper::ScopedConnection::~ScopedConnection ( )

Definition at line 80 of file QGCSqlHelper.cc.

◆ ScopedConnection() [2/3]

QGCSqlHelper::ScopedConnection::ScopedConnection ( const ScopedConnection )
delete

◆ ScopedConnection() [3/3]

QGCSqlHelper::ScopedConnection::ScopedConnection ( ScopedConnection &&  )
delete

Member Function Documentation

◆ database()

QSqlDatabase QGCSqlHelper::ScopedConnection::database ( ) const

◆ isValid()

bool QGCSqlHelper::ScopedConnection::isValid ( ) const
inline

◆ operator=() [1/2]

ScopedConnection & QGCSqlHelper::ScopedConnection::operator= ( const ScopedConnection )
delete

◆ operator=() [2/2]

ScopedConnection & QGCSqlHelper::ScopedConnection::operator= ( ScopedConnection &&  )
delete

The documentation for this class was generated from the following files: