TreeFrogFramework  1.18
tcriteria.h
Go to the documentation of this file.
1 #ifndef TCRITERIA_H
2 #define TCRITERIA_H
3 
4 #include <QVariant>
5 #include <TGlobal>
6 
7 
9 {
10 public:
11  TCriteria();
12  TCriteria(const TCriteria &other);
13 
14  TCriteria(int property, const QVariant &val);
15  TCriteria(int property, TSql::ComparisonOperator op);
16  TCriteria(int property, TSql::ComparisonOperator op, const QVariant &val);
17  TCriteria(int property, TSql::ComparisonOperator op, const QVariant &val1, const QVariant &val2);
18  TCriteria(int property, TSql::ComparisonOperator op1, TSql::ComparisonOperator op2, const QVariant &val);
19  TCriteria(int property, TMongo::ComparisonOperator op);
20  TCriteria(int property, TMongo::ComparisonOperator op, const QVariant &val);
21  ~TCriteria() { }
22 
23  TCriteria &add(int property, const QVariant &val);
24  TCriteria &add(int property, TSql::ComparisonOperator op);
25  TCriteria &add(int property, TSql::ComparisonOperator op, const QVariant &val);
26  TCriteria &add(int property, TSql::ComparisonOperator op, const QVariant &val1, const QVariant &val2);
27  TCriteria &add(int property, TSql::ComparisonOperator op1, TSql::ComparisonOperator op2, const QVariant &val);
28  TCriteria &add(const TCriteria &criteria);
29  TCriteria &addOr(int property, const QVariant &val);
30  TCriteria &addOr(int property, TSql::ComparisonOperator op);
31  TCriteria &addOr(int property, TSql::ComparisonOperator op, const QVariant &val);
32  TCriteria &addOr(int property, TSql::ComparisonOperator op, const QVariant &val1, const QVariant &val2);
33  TCriteria &addOr(int property, TSql::ComparisonOperator op1, TSql::ComparisonOperator op2, const QVariant &val);
34  TCriteria &addOr(const TCriteria &criteria);
35 
36  // For MongoDB
37  TCriteria &add(int property, TMongo::ComparisonOperator op);
38  TCriteria &add(int property, TMongo::ComparisonOperator op, const QVariant &val);
39  TCriteria &addOr(int property, TMongo::ComparisonOperator op);
40  TCriteria &addOr(int property, TMongo::ComparisonOperator op, const QVariant &val);
41 
42  bool isEmpty() const;
43  void clear();
44 
45  const TCriteria operator&&(const TCriteria &criteria) const;
46  const TCriteria operator||(const TCriteria &criteria) const;
47  const TCriteria operator!() const;
48  TCriteria &operator=(const TCriteria &other);
49 
50 protected:
52  None = 0,
53  And,
54  Or,
55  Not,
56  };
57 
58  const QVariant &first() const { return cri1; }
59  const QVariant &second() const { return cri2; }
60  LogicalOperator logicalOperator() const { return (LogicalOperator)logiOp; }
61  TCriteria &add(LogicalOperator op, const TCriteria &criteria);
62 
63 private:
64  QVariant cri1;
65  QVariant cri2;
66  int logiOp;
67 
68  template<class T> friend class TCriteriaConverter;
69  template<class T> friend class TCriteriaMongoConverter;
70 };
71 
72 Q_DECLARE_METATYPE(TCriteria)
73 
74 #endif // TCRITERIA_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
const QVariant & first() const
This function is for internal use only.
Definition: tcriteria.h:58
LogicalOperator
Definition: tcriteria.h:51
const QVariant & second() const
This function is for internal use only.
Definition: tcriteria.h:59
Definition: tcriteria.h:54
ComparisonOperator
Definition: tfnamespace.h:238
ComparisonOperator
Definition: tfnamespace.h:280
LogicalOperator logicalOperator() const
This function is for internal use only.
Definition: tcriteria.h:60
Definition: tcriteria.h:53
~TCriteria()
Definition: tcriteria.h:21
The TCriteria class represents a WHERE clause without SQL for the sake of database abstraction...
Definition: tcriteria.h:8
Definition: tcriteria.h:55