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
ScopedConnection & operator= (const ScopedConnection &)=delete
 ScopedConnection (ScopedConnection &&)=delete
ScopedConnection & operator= (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().

Referenced by operator=(), operator=(), ScopedConnection(), and ScopedConnection().

◆ ~ScopedConnection()

QGCSqlHelper::ScopedConnection::~ScopedConnection ( )

Definition at line 80 of file QGCSqlHelper.cc.

◆ ScopedConnection() [2/3]

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

References ScopedConnection().

◆ ScopedConnection() [3/3]

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

References ScopedConnection().

Member Function Documentation

◆ database()

QSqlDatabase QGCSqlHelper::ScopedConnection::database ( ) const
nodiscard

◆ isValid()

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

◆ operator=() [1/2]

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

References ScopedConnection().

◆ operator=() [2/2]

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

References ScopedConnection().


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