Wexus2 0.20
|
00001 00002 /* 00003 * Copyright (c) 2011 Aleksander B. Demko 00004 * This source code is distributed under the MIT license. 00005 * See the accompanying file LICENSE.MIT.txt for details. 00006 */ 00007 00008 #ifndef __INLCLUDED_WEXUS_ACTIVEEXPR_H__ 00009 #define __INLCLUDED_WEXUS_ACTIVEEXPR_H__ 00010 00011 #include <wexus/TR1.h> 00012 00013 #include <QVariant> 00014 #include <QSqlQuery> 00015 00016 namespace wexus 00017 { 00018 class ActiveExpr; 00019 00020 class ActiveClass;//fwd 00021 class ActiveRecord;//fwd 00022 } 00023 00024 class wexus::ActiveExpr 00025 { 00026 public: 00027 /// creates a null expression (empty) 00028 ActiveExpr(void); 00029 /// shallow copy ctor 00030 ActiveExpr(const ActiveExpr &rhs); 00031 /// Variable initer 00032 ActiveExpr(const QVariant &v); 00033 00034 // we have these rather than having operators that take QVariant... good idea? 00035 ActiveExpr(int i); 00036 ActiveExpr(double d); 00037 ActiveExpr(const char *c); 00038 ActiveExpr(const QString &s); 00039 00040 bool isNull(void) const; 00041 00042 /** 00043 * Returns the column index if this expr was built with fromColumn. 00044 * throws if its not such an expression 00045 * 00046 * @author Aleksander Demko 00047 */ 00048 int columnIndex(void) const; 00049 00050 void buildString(ActiveClass &klass, QString &out) const; 00051 void buildBinds(ActiveClass &klass, ActiveRecord &recinst, QSqlQuery &out) const; 00052 00053 // explicit "ctors" 00054 00055 static ActiveExpr fromColumn(int index); 00056 00057 // operators 00058 00059 ActiveExpr operator == (const ActiveExpr &rhs); 00060 ActiveExpr operator != (const ActiveExpr &rhs); 00061 ActiveExpr operator < (const ActiveExpr &rhs); 00062 ActiveExpr operator <= (const ActiveExpr &rhs); 00063 ActiveExpr operator > (const ActiveExpr &rhs); 00064 ActiveExpr operator >= (const ActiveExpr &rhs); 00065 ActiveExpr operator && (const ActiveExpr &rhs); 00066 ActiveExpr operator || (const ActiveExpr &rhs); 00067 00068 private: 00069 class Imp; // internal class 00070 class ColumnIndex; 00071 class BinOp; 00072 class Var; 00073 00074 std::shared_ptr<Imp> dm_imp; 00075 00076 private: 00077 /// internal ctor for the explicit "ctors" 00078 ActiveExpr(const std::shared_ptr<Imp> &imp); 00079 00080 }; 00081 00082 #endif 00083