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