spatialite_database_unique_ptr class

Unique pointer for spatialite databases, which automatically closes the database when the pointer goes out of scope or is reset.

Contents

Public functions

auto errorMessage() const -> QString
Returns the most recent error message encountered by the database.
auto open(const QString& path) -> int
Opens the database at the specified file path.
auto open_v2(const QString& path, int flags, const char* zVfs) -> int
Opens the database at the specified file path.
auto prepare(const QString& sql, int& resultCode) -> sqlite3_statement_unique_ptr
Prepares a sql statement, returning the result.
void reset()
Will close the connection and set the internal pointer to nullptr.
void reset(sqlite3* handle) deleted
It is not allowed to set an arbitrary sqlite3 handle on this object.

Function documentation

int spatialite_database_unique_ptr::open(const QString& path)

Opens the database at the specified file path.

Returns the sqlite error code, or SQLITE_OK if open was successful.

int spatialite_database_unique_ptr::open_v2(const QString& path, int flags, const char* zVfs)

Opens the database at the specified file path.

Returns the sqlite error code, or SQLITE_OK if open was successful.

sqlite3_statement_unique_ptr spatialite_database_unique_ptr::prepare(const QString& sql, int& resultCode)

Prepares a sql statement, returning the result.

The resultCode argument will be filled with the sqlite3 result code.

void spatialite_database_unique_ptr::reset(sqlite3* handle) deleted

It is not allowed to set an arbitrary sqlite3 handle on this object.

A dedicated spatialite context (connection) is created when calling open or open_v2. This context needs to be kept together with the handle, hence it is not allowed to reset to a handle with missing context.