Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSqlQueryLoader.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KISSQLQUERYLOADER_H
7#define KISSQLQUERYLOADER_H
8
9#include <kritaresources_export.h>
10
11#include <exception>
12#include <QSqlQuery>
13#include <QSqlError>
14#include <QStringList>
15#include <QFileDevice>
16
105class KRITARESOURCES_EXPORT KisSqlQueryLoader
106{
107public:
109 static constexpr single_statement_mode_t single_statement_mode{};
110
111 struct FileException : std::exception
112 {
113 FileException(QString _message,
114 QString _filePath,
115 QString _fileErrorString)
116 : message(_message)
117 , filePath(_filePath)
118 , fileErrorString(_fileErrorString)
119 {}
120
121 QString message;
122 QString filePath;
124 };
125
126 struct SQLException : std::exception
127 {
128 SQLException(QString _message,
129 QString _filePath,
130 int _statementIndex,
131 QSqlError _sqlError)
132 : message(_message)
133 , filePath(_filePath)
134 , statementIndex(_statementIndex)
135 , sqlError(_sqlError)
136 {}
137
138 QString message;
139 QString filePath;
140 int statementIndex {0};
141 QSqlError sqlError;
142 };
143
144public:
154 KisSqlQueryLoader(const QString &fileName);
155
161 KisSqlQueryLoader(const QString &fileName, single_statement_mode_t);
162
172 KisSqlQueryLoader(const QString &scriptName, const QString &script);
173
183 KisSqlQueryLoader(const QString &scriptName, const QString &script, single_statement_mode_t);
184
186
187 QSqlQuery& query();
188
195 void exec();
196
197private:
198 void init(const QString &fileName, QString entireScript, bool singleStatementMode);
199
200private:
201 QSqlQuery m_query;
203 bool m_singleStatementMode {false};
204 QString m_fileName;
205};
206
207#endif /* KISSQLQUERYLOADER_H */
FileException(QString _message, QString _filePath, QString _fileErrorString)
SQLException(QString _message, QString _filePath, int _statementIndex, QSqlError _sqlError)