Herunterladen als
root/src/queryinterpreter.h @ 827458ed
38838b5b | Christian Ehringfeld | /*
|
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|||
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
2ee5022f | Christian Ehringfeld | #ifndef QUERYINTERPRETER_H
|
|
#define QUERYINTERPRETER_H
|
|||
#include <QSqlQuery>
|
|||
#include <QSharedPointer>
|
|||
3160499c | Christian Ehringfeld | #include <QRegularExpressionMatchIterator>
|
|
2ee5022f | Christian Ehringfeld | namespace CuteEntityManager {
|
|
class Query;
|
|||
3160499c | Christian Ehringfeld | class Join;
|
|
class OrderBy;
|
|||
class Expression;
|
|||
dbd41a3a | Christian Ehringfeld | class AttributeResolver;
|
|
2ee5022f | Christian Ehringfeld | class QueryInterpreter {
|
|
public:
|
|||
5ca225ed | Christian Ehringfeld | explicit QueryInterpreter(QSharedPointer<AttributeResolver> ar);
|
|
8fea42af | Christian Ehringfeld | QSqlQuery build(Query &q, const QMetaObject *obj = nullptr);
|
|
3160499c | Christian Ehringfeld | ||
protected:
|
|||
1b167b6c | Christian Ehringfeld | QString buildSelect(Query &q, const QList<Expression> &columns,
|
|
506067a2 | Christian Ehringfeld | const bool &distinct = false,
|
|
3160499c | Christian Ehringfeld | const QString &selectOption = "") const;
|
|
QString buildFrom(const QStringList &from) const;
|
|||
QString buildJoin(const QList<Join> &joins) const;
|
|||
e3fc2748 | Christian Ehringfeld | QString buildSQLJoin(const QString &table1, const QString &col1, const QString &table2, const QString &col2) const;
|
|
1b167b6c | Christian Ehringfeld | QString buildWhere(Query &q, const QList<Expression> &conditions) const;
|
|
3160499c | Christian Ehringfeld | QString buildGroupBy(const QStringList &groupBy) const;
|
|
1b167b6c | Christian Ehringfeld | QString buildHaving(Query &q, const QList<Expression> &conditions) const;
|
|
3160499c | Christian Ehringfeld | QString buildOrderByAndLimit(QString sql, const QList<OrderBy> &orderBy,
|
|
const quint64 &limit, const quint64 &offset) const;
|
|||
QString buildOrderBy(const QList<OrderBy> &columns) const;
|
|||
1b167b6c | Christian Ehringfeld | QString buildCondition(Query &q, const QList<Expression> &conditions) const;
|
|
fd67a7a7 | Christian Ehringfeld | void convertParams(Query &q, const QHash<QString, QVariant> ¶ms, QString &condition) const;
|
|
8fea42af | Christian Ehringfeld | QVariant convertParamValue(const QVariant val) const;
|
|
void resolveRelations(Query &q, const QMetaObject *obj);
|
|||
3b82c8c0 | Christian Ehringfeld | QString generateParam(Query &q) const;
|
|
3160499c | Christian Ehringfeld | ||
2ee5022f | Christian Ehringfeld | private:
|
|
dbd41a3a | Christian Ehringfeld | QSharedPointer<AttributeResolver> ar;
|
|
3160499c | Christian Ehringfeld | ||
2ee5022f | Christian Ehringfeld | };
|
|
3160499c | Christian Ehringfeld | ||
2ee5022f | Christian Ehringfeld | }
|
|
#endif // QUERYINTERPRETER_H
|