Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Z/src/ngldb/nsqlquery.h
T
berrux-dev 156c2dfcdc Restore legacy @RDE_HEADER@ comment blocks stripped by the Qt6 migration
The migration pipeline dropped the leading @RDE_HEADER@ comment blocks
from 243 target source files (and 2 cmake macros). Restore them
byte-for-byte from the legacy Qt5 tree
(qt5-before/qt5-legatus-legacy): the exact legacy header is re-inserted
at the top of each file (block-comment, '#'-style, line-comment '//'
styles, BOM and surrounding blank lines included). File bodies are
untouched.

Scope: all in-scope target code, unit-test directories excluded.
190 files already kept their legacy header through the migration and
were left as-is; legacy files without an RDE header were not given
one. Special cases: 3 headers sitting after a '#pragma once' line,
1 BOM-prefixed file, 4 '//'-style TetraIF headers. *.grantlee template
files were not in scope and remain untouched.

Verified: every restored file is byte-exact (legacy preamble + original
body) and the ctest baseline is unchanged (20/23 passed, 3 Not Run as
before).
2026-11-15 23:22:04 +01:00

228 lines
3.0 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Wrapper around QSqlQuery with enhanced logging functionality
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QtSql/QSqlQuery>
#include "ngldb_export.h"
#include "dbcommon.h"
namespace NGL
{
class INGLLogger;
}
class QDateTime;
class QJsonValue;
class NGLDB_EXPORT NSqlQuery final : public QSqlQuery
{
public:
explicit NSqlQuery(const QSqlDatabase &db);
explicit NSqlQuery(const QSqlDatabase &db, NGL::INGLLogger &logger);
explicit NSqlQuery(const QString &query, const QSqlDatabase &db);
explicit NSqlQuery(const QString &query, const QSqlDatabase &db, NGL::INGLLogger &logger);
NSqlQuery(const NSqlQuery &other) = default;
~NSqlQuery() = default;
void addBindValue(const QVariant &val, QSql::ParamType paramType = QSql::In);
int at() const;
void bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType paramType = QSql::In);
void bindValue(int pos, const QVariant &val, QSql::ParamType paramType = QSql::In);
QVariant boundValue(const QString &placeholder) const;
QVariant boundValue(int pos) const;
QMap<QString, QVariant> boundValues() const;
void clear();
const QSqlDriver *driver() const;
bool exec(const QString &query, bool bEmitMessageOnError = true);
bool exec(bool bEmitMessageOnError = true);
bool execAndFetch();
bool execAndFetch(const QString &query);
bool execBatch(BatchExecutionMode mode = ValuesAsRows);
QString executedQuery() const;
void finish();
bool first();
bool isActive() const;
bool isForwardOnly() const;
bool isNull(int field) const;
bool isSelect() const;
bool isValid() const;
bool last();
QSqlError lastError() const;
QString sqlstate();
QVariant lastInsertId();
QString lastQuery() const;
bool next();
bool nextResult();
int numRowsAffected() const;
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
bool prepare(const QString &query);
bool previous();
QSqlRecord record() const;
const QSqlResult *result() const;
bool seek(int index, bool relative = false);
void setForwardOnly(bool forward);
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
int size() const;
QVariant value(int index) const;
NSqlQuery &operator= (const NSqlQuery &other);
bool export2CSV(const QString &filename);
static QVariant qDateTimeToQVariant(const QDateTime &dt);
static QDateTime qVariantToQDateTime(const QVariant &var);
static QString qVariantToJsonString(const QVariant &value);
static QString jsonValueToJsonString(const QJsonValue &value);
static inline QString fixupEmptyJsonString(const QString &str) { return str.isEmpty() ? QLatin1String("{}") : str; }
QString getLastSqlError();
private:
void printLastSqlError();
QSqlDatabase m_db;
NGL::INGLLogger &mLogger;
};