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
litesql::SelectQuery
a class that helps creating SELECT-SQL statements.
Definition: selectquery.hpp:20
litesql::toString
std::string toString(T a)
returns string representation of passed parameter if it can be written to ostringstream
Definition: string.hpp:20
litesql::RawExpr
used to inject custom expression into WHERE-clause
Definition: expr.hpp:35
selectquery.hpp
litesql::join
std::string join(const std::vector< std::string > &strings, const std::string &delim=" ")
returns strings joined with delimiter
expr.hpp
litesql::Expr
A base class for expression in WHERE - clause.
Definition: expr.hpp:18

SourceForge.net Logo