Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:18

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QSQLDRIVER_H
0005 #define QSQLDRIVER_H
0006 
0007 #include <QtSql/qtsqlglobal.h>
0008 #include <QtCore/qobject.h>
0009 #include <QtCore/qstring.h>
0010 #include <QtCore/qstringlist.h>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 
0015 class QSqlDatabase;
0016 class QSqlDriverPrivate;
0017 class QSqlError;
0018 class QSqlField;
0019 class QSqlIndex;
0020 class QSqlRecord;
0021 class QSqlResult;
0022 class QVariant;
0023 
0024 class Q_SQL_EXPORT QSqlDriver : public QObject
0025 {
0026     friend class QSqlDatabase;
0027     friend class QSqlResultPrivate;
0028     Q_OBJECT
0029     Q_DECLARE_PRIVATE(QSqlDriver)
0030 
0031 public:
0032     enum DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries,
0033                          NamedPlaceholders, PositionalPlaceholders, LastInsertId,
0034                          BatchOperations, SimpleLocking, LowPrecisionNumbers,
0035                          EventNotifications, FinishQuery, MultipleResultSets, CancelQuery };
0036 
0037     enum StatementType { WhereStatement, SelectStatement, UpdateStatement,
0038                          InsertStatement, DeleteStatement };
0039 
0040     enum IdentifierType { FieldName, TableName };
0041 
0042     enum NotificationSource { UnknownSource, SelfSource, OtherSource };
0043 
0044     enum DbmsType {
0045         UnknownDbms,
0046         MSSqlServer,
0047         MySqlServer,
0048         PostgreSQL,
0049         Oracle,
0050         Sybase,
0051         SQLite,
0052         Interbase,
0053         DB2,
0054         MimerSQL,
0055     };
0056 
0057     explicit QSqlDriver(QObject *parent = nullptr);
0058     ~QSqlDriver();
0059     virtual bool isOpen() const;
0060     bool isOpenError() const;
0061 
0062     virtual bool beginTransaction();
0063     virtual bool commitTransaction();
0064     virtual bool rollbackTransaction();
0065     virtual QStringList tables(QSql::TableType tableType) const;
0066     virtual QSqlIndex primaryIndex(const QString &tableName) const;
0067     virtual QSqlRecord record(const QString &tableName) const;
0068     virtual QString formatValue(const QSqlField &field, bool trimStrings = false) const;
0069 
0070     virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
0071     virtual QString sqlStatement(StatementType type, const QString &tableName,
0072                                  const QSqlRecord &rec, bool preparedStatement) const;
0073 
0074     QSqlError lastError() const;
0075 
0076     virtual QVariant handle() const;
0077     virtual bool hasFeature(DriverFeature f) const = 0;
0078     virtual void close() = 0;
0079     virtual QSqlResult *createResult() const = 0;
0080 
0081     virtual bool open(const QString &db,
0082                       const QString &user = QString(),
0083                       const QString &password = QString(),
0084                       const QString &host = QString(),
0085                       int port = -1,
0086                       const QString &connOpts = QString()) = 0;
0087     virtual bool subscribeToNotification(const QString &name);
0088     virtual bool unsubscribeFromNotification(const QString &name);
0089     virtual QStringList subscribedToNotifications() const;
0090 
0091     virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const;
0092     virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const;
0093 
0094     void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
0095     QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
0096 
0097     DbmsType dbmsType() const;
0098     virtual int maximumIdentifierLength(IdentifierType type) const;
0099 public Q_SLOTS:
0100     virtual bool cancelQuery();
0101 
0102 Q_SIGNALS:
0103     void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);
0104 
0105 protected:
0106     QSqlDriver(QSqlDriverPrivate &dd, QObject *parent = nullptr);
0107     virtual void setOpen(bool o);
0108     virtual void setOpenError(bool e);
0109     virtual void setLastError(const QSqlError& e);
0110 
0111 
0112 private:
0113     Q_DISABLE_COPY(QSqlDriver)
0114 };
0115 
0116 QT_END_NAMESPACE
0117 
0118 #endif // QSQLDRIVER_H