Dv::Sql::SelectExp Class Reference

This class represents a wrapper around a (reference-counted) pointer to a Dv::Sql::boolexp. More...

#include <select_exp.h>

Collaboration diagram for Dv::Sql::SelectExp:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SelectExp (const boolexp *e)
 Constructor.
const boolexpexp () const
 Return underlying Dv::Sql::boolexp.
std::ostream & print (std::ostream &os, const Dv::Sql::Db &db) const
 Print the expression in sql format.
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 query (const Dv::Sql::Table::Ref &table, const std::string &rest="") const
 Return a complete select statement corresponding to this expression and a table.
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.

Static Public Member Functions

static SelectExp true_exp ()
 Return "true" SelectExp.

Private Attributes

Dv::shared_ptr< const boolexpexp_

Detailed Description

This class represents a wrapper around a (reference-counted) pointer to a Dv::Sql::boolexp.

Example
 Dv::Sql::Table::Column col1;
 Dv::Sql::Table::Column col2;
 int i;
 std::string s;
 Dv::Sql::SelectExp exp( col1 > i && col2 == s );

Definition at line 356 of file select_exp.h.


Constructor & Destructor Documentation

Dv::Sql::SelectExp::SelectExp ( const boolexp e  )  [inline]

Constructor.

It simply wraps a (reference-counted) pointer to an expression.

Parameters:
e pointer to expression to be wrapped

Definition at line 362 of file select_exp.h.


Member Function Documentation

const boolexp& Dv::Sql::SelectExp::exp (  )  const [inline]

Return underlying Dv::Sql::boolexp.

Returns:
underlying Dv::Sql::boolexp.

Definition at line 367 of file select_exp.h.

References exp_.

Referenced by Dv::Sql::complex_boolexp::complex_boolexp().

std::ostream& Dv::Sql::SelectExp::print ( std::ostream &  os,
const Dv::Sql::Db db 
) const

Print the expression in sql format.

Parameters:
os stream to print on
db to use for escaping string values
Returns:
os
const Dv::Sql::Table::Set& Dv::Sql::SelectExp::tables (  )  const [inline]

The set of tables involved in this expression.

Returns:
the set of tables involved in this expression
See also:
Dv::Sql::boolexp::tables

Definition at line 379 of file select_exp.h.

References exp_.

std::string Dv::Sql::SelectExp::from (  )  const [inline]

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::boolexp::from

Definition at line 391 of file select_exp.h.

References exp_.

std::string Dv::Sql::SelectExp::where ( const Dv::Sql::Db db  )  const [inline]

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.
See also:
Dv::Sql::boolexp::where

Definition at line 403 of file select_exp.h.

References exp_.

std::string Dv::Sql::SelectExp::query ( const Dv::Sql::Table::Ref table,
const std::string &  rest = "" 
) const [inline]

Return a complete select statement corresponding to this expression and a table.

The statement retrieves all columns (using "select distinct") of the table.

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

Definition at line 417 of file select_exp.h.

References exp_.

std::string Dv::Sql::SelectExp::from_where ( Dv::Sql::Db db,
const std::string &  rest = "" 
) const [inline]

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::SelectExp::from
Dv::Sql::SelectExp::where

Definition at line 444 of file select_exp.h.

References exp_.

static SelectExp Dv::Sql::SelectExp::true_exp (  )  [static]

Return "true" SelectExp.

Returns:
a true SelectExp
See also:
Dv::Sql::true_boolexp

Member Data Documentation

Definition at line 456 of file select_exp.h.

Referenced by exp(), from(), from_where(), query(), tables(), and where().


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

dvmysql-1.0.3 [17 November, 2010]