QDjango: QDjangoWhere.h Source File

QDjango

QDjangoWhere.h
1 /*
2 * Copyright (C) 2010-2015 Jeremy Lainé
3 * Contact: https://github.com/jlaine/qdjango
4 *
5 * This file is part of the QDjango Library.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
17
18 #ifndef QDJANGO_WHERE_H
19 #define QDJANGO_WHERE_H
20
21 #include <QSharedDataPointer>
22 #include <QVariant>
23
24 #include "QDjango_p.h"
25
26 class QDjangoMetaModel;
27 class QDjangoQuery;
28 class QDjangoWherePrivate;
29
40 class QDJANGO_DB_EXPORT QDjangoWhere
41 {
42 public:
43 enum Operation
44 {
45 None,
46 Equals,
47 NotEquals,
48 GreaterThan,
49 LessThan,
50 GreaterOrEquals,
51 LessOrEquals,
52 StartsWith,
53 EndsWith,
54 Contains,
55 IsIn,
56 IsNull,
57 IEquals,
58 INotEquals,
59 IStartsWith,
60 IEndsWith,
61 IContains
62 };
63
64 enum AggregateType{
65 AVG,
66 COUNT,
67 SUM,
68 MIN,
69 MAX
70 };
71 QDjangoWhere();
72 QDjangoWhere(const QDjangoWhere &other);
73 QDjangoWhere(const QString &key, QDjangoWhere::Operation operation, QVariant value);
74 ~QDjangoWhere();
75
76 QDjangoWhere& operator=(const QDjangoWhere &other);
77 QDjangoWhere operator!() const;
78 QDjangoWhere operator&&(const QDjangoWhere &other) const;
79 QDjangoWhere operator||(const QDjangoWhere &other) const;
80
81 void bindValues(QDjangoQuery &query) const;
82 bool isAll() const;
83 bool isNone() const;
84 QString sql(const QSqlDatabase &db) const;
85 QString toString() const;
86
87 private:
88 QSharedDataPointer<QDjangoWherePrivate> d;
89 friend class QDjangoCompiler;
90 };
91
92 #endif
QDjangoWhere::StartsWith
@ StartsWith
Definition: QDjangoWhere.h:52
QDjangoWhere::EndsWith
@ EndsWith
Definition: QDjangoWhere.h:53
QDjangoWhere::IEquals
@ IEquals
Definition: QDjangoWhere.h:57
QDjangoWhere::LessThan
@ LessThan
Definition: QDjangoWhere.h:49
QDjangoWhere::IStartsWith
@ IStartsWith
Definition: QDjangoWhere.h:59
QDjangoWhere
The QDjangoWhere class expresses an SQL constraint.
Definition: QDjangoWhere.h:41
QDjangoWhere::LessOrEquals
@ LessOrEquals
Definition: QDjangoWhere.h:51
QDjangoWhere::Equals
@ Equals
Definition: QDjangoWhere.h:46
QDjangoWhere::INotEquals
@ INotEquals
Definition: QDjangoWhere.h:58
QDjangoMetaModel
The QDjangoMetaModel class holds the database schema for a model.
Definition: QDjangoMetaModel.h:66
QDjangoWhere::Operation
Operation
Definition: QDjangoWhere.h:44
QDjangoWhere::None
@ None
Definition: QDjangoWhere.h:45
QDjangoWhere::NotEquals
@ NotEquals
Definition: QDjangoWhere.h:47
QDjangoWhere::Contains
@ Contains
Definition: QDjangoWhere.h:54
QDjangoWhere::IsIn
@ IsIn
Definition: QDjangoWhere.h:55
QDjangoWhere::GreaterOrEquals
@ GreaterOrEquals
Definition: QDjangoWhere.h:50
QDjangoWhere::IsNull
@ IsNull
Definition: QDjangoWhere.h:56
QDjangoWhere::IEndsWith
@ IEndsWith
Definition: QDjangoWhere.h:60
QDjangoWhere::GreaterThan
@ GreaterThan
Definition: QDjangoWhere.h:48