An abstract base class for boolean expressions. More...
#include <select_exp.h>
Public Member Functions | |
virtual std::ostream & | print (std::ostream &os, const Dv::Sql::Db &db) const =0 |
Print this expression on a stream, using escapes for column values. | |
virtual | ~boolexp () |
Destructor. | |
const Dv::Sql::Table::Set & | tables () const |
The set of tables involved in this expression. | |
std::string | from () const |
Return "from" clause corresponding to this expression. | |
std::string | where (const Dv::Sql::Db &db) const |
Return where clause corresponding to this epression. | |
std::string | from_where (Dv::Sql::Db &db, const std::string &rest="") const |
Return "from .. where .. " part of an sql select statement corresponding to this expression. | |
std::string | query (Dv::Sql::Table::Ref table, const std::string &rest="") const |
Return a complete select statement corresponding to this expression and a table. | |
Protected Member Functions | |
template<typename T > | |
void | add_table (const T &t) |
Add the table(s) mentioned in a (component) of an expression to the list of involved tables. | |
void | add_table (const Dv::Sql::ValueExp &e) |
Add the tables involved in a value expression to the list of involved tables. | |
void | add_table (const Dv::Sql::Table::Column &c) |
Add the table of this column to the list of involved tables. | |
void | add_table (const Dv::Sql::boolexp &c) |
Add the tables involved in an expression to the list of involved tables. | |
Protected Attributes | |
Dv::Sql::Table::Set | tables_ |
Set of tables mentioned in this expression. |
An abstract base class for boolean expressions.
Definition at line 91 of file select_exp.h.
virtual Dv::Sql::boolexp::~boolexp | ( | ) | [inline, virtual] |
Destructor.
Definition at line 101 of file select_exp.h.
virtual std::ostream& Dv::Sql::boolexp::print | ( | std::ostream & | os, | |
const Dv::Sql::Db & | db | |||
) | const [pure virtual] |
Print this expression on a stream, using escapes for column values.
os | stream to print to | |
db | whose associated escape function will be used |
Implemented in Dv::Sql::true_boolexp, Dv::Sql::basic_boolexp< L, R >, Dv::Sql::basic_unary_boolexp< L >, Dv::Sql::match_boolexp, and Dv::Sql::complex_boolexp.
const Dv::Sql::Table::Set& Dv::Sql::boolexp::tables | ( | ) | const [inline] |
The set of tables involved in this expression.
Definition at line 105 of file select_exp.h.
References tables_.
std::string Dv::Sql::boolexp::from | ( | ) | const |
Return "from" clause corresponding to this expression.
from table_1 , table_2 , .. , table_n
table_1
, .. , table_n
are the names of the tables mentioned in the expression. std::string Dv::Sql::boolexp::where | ( | const Dv::Sql::Db & | db | ) | const |
Return where clause corresponding to this epression.
db | database connection (needed for DBMS-dependent escape for string values). |
where condition
condition
is generated by Dv::Sql::boolexp::print. std::string Dv::Sql::boolexp::from_where | ( | Dv::Sql::Db & | db, | |
const std::string & | rest = "" | |||
) | const |
Return "from .. where .. " part of an sql select statement corresponding to this expression.
db | database connection (needed for DBMS-dependent escape for string values). | |
rest | optional suffix to append to the generated string. |
Customer::Row cust; ... Dv::Sql::SelectExp e = acct_cust.match_target(cust) && acct_cust.match() && trans_acct.match(); Dv::Sql::Object total(db, "select sum(transaction.amount) as total" + e.from_where(db));
std::string Dv::Sql::boolexp::query | ( | Dv::Sql::Table::Ref | table, | |
const std::string & | rest = "" | |||
) | const |
Return a complete select statement corresponding to this expression and a table.
The statement retrieves all columns (using "select distinct") of the table. If there are no tables associated with this expression, as can happen e.g. when the expression is "true", then the from clause will be "from table_name" where table_name
is the name of the table
parameter.
table | for which the columns need to be retrieved | |
rest | optional suffix for the statement. |
void Dv::Sql::boolexp::add_table | ( | const T & | t | ) | [inline, protected] |
Add the table(s) mentioned in a (component) of an expression to the list of involved tables.
t | expression component |
Definition at line 180 of file select_exp.h.
Referenced by Dv::Sql::complex_boolexp::complex_boolexp(), and Dv::Sql::match_boolexp::match_boolexp().
void Dv::Sql::boolexp::add_table | ( | const Dv::Sql::ValueExp & | e | ) | [protected] |
Add the tables involved in a value expression to the list of involved tables.
void Dv::Sql::boolexp::add_table | ( | const Dv::Sql::Table::Column & | c | ) | [protected] |
Add the table of this column to the list of involved tables.
void Dv::Sql::boolexp::add_table | ( | const Dv::Sql::boolexp & | c | ) | [protected] |
Add the tables involved in an expression to the list of involved tables.
Dv::Sql::Table::Set Dv::Sql::boolexp::tables_ [protected] |
Set of tables mentioned in this expression.
Definition at line 173 of file select_exp.h.
Referenced by tables().
dvmysql-1.0.3 | [17 November, 2010] |