File indexing completed on 2026-07-13 08:30:30
0001
0002
0003
0004
0005 #ifndef QSQLERROR_H
0006 #define QSQLERROR_H
0007
0008 #include <QtSql/qtsqlglobal.h>
0009 #include <QtCore/qshareddata.h>
0010 #include <QtCore/qstring.h>
0011
0012 QT_BEGIN_NAMESPACE
0013
0014 class QSqlErrorPrivate;
0015 QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlErrorPrivate, Q_SQL_EXPORT)
0016
0017 class Q_SQL_EXPORT QSqlError
0018 {
0019 public:
0020 enum ErrorType {
0021 NoError,
0022 ConnectionError,
0023 StatementError,
0024 TransactionError,
0025 UnknownError
0026 };
0027 QSqlError(const QString &driverText = QString(),
0028 const QString &databaseText = QString(),
0029 ErrorType type = NoError,
0030 const QString &nativeErrorCode = QString());
0031 QSqlError(const QSqlError &other);
0032 QSqlError(QSqlError &&other) noexcept = default;
0033 QSqlError& operator=(const QSqlError &other);
0034 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSqlError)
0035 ~QSqlError();
0036
0037 bool operator==(const QSqlError &other) const;
0038 bool operator!=(const QSqlError &other) const;
0039
0040 void swap(QSqlError &other) noexcept { d.swap(other.d); }
0041
0042 QString driverText() const;
0043 QString databaseText() const;
0044 ErrorType type() const;
0045 QString nativeErrorCode() const;
0046 QString text() const;
0047 bool isValid() const;
0048
0049 private:
0050 QExplicitlySharedDataPointer<QSqlErrorPrivate> d;
0051 };
0052
0053 Q_DECLARE_SHARED(QSqlError)
0054
0055 #ifndef QT_NO_DEBUG_STREAM
0056 Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlError &);
0057 #endif
0058
0059 QT_END_NAMESPACE
0060
0061 #endif