blob: 055be3372cb6aba63634e533c7b3613b501581a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef OWNSQL_H
#define OWNSQL_H
#include <sqlite3.h>
#include <QObject>
#include <QVariant>
#include "owncloudlib.h"
namespace Mirall {
class OWNCLOUDSYNC_EXPORT SqlDatabase
{
Q_DISABLE_COPY(SqlDatabase)
public:
explicit SqlDatabase();
bool isOpen();
bool open( const QString& filename );
bool transaction();
bool commit();
void close();
QString error() const;
sqlite3* sqliteDb();
private:
sqlite3 *_db;
QString _error; // last error string
int _errId;
};
class OWNCLOUDSYNC_EXPORT SqlQuery
{
Q_DISABLE_COPY(SqlQuery)
public:
explicit SqlQuery();
explicit SqlQuery(SqlDatabase& db);
explicit SqlQuery(const QString& sql, SqlDatabase& db);
~SqlQuery();
QString error() const;
QString stringValue(int index);
int intValue(int index);
quint64 int64Value(int index);
QByteArray baValue(int index);
bool isSelect();
bool isPragma();
bool exec();
int prepare( const QString& sql );
bool next();
void bindValue(int pos, const QVariant& value);
QString lastQuery() const;
int numRowsAffected();
void reset();
void finish();
private:
sqlite3 *_db;
sqlite3_stmt *_stmt;
QString _error;
int _errId;
QString _sql;
};
} // namespace Mirall
#endif // OWNSQL_H
|