QDjango
|
00001 /* 00002 * Copyright (C) 2010-2012 Jeremy Lainé 00003 * Contact: http://code.google.com/p/qdjango/ 00004 * 00005 * This file is part of the QDjango Library. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 */ 00017 00018 #ifndef QDJANGO_WHERE_H 00019 #define QDJANGO_WHERE_H 00020 00021 #include <QSharedDataPointer> 00022 #include <QVariant> 00023 00024 #include "QDjango_p.h" 00025 00026 class QDjangoMetaModel; 00027 class QDjangoQuery; 00028 class QDjangoWherePrivate; 00029 00040 class QDJANGO_EXPORT QDjangoWhere 00041 { 00042 public: 00044 enum Operation 00045 { 00047 None, 00049 Equals, 00051 NotEquals, 00053 GreaterThan, 00055 LessThan, 00057 GreaterOrEquals, 00059 LessOrEquals, 00061 StartsWith, 00063 EndsWith, 00065 Contains, 00067 IsIn, 00069 IsNull 00070 }; 00071 00072 QDjangoWhere(); 00073 QDjangoWhere(const QDjangoWhere &other); 00074 QDjangoWhere(const QString &key, QDjangoWhere::Operation operation, QVariant value); 00075 ~QDjangoWhere(); 00076 00077 QDjangoWhere& operator=(const QDjangoWhere &other); 00078 QDjangoWhere operator!() const; 00079 QDjangoWhere operator&&(const QDjangoWhere &other) const; 00080 QDjangoWhere operator||(const QDjangoWhere &other) const; 00081 00082 void bindValues(QDjangoQuery &query) const; 00083 bool isAll() const; 00084 bool isNone() const; 00085 QString sql(const QSqlDatabase &db) const; 00086 00087 private: 00088 QSharedDataPointer<QDjangoWherePrivate> d; 00089 friend class QDjangoCompiler; 00090 }; 00091 00092 #endif