QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsspatialiteutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsspatialiteutils.h
3 -------------------
4 begin : Nov, 2017
5 copyright : (C) 2017 by Matthias Kuhn
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSPATIALITEUTILS_H
19#define QGSSPATIALITEUTILS_H
20
21#define SIP_NO_FILE
22
23#include <functional>
24
25#include "qgis_core.h"
26#include "qgssqliteutils.h"
27
34struct CORE_EXPORT QgsSpatialiteCloser
35{
36
40 void operator()( sqlite3 *database );
41
45 void *mSpatialiteContext = nullptr;
46};
47
55class CORE_EXPORT spatialite_database_unique_ptr : public std::unique_ptr< sqlite3, QgsSpatialiteCloser>
56{
57 public:
58
64 int open( const QString &path );
65
69 void reset();
70
78 void reset( sqlite3 *handle ) = delete;
79
85 int open_v2( const QString &path, int flags, const char *zVfs );
86
90 QString errorMessage() const;
91
96 sqlite3_statement_unique_ptr prepare( const QString &sql, int &resultCode );
97};
98
99#endif // QGSSPATIALITEUTILS_H
Unique pointer for spatialite databases, which automatically closes the database when the pointer goe...
void reset(sqlite3 *handle)=delete
It is not allowed to set an arbitrary sqlite3 handle on this object.
int open(const QString &path)
Opens the database at the specified file path.
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode)
Prepares a sql statement, returning the result.
int open_v2(const QString &path, int flags, const char *zVfs)
Opens the database at the specified file path.
QString errorMessage() const
Returns the most recent error message encountered by the database.
void reset()
Will close the connection and set the internal pointer to nullptr.
Unique pointer for sqlite3 prepared statements, which automatically finalizes the statement when the ...
struct sqlite3 sqlite3
Closes a spatialite database.
void operator()(sqlite3 *database)
Closes an spatialite database.
void * mSpatialiteContext
Keep track of the spatialite context.