Dv::Sql::boolexp Class Reference

An abstract base class for boolean expressions. More...

#include <select_exp.h>

Inheritance diagram for Dv::Sql::boolexp:
Inheritance graph
[legend]

List of all members.

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::Settables () 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.

Detailed Description

An abstract base class for boolean expressions.

See also:
Dv::Sql::basic_boolexp
Dv::Sql::complex_boolexp
Dv::Sql::true_boolexp
Dv::Sql::SelectExp

Definition at line 91 of file select_exp.h.


Constructor & Destructor Documentation

virtual Dv::Sql::boolexp::~boolexp (  )  [inline, virtual]

Destructor.

Definition at line 101 of file select_exp.h.


Member Function Documentation

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.

Parameters:
os stream to print to
db whose associated escape function will be used
Returns:
os

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.

Returns:
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.

Returns:
A string of the form
  from table_1 , table_2 , .. , table_n
where "from" is preceeded by a space and table_1, .. , table_n are the names of the tables mentioned in the expression.
See also:
Dv::Sql::boolexp::tables
Dv::Sql::SelectExp::from
std::string Dv::Sql::boolexp::where ( const Dv::Sql::Db db  )  const

Return where clause corresponding to this epression.

Parameters:
db database connection (needed for DBMS-dependent escape for string values).
Returns:
a string of the form
  where condition
where "where" is preceeded by a space and 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.

Parameters:
db database connection (needed for DBMS-dependent escape for string values).
rest optional suffix to append to the generated string.
Returns:
the string
 from() + where() + rest
Example
 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));
See also:
Dv::Sql::boolexp::from
Dv::Sql::boolexp::where
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.

Parameters:
table for which the columns need to be retrieved
rest optional suffix for the statement.
Returns:
a full sql select statement of the form
 table->select(true) +  from() + where(table->db()) + rest
See also:
Dv::Sql::Table::select
Dv::Sql::SelectExp::from
template<typename T >
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.

Parameters:
t expression component
See also:
Dv::Sql::boolexp::tables

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.

See also:
Dv::Sql::ValueExp::tables
Dv::Sql::boolexp::add_table(const T&)
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.

See also:
Dv::Sql::boolexp::tables
Dv::Sql::boolexp::add_table(const T&)
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.

See also:
Dv::Sql::boolexp::tables
Dv::Sql::boolexp::add_table(const T&)

Member Data Documentation

Set of tables mentioned in this expression.

Definition at line 173 of file select_exp.h.

Referenced by tables().


The documentation for this class was generated from the following file:

dvmysql-1.0.3 [17 November, 2010]