QDjango
 All Classes Functions Typedefs Enumerations Enumerator Properties Groups Pages
QDjangoWhere.h
1 /*
2  * Copyright (C) 2010-2012 Jeremy LainĂ©
3  * Contact: http://code.google.com/p/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_EXPORT QDjangoWhere
41 {
42 public:
44  enum Operation
45  {
69  IsNull
70  };
71 
72  QDjangoWhere();
73  QDjangoWhere(const QDjangoWhere &other);
74  QDjangoWhere(const QString &key, QDjangoWhere::Operation operation, QVariant value);
75  ~QDjangoWhere();
76 
77  QDjangoWhere& operator=(const QDjangoWhere &other);
78  QDjangoWhere operator!() const;
79  QDjangoWhere operator&&(const QDjangoWhere &other) const;
80  QDjangoWhere operator||(const QDjangoWhere &other) const;
81 
82  void bindValues(QDjangoQuery &query) const;
83  bool isAll() const;
84  bool isNone() const;
85  QString sql(const QSqlDatabase &db) const;
86 
87 private:
88  QSharedDataPointer<QDjangoWherePrivate> d;
89  friend class QDjangoCompiler;
90 };
91 
92 #endif