aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/db/sqlerrorresults.h
blob: f837245ace37f1ec929c04203f0fa69586a908e5 (plain) (blame)
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
#ifndef SQLERRORRESULTS_H
#define SQLERRORRESULTS_H

#include "sqlquery.h"
#include <QStringList>

/**
 * @brief SqlResults implementation for returning errors.
 *
 * It's very simple implementation of SqlResults, which has hardcoded number of columns and rows (0).
 * It has single constructor which accepts error code and error message, which are later
 * returned from getErrorCode() and getErrorText().
 */
class SqlErrorResults : public SqlQuery
{
    public:
        /**
         * @brief Creates error results with given code and message.
         * @param code Error code.
         * @param text Error message.
         */
        SqlErrorResults(int code, const QString &text);

        QString getErrorText();
        int getErrorCode();
        QStringList getColumnNames();
        int columnCount();
        qint64 rowsAffected();

    protected:
        SqlResultsRowPtr nextInternal();
        bool hasNextInternal();
        bool execInternal(const QList<QVariant>& args);
        bool execInternal(const QHash<QString, QVariant>& args);

    private:
        /**
         * @brief Error message passed in constructor.
         */
        QString errText;

        /**
         * @brief errCode Error code passed in constructor.
         */
        int errCode;
};

#endif // SQLERRORRESULTS_H