LiteSQL
selectquery.hpp
Go to the documentation of this file.
1 /* LiteSQL
2  *
3  * The list of contributors at http://litesql.sf.net/
4  *
5  * See LICENSE for copyright information. */
6 
7 
8 #ifndef litesql_selectquery_hpp
9 #define litesql_selectquery_hpp
10 
11 #include "litesql/expr.hpp"
12 
16 namespace litesql {
20 class SelectQuery {
21  bool _distinct;
22  int _limit, _offset;
23  std::vector<std::string> _results;
24  std::vector<std::string> _sources;
25  std::string _where;
26  std::vector<std::string> _groupBy;
27  std::string _having;
28  std::vector<std::string> _orderBy;
29 public:
30  SelectQuery() : _distinct(false), _limit(0), _offset(0), _where("True") {}
31  SelectQuery & distinct(bool d);
32  SelectQuery & limit(int value);
33  SelectQuery & offset(int value);
34  SelectQuery & result(const std::string& r);
35  SelectQuery & clearResults();
36  SelectQuery & source(const std::string& s, const std::string& alias="");
37  SelectQuery & where(const Expr & w);
38  SelectQuery & where(const std::string& w);
39  SelectQuery & groupBy(const std::string& gb);
40  SelectQuery & having(const Expr & h);
41  SelectQuery & having(const std::string& h);
42  SelectQuery & orderBy(const std::string& ob, bool ascending=true);
43  operator std::string() const;
44  std::string asString() const { return this->operator std::string(); }
45 };
46 }
47 
48 #endif
A base class for expression in WHERE - clause.
Definition: expr.hpp:18
a class that helps creating SELECT-SQL statements.
Definition: selectquery.hpp:20
Contains Expr-class hierarchy and operator overloadings for them.

SourceForge.net Logo