![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <QtCore/qbytearray.h>#include <QtCore/qdatetime.h>#include <QtCore/qloggingcategory.h>#include <QtCore/qmetatype.h>#include <QtCore/qvariant.h>#include <QtSql/qtsqlglobal.h>#include <QtSql/qsqlerror.h>#include <ibase.h>#include <firebird/Interface.h>#include <cmath>Go to the source code of this file.
Classes | |
| class | FbGuard< T > |
Enumerations | |
| enum class | TxnEnd : quint8 { Commit , Rollback } |
| enum class | TxnWait : quint8 { Wait , NoWait } |
Functions | |
| template<typename T> | |
| static QT_BEGIN_NAMESPACE void | fbRelease (T *h) |
| template<typename T> | |
| static void | fbDispose (T *h) |
| int | fbBaseType (int t) |
| QString | fbErrorString (Firebird::IMaster *master, Firebird::IStatus *status) |
| QSqlError | fbError (Firebird::IMaster *master, Firebird::IStatus *status, QSqlError::ErrorType type) |
| QString | fbErrorLog (const QSqlError &err) |
| void | finishAndClear (Firebird::ThrowStatusWrapper &st, Firebird::ITransaction *&tr, TxnEnd end) |
| Firebird::ITransaction * | startDefaultTransaction (Firebird::IAttachment *att, Firebird::ThrowStatusWrapper &st, TxnWait wait) |
| QMetaType::Type | blrTypeToQt (unsigned char blrType, bool hasScale) |
| void | encodeTextValue (char *data, int fbType, qsizetype length, const QByteArray &bytes) |
| qint64 | pow10i (int n) |
| template<typename T> | |
| static QString | numberToHighPrecision (T val, int scale) |
| template<typename T> | |
| static QVariant | applyScale (T val, int scale, QSql::NumericalPrecisionPolicy policy) |
| QMetaType::Type | fbTypeToQt (int fbType, int scale) |
| QByteArray | numericInputString (const QVariant &val) |
| bool | decimalToScaledInt64 (const QByteArray &decimal, int scale, qint64 *out) |
| QString | int128ToString (Firebird::IUtil *util, Firebird::ThrowStatusWrapper &st, const FB_I128 *value, int scale) |
| template<typename Iface, typename Raw> | |
| static QString | decFloatToString (Iface *iface, Firebird::ThrowStatusWrapper &st, const Raw *value) |
| template<typename Iface, typename Raw> | |
| static void | decFloatFromString (Iface *iface, Firebird::ThrowStatusWrapper &st, const QByteArray &s, Raw *out) |
| ISC_DATE | encodeQDate (Firebird::IUtil *util, const QDate &d) |
| ISC_TIME | encodeQTime (Firebird::IUtil *util, const QTime &t) |
| ISC_TIMESTAMP | encodeQDateTime (Firebird::IUtil *util, const QDateTime &dt) |
| ISC_TIMESTAMP_TZ | encodeQDateTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt) |
| ISC_TIME_TZ | encodeQTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const QDateTime &dt) |
| QDate | decodeFirebirdDate (Firebird::IUtil *util, ISC_DATE date) |
| QTime | decodeFirebirdTime (Firebird::IUtil *util, ISC_TIME time) |
| QDateTime | decodeFirebirdTimestamp (Firebird::IUtil *util, const ISC_TIMESTAMP &ts) |
| QDateTime | decodeFirebirdTimestampTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIMESTAMP_TZ &tstz) |
| QDateTime | decodeFirebirdTimeTz (Firebird::IStatus *iStatus, Firebird::IUtil *util, const ISC_TIME_TZ &ttz) |
| Enumerator | |
|---|---|
| Commit | |
| Rollback | |
Definition at line 124 of file qsql_firebird_helpers_p.h.
| Enumerator | |
|---|---|
| Wait | |
| NoWait | |
Definition at line 130 of file qsql_firebird_helpers_p.h.
|
static |
Definition at line 181 of file qsql_firebird_helpers_p.h.
| QMetaType::Type blrTypeToQt | ( | unsigned char | blrType, |
| bool | hasScale ) |
Definition at line 107 of file qsql_firebird_helpers.cpp.
|
static |
Definition at line 234 of file qsql_firebird_helpers_p.h.
|
static |
IDecFloat16 and IDecFloat34 share identical toString()/fromString() shapes; templated on the interface so one helper serves both DECFLOAT widths.
Definition at line 226 of file qsql_firebird_helpers_p.h.
| bool decimalToScaledInt64 | ( | const QByteArray & | decimal, |
| int | scale, | ||
| qint64 * | out ) |
Convert a plain decimal string (as produced by numericInputString) into the scaled integer Firebird stores for a NUMERIC/DECIMAL column: shift the decimal point by -scale digits (right for the usual negative scale), round half away from zero, and detect qint64 overflow. Works on the digit string, never through double — a double round-trip silently drops digits above 2^53 and an out-of-range double-to-integer cast is undefined behaviour. The read path (applyScale) avoids double for the same reason. Exponent notation is rejected, matching IInt128::fromString on the INT128 path.
Definition at line 218 of file qsql_firebird_helpers.cpp.
| QDate decodeFirebirdDate | ( | Firebird::IUtil * | util, |
| ISC_DATE | date ) |
| QTime decodeFirebirdTime | ( | Firebird::IUtil * | util, |
| ISC_TIME | time ) |
| QDateTime decodeFirebirdTimestamp | ( | Firebird::IUtil * | util, |
| const ISC_TIMESTAMP & | ts ) |
| QDateTime decodeFirebirdTimestampTz | ( | Firebird::IStatus * | iStatus, |
| Firebird::IUtil * | util, | ||
| const ISC_TIMESTAMP_TZ & | tstz ) |
| QDateTime decodeFirebirdTimeTz | ( | Firebird::IStatus * | iStatus, |
| Firebird::IUtil * | util, | ||
| const ISC_TIME_TZ & | ttz ) |
| ISC_DATE encodeQDate | ( | Firebird::IUtil * | util, |
| const QDate & | d ) |
| ISC_TIMESTAMP encodeQDateTime | ( | Firebird::IUtil * | util, |
| const QDateTime & | dt ) |
| ISC_TIMESTAMP_TZ encodeQDateTimeTz | ( | Firebird::IStatus * | iStatus, |
| Firebird::IUtil * | util, | ||
| const QDateTime & | dt ) |
| ISC_TIME encodeQTime | ( | Firebird::IUtil * | util, |
| const QTime & | t ) |
| ISC_TIME_TZ encodeQTimeTz | ( | Firebird::IStatus * | iStatus, |
| Firebird::IUtil * | util, | ||
| const QDateTime & | dt ) |
| void encodeTextValue | ( | char * | data, |
| int | fbType, | ||
| qsizetype | length, | ||
| const QByteArray & | bytes ) |
Encode a UTF-8 string into a CHAR/VARCHAR message slot: VARYING gets a 2-byte length prefix, TEXT is space-padded; data beyond the declared length is truncated. Shared by fillInputBuffer and lookupArrayDesc's bind loop so the Firebird text wire format lives in one place.
Definition at line 473 of file qsql_firebird_helpers.cpp.
|
inline |
Definition at line 112 of file qsql_firebird_helpers_p.h.
Referenced by QFirebirdResult::data(), QFirebirdResultPrivate::encodeScaledNumeric(), fbTypeToQt(), and QFirebirdResultPrivate::fillInputBuffer().
|
static |
Definition at line 55 of file qsql_firebird_helpers_p.h.
| QSqlError fbError | ( | Firebird::IMaster * | master, |
| Firebird::IStatus * | status, | ||
| QSqlError::ErrorType | type ) |
Definition at line 53 of file qsql_firebird_helpers.cpp.
| QString fbErrorString | ( | Firebird::IMaster * | master, |
| Firebird::IStatus * | status ) |
|
static |
RAII guard for Firebird OO-API handles
The Firebird OO API splits cleanup across two families: reference-counted interfaces freed with release() (IStatement, IResultSet, IBlob, …) and IDisposable ones freed with dispose() (IXpbBuilder, IBatchCompletionState). FbGuard centralises the "free on every error path" bookkeeping so it is not repeated at every call site.
FbGuard owns one handle and frees it on scope exit with the action supplied at construction, unless it has been dismissed. closeWith() performs the type-specific graceful shutdown (IResultSet::close, IStatement::free, ITransaction::commit, …) which itself consumes the interface reference on success — so on success the guard is dismissed (no extra free), and only on a failed close does the destructor release the handle. This mirrors exactly the "close on the happy path, release on the error path" idiom used throughout.
Definition at line 54 of file qsql_firebird_helpers_p.h.
| QMetaType::Type fbTypeToQt | ( | int | fbType, |
| int | scale ) |
Definition at line 150 of file qsql_firebird_helpers.cpp.
References fbBaseType().
Commit (or roll back) a transaction whose handle must not outlive a failure: on a throw the interface is released and the member cleared before the rethrow, on success commit/rollback already released it, so the member is cleared too. Taking the handle by reference makes "released implies cleared" structural — every finish site shares this discipline instead of repeating it. (The bare-COMMIT path in exec() intentionally does NOT use this: a failed user COMMIT keeps the still-valid handle so it can be retried.)
Definition at line 74 of file qsql_firebird_helpers.cpp.
References Commit.
| QString int128ToString | ( | Firebird::IUtil * | util, |
| Firebird::ThrowStatusWrapper & | st, | ||
| const FB_I128 * | value, | ||
| int | scale ) |
-— INT128 / DECFLOAT string conversion helpers -—
Firebird's IInt128/IDecFloat interfaces convert to and from a canonical decimal string via a fixed-size caller buffer. These wrappers own the buffer (64 chars is ample for INT128's 39 digits and DECFLOAT's 34) so the value conversions read as one line at each call site.
|
static |
Format a scaled integer as a high-precision decimal string. e.g. val=12345, scale=-2 → "123.45"; val=12, scale=2 → "1200"
Definition at line 157 of file qsql_firebird_helpers_p.h.
| QByteArray numericInputString | ( | const QVariant & | val | ) |
Canonical decimal string for binding a value to an INT128/DECFLOAT parameter via Firebird's fromString(). Integer and string variants are already plain C-locale decimals; floating-point variants are reformatted only when QVariant::toByteArray() yields exponential notation (e.g. a large double), which IInt128::fromString does not accept.
Definition at line 191 of file qsql_firebird_helpers.cpp.
| qint64 pow10i | ( | int | n | ) |
10^n as a 64-bit integer (n >= 0). Firebird numeric scale magnitudes are small (NUMERIC/DECIMAL precision <= 38, INT64 <= 18), so this never overflows for the integer-backed types it is used with.
Definition at line 142 of file qsql_firebird_helpers.cpp.
| Firebird::ITransaction * startDefaultTransaction | ( | Firebird::IAttachment * | att, |
| Firebird::ThrowStatusWrapper & | st, | ||
| TxnWait | wait ) |