7 #ifndef litesql_expr_hpp
8 #define litesql_expr_hpp
23 virtual std::string asString()
const {
return True; }
25 const std::vector<std::string>& getExtraTables()
const {
31 std::vector<std::string> extraTables;
38 RawExpr(
const std::string& e) : expr(e) {}
39 virtual std::string asString()
const {
return expr; }
51 : op(o), e1(e1_), e2(e2_) { }
56 virtual std::string asString()
const {
57 std::string res =
"(" + e1.asString() +
") " + op
58 +
" (" + e2.asString() +
")";
66 virtual std::string asString()
const {
67 if (e1.asString() ==
True)
69 else if (e2.asString() ==
True)
72 return Connective::asString();
80 virtual std::string asString()
const {
81 if ((e1.asString() ==
True)||(e2.asString() ==
True))
84 return Connective::asString();
92 Not(
const Expr & _exp) : exp(_exp) {}
93 virtual std::string asString()
const {
94 return "not ("+exp.asString()+
")";
106 Oper(
const FieldType & fld,
const std::string& o,
const std::string& d)
107 : field(fld), op(o), data(d), escape(
true) {
108 extraTables.push_back(fld.table());
111 : field(fld), op(o), data(f2.fullName()), escape(
false) {
112 extraTables.push_back(fld.table());
116 virtual std::string asString()
const {
118 res += field.fullName() +
" " + op +
" " + (escape ?
escapeSQL(data) : data);
126 :
Oper(fld,
"=", d) {}
128 :
Oper(fld,
"=", f2) {}
135 :
Oper(fld,
"<>", d) {}
137 :
Oper(fld,
"<>", f2) {
145 :
Oper(fld,
">", d) {}
147 :
Oper(fld,
">", d) {}
154 :
Oper(fld,
">=", d) {}
156 :
Oper(fld,
">=", d) {}
163 :
Oper(fld,
"<", d) {}
165 :
Oper(fld,
"<", d) {}
172 :
Oper(fld,
"<=", d) {}
174 :
Oper(fld,
"<=", d) {}
181 :
Oper(fld,
"like", d) {}
188 :
Oper(fld,
"in",
"("+set+
")") {};
190 virtual std::string asString()
const {
191 return field.fullName() +
" " + op +
" " + data;
196 Or operator||(
const Expr& o1,
const Expr& o2);
201 Eq operator==(
const FieldType& fld,
const FieldType& f2);
202 Gt operator>(
const FieldType& fld,
const FieldType& o2);
203 GtEq operator>=(
const FieldType& fld,
const FieldType& o2);
204 Lt operator<(
const FieldType& fld,
const FieldType& o2);
205 LtEq operator<=(
const FieldType& fld,
const FieldType& o2);
206 NotEq operator!=(
const FieldType& fld,
const FieldType& f2);
233 Not operator!(
const Expr &exp);
connects two expressions with and-operator.
Definition: expr.hpp:63
used to connect two expressions
Definition: expr.hpp:44
equality operator
Definition: expr.hpp:123
A base class for expression in WHERE - clause.
Definition: expr.hpp:18
static const char * True
constant for True expression
Definition: expr.hpp:21
greater or equal operator
Definition: expr.hpp:151
greater than operator
Definition: expr.hpp:142
in operator
Definition: expr.hpp:185
like operator
Definition: expr.hpp:178
less than or equal operator
Definition: expr.hpp:169
less than operator
Definition: expr.hpp:160
inequality operator
Definition: expr.hpp:132
negates expression
Definition: expr.hpp:88
base class of operators in expressions
Definition: expr.hpp:99
connects two expression with or-operator.
Definition: expr.hpp:76
used to inject custom expression into WHERE-clause
Definition: expr.hpp:35
a class that helps creating SELECT-SQL statements.
Definition: selectquery.hpp:20
contains FieldType- and Field-classes
std::string escapeSQL(const std::string &str)
escapes ' characters so that they do not break SQL statements.
includes string.hpp and split.hpp