Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (3,58 KB) Statistiken
| Zweig: | Revision:
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/>.
*/
5d93390e Christian Ehringfeld
#ifndef QUERY_H
#define QUERY_H
#include <QString>
#include <QHash>
#include <QVariant>
#include <QLinkedList>
#include "join.h"
3160499c Christian Ehringfeld
#include "expression.h"
5d93390e Christian Ehringfeld
namespace CuteEntityManager {
2ee5022f Christian Ehringfeld
class Condition;
3160499c Christian Ehringfeld
class OrderBy;
enum class Direction;
2ee5022f Christian Ehringfeld
class Query {
public:
5d93390e Christian Ehringfeld
Query();
82442988 Christian Ehringfeld
~Query();
9e44a59b Christian Ehringfeld
Query(QStringList from, QList<Expression> where = QList<Expression>(),
506067a2 Christian Ehringfeld
QList<Join> joins = QList<Join>(),
QHash<QString, QVariant> params = QHash<QString, QVariant>(), quint64 limit = 0,
quint64 offset = 0,
QList<Expression> select = QList<Expression>(),
QStringList groupBy = QStringList(), bool distinct = false,
QList<Expression> having = QList<Expression>());
5d93390e Christian Ehringfeld
QString getSelectOption() const;
void setSelectOption(const QString &value);

bool getDistinct() const;
void setDistinct(bool value);

82442988 Christian Ehringfeld
void appendFrom(const QString &value);
5d93390e Christian Ehringfeld
QStringList getFrom() const;
void setFrom(const QStringList &value);

82442988 Christian Ehringfeld
void appendJoin(const Join &value);
c9f21778 Christian Ehringfeld
void appendJoins(const QList<Join> &value);
5d93390e Christian Ehringfeld
QList<Join> getJoins() const;
void setJoins(const QList<Join> &value);

void appendParam(const QString &column, QVariant value);
506067a2 Christian Ehringfeld
void appendParams(const QHash<QString, QVariant> &params);
5d93390e Christian Ehringfeld
QHash<QString, QVariant> getParams() const;
void setParams(const QHash<QString, QVariant> &value);

506067a2 Christian Ehringfeld
quint64 getLimit() const;
void setLimit(const quint64 &value);
5d93390e Christian Ehringfeld
506067a2 Christian Ehringfeld
quint64 getOffset() const;
void setOffset(const quint64 &value);
5d93390e Christian Ehringfeld
3160499c Christian Ehringfeld
void appendOrderBy(const OrderBy &orderBy);
void appendOrderBy(const QString &column, const Direction &direction);
QList<OrderBy> getOrderBy() const;
void setOrderBy(const QList<OrderBy> &value);

82442988 Christian Ehringfeld
void appendGroupBy(const QString &value);
3160499c Christian Ehringfeld
QStringList getGroupBy() const;
void setGroupBy(const QStringList &value);

QList<Expression> getSelect() const;
void appendSelect(const Expression &value);
void appendSelect(const QString &value);
void setSelect(const QList<Expression> &value);
void setSelect(const QStringList &value);
5d93390e Christian Ehringfeld
82442988 Christian Ehringfeld
void appendWhere(const QString &condition);
void appendWhere(const Expression &condition);
506067a2 Christian Ehringfeld
QList<Expression> getWhere() const;
void setWhere(const QList<Expression> &value);

82442988 Christian Ehringfeld
void appendHaving(const QString &condition);
void appendHaving(const Expression &condition);
506067a2 Christian Ehringfeld
QList<Expression> getHaving() const;
void setHaving(const QList<Expression> &value);

38838b5b Christian Ehringfeld
private:
3160499c Christian Ehringfeld
QList<Expression> select;
5d93390e Christian Ehringfeld
QString selectOption = QStringLiteral("");
bool distinct = false;
QStringList from;
QStringList groupBy;
3160499c Christian Ehringfeld
QList<OrderBy> orderBy;
506067a2 Christian Ehringfeld
QList<Expression> where;
QList<Expression> having;
5d93390e Christian Ehringfeld
QList<Join> joins;
QHash<QString, QVariant> params;
506067a2 Christian Ehringfeld
quint64 limit = 0;
quint64 offset = 0;
5d93390e Christian Ehringfeld
};

enum class JokerPosition {
FRONT, // e.g. "%foo"
BEHIND, // e.g. "foo%"
584721e5 Christian Ehringfeld
BOTH, // e.g. "%foo%"
NONE
5d93390e Christian Ehringfeld
};


}

#endif // QUERY_H