5#ifndef QSQL_FIREBIRD_HELPERS_P_H
6#define QSQL_FIREBIRD_HELPERS_P_H
19#include <QtCore/qbytearray.h>
20#include <QtCore/qdatetime.h>
21#include <QtCore/qloggingcategory.h>
22#include <QtCore/qmetatype.h>
23#include <QtCore/qvariant.h>
24#include <QtSql/qtsqlglobal.h>
25#include <QtSql/qsqlerror.h>
28#include <QtSql/private/qsqlnumeric_p.h>
31#include <firebird/Interface.h>
35Q_DECLARE_LOGGING_CATEGORY(lcFirebird)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
55template <
typename T>
static void fbRelease(T *h) { h->release(); }
56template <
typename T>
static void fbDispose(T *h) { h->dispose(); }
64
65
66
68 ~
FbGuard() {
if (m_handle) m_free(m_handle); }
70
71
72
76 T *
get()
const {
return m_handle; }
78 explicit operator bool()
const {
return m_handle !=
nullptr; }
81 T *
take() { T *h = m_handle; m_handle =
nullptr;
return h; }
85
86
87
88
89
90 template <
typename CloseFn>
91 void closeWith(CloseFn closeFn,
bool rethrow =
true)
119 QSqlError::ErrorType type);
137 Firebird::ITransaction *&tr,
TxnEnd end);
139 Firebird::ThrowStatusWrapper &st,
146void encodeTextValue(
char *data,
int fbType, qsizetype length,
const QByteArray &bytes);
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
176 Firebird::IMaster *master, Firebird::IStatus *status,
179 Firebird::IMaster *master, Firebird::IStatus *status,
180 QString *overflowText =
nullptr);
183
184
185
186
187template <
typename Iface,
typename Raw>
191 iface->toString(&st, value,
sizeof(buf), buf);
192 return QString::fromLatin1(buf);
195template <
typename Iface,
typename Raw>
197 const QByteArray &s, Raw *out)
199 iface->fromString(&st, s.constData(), out);
208 const QDateTime &dt);
210 const QDateTime &dt);
215 const ISC_TIMESTAMP_TZ &tstz);
217 const ISC_TIME_TZ &ttz);
FbGuard(const FbGuard &)=delete
void closeWith(CloseFn closeFn, bool rethrow=true)
FbGuard & operator=(const FbGuard &)=delete
void setError(const QString &msg, QSqlError::ErrorType type, const QString &code={})
QHash< QString, QFirebirdEventSubscription * > eventSubscriptions
Firebird::ITransaction * iTrans
Firebird::IAttachment * iAtt
Firebird::IStatus * iStatus
QList< QFirebirdResultPrivate * > activeResults
bool finishTransaction(TxnEnd end)
bool cacheScrollableResults
void setFbError(const QString &context, QSqlError::ErrorType type=QSqlError::UnknownError)
bool commitTransaction() override
This function is called to commit a transaction.
QSqlResult * createResult() const override
Creates an empty SQL result on the database.
bool cancelQuery() override
bool hasFeature(DriverFeature feature) const override
Returns true if the driver supports feature feature; otherwise returns false.
QString escapeIdentifier(const QString &identifier, IdentifierType type) const override
Returns the identifier escaped according to the database rules.
QSqlRecord record(const QString &tableName) const override
Returns a QSqlRecord populated with the names of the fields in table tableName.
QFirebirdDriver(QObject *parent=nullptr)
bool rollbackTransaction() override
This function is called to rollback a transaction.
QSqlIndex primaryIndex(const QString &tableName) const override
Returns the primary index for table tableName.
int maximumIdentifierLength(IdentifierType type) const override
QVariant handle() const override
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
bool open(const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts) override
Derived classes must reimplement this pure virtual function to open a database connection on database...
QStringList subscribedToNotifications() const override
Returns a list of the names of the event notifications that are currently subscribed to.
bool unsubscribeFromNotification(const QString &name) override
This function is called to unsubscribe from event notifications from the database.
QString formatValue(const QSqlField &field, bool trimStrings) const override
Returns a string representation of the field value for the database.
bool beginTransaction() override
This function is called to begin a transaction.
bool subscribeToNotification(const QString &name) override
This function is called to subscribe to event notifications from the database.
~QFirebirdDriver() override
void close() override
Derived classes must reimplement this pure virtual function in order to close the database connection...
void eventCallbackFunction(unsigned length, const unsigned char *data) override
std::atomic< int > counter
QFirebirdEventSubscription(QFirebirdDriver *drv, IAttachment *att, const QString &eventName)
QFirebirdResult(const QFirebirdDriver *driver)
Combined button and popup list for selecting options.
QDateTime decodeFirebirdTimestamp(Firebird::IUtil *util, const ISC_TIMESTAMP &ts)
bool encodeInt128Slot(const QVariant &val, int scale, char *slot, Firebird::IMaster *master, Firebird::IStatus *status, QString &errorText)
QString fbErrorLog(const QSqlError &err)
static void decFloatFromString(Iface *iface, Firebird::ThrowStatusWrapper &st, const QByteArray &s, Raw *out)
Firebird::ITransaction * startDefaultTransaction(Firebird::IAttachment *att, Firebird::ThrowStatusWrapper &st, TxnWait wait)
QString fbErrorString(Firebird::IMaster *master, Firebird::IStatus *status)
ISC_TIMESTAMP encodeQDateTime(Firebird::IUtil *util, const QDateTime &dt)
ISC_TIME encodeQTime(Firebird::IUtil *util, const QTime &t)
static void fbDispose(T *h)
QDate decodeFirebirdDate(Firebird::IUtil *util, ISC_DATE date)
QDateTime decodeFirebirdTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIME_TZ &ttz)
void encodeTextValue(char *data, int fbType, qsizetype length, const QByteArray &bytes)
void finishAndClear(Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd end)
QDateTime decodeFirebirdTimestampTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIMESTAMP_TZ &tstz)
QMetaType::Type blrTypeToQt(unsigned char blrType, bool hasScale)
QTime decodeFirebirdTime(Firebird::IUtil *util, ISC_TIME time)
ISC_TIMESTAMP_TZ encodeQDateTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
static QString decFloatToString(Iface *iface, Firebird::ThrowStatusWrapper &st, const Raw *value)
ISC_TIME_TZ encodeQTimeTz(Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt)
QSqlError fbError(Firebird::IMaster *master, Firebird::IStatus *status, QSqlError::ErrorType type)
ISC_DATE encodeQDate(Firebird::IUtil *util, const QDate &d)
QMetaType::Type fbTypeToQt(int fbType, int scale)
QVariant decodeInt128Slot(const char *slot, int scale, QSql::NumericalPrecisionPolicy policy, Firebird::IMaster *master, Firebird::IStatus *status, QString *overflowText=nullptr)