| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSQLERROR_H |
| 5 | #define QSQLERROR_H |
| 6 | |
| 7 | #include <QtSql/qtsqlglobal.h> |
| 8 | #include <QtCore/qshareddata.h> |
| 9 | #include <QtCore/qstring.h> |
| 10 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | class QSqlErrorPrivate; |
| 14 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlErrorPrivate, Q_SQL_EXPORT) |
| 15 | |
| 16 | class Q_SQL_EXPORT QSqlError |
| 17 | { |
| 18 | public: |
| 19 | enum ErrorType { |
| 20 | NoError, |
| 21 | ConnectionError, |
| 22 | StatementError, |
| 23 | TransactionError, |
| 24 | UnknownError |
| 25 | }; |
| 26 | QSqlError(const QString &driverText = QString(), |
| 27 | const QString &databaseText = QString(), |
| 28 | ErrorType type = NoError, |
| 29 | const QString &errorCode = QString()); |
| 30 | QSqlError(const QSqlError &other); |
| 31 | QSqlError(QSqlError &&other) noexcept = default; |
| 32 | QSqlError& operator=(const QSqlError &other); |
| 33 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSqlError) |
| 34 | ~QSqlError(); |
| 35 | |
| 36 | bool operator==(const QSqlError &other) const; |
| 37 | bool operator!=(const QSqlError &other) const; |
| 38 | |
| 39 | void swap(QSqlError &other) noexcept { d.swap(other&: other.d); } |
| 40 | |
| 41 | QString driverText() const; |
| 42 | QString databaseText() const; |
| 43 | ErrorType type() const; |
| 44 | QString nativeErrorCode() const; |
| 45 | QString text() const; |
| 46 | bool isValid() const; |
| 47 | |
| 48 | private: |
| 49 | QExplicitlySharedDataPointer<QSqlErrorPrivate> d; |
| 50 | }; |
| 51 | |
| 52 | Q_DECLARE_SHARED(QSqlError) |
| 53 | |
| 54 | #ifndef QT_NO_DEBUG_STREAM |
| 55 | Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlError &); |
| 56 | #endif |
| 57 | |
| 58 | QT_END_NAMESPACE |
| 59 | |
| 60 | #endif // QSQLERROR_H |
| 61 |
