ffead.server.doc
CibernateQuery.h
1 /*
2  * CibernateQuery.h
3  *
4  * Created on: 19-Feb-2013
5  * Author: sumeetc
6  */
7 
8 #ifndef CIBERNATEQUERY_H_
9 #define CIBERNATEQUERY_H_
10 #include "map"
11 #include "string"
12 #include "Object.h"
13 #include "StringUtil.h"
14 using namespace std;
15 typedef map<string, Object> Parameters;
16 typedef map<int, Object> PosParameters;
17 
19  friend class Cibernate;
20  /*The column bindings used in the where clause for the entity*/
21  Parameters columnBindings;
22  /*The property/column names to be queried for the entity*/
23  Parameters propNameVaues;
24  /*The property/column positions to be queried for the entity*/
25  PosParameters propPosVaues;
26  /*The actual Query string*/
27  string query;
28  /*The actual Order By string*/
29  map<string, bool> orderByDescCols;
30  map<string, bool> orderByAscCols;
31  /*The start and count values required for pagination*/
32  int start, count;
33  /*The class for criteria building*/
34  string className;
35 public:
36  CibernateQuery(string query);
37  CibernateQuery(string query,string className);
38  CibernateQuery addParameter(string,Object);
39  CibernateQuery addParameters(Parameters propNameVaues);
40  CibernateQuery addParameter(int,Object);
41  CibernateQuery addParameters(PosParameters propPosVaues);
42  CibernateQuery addColumnBinding(string,Object);
43  CibernateQuery addColumnBindings(Parameters columnBindings);
44  CibernateQuery orderByAsc(string column);
45  CibernateQuery orderByDesc(string column);
46  CibernateQuery paginate(int,int);
47  virtual ~CibernateQuery();
48  bool isUpdate()
49  {
50  if(StringUtil::toLowerCopy(query).find("select")==0)
51  {
52  return false;
53  }
54  return true;
55  }
56 };
57 
58 #endif /* CIBERNATEQUERY_H_ */