iopc::Query Class Reference
[iopclib]

Base query class. More...

#include <query.h>

Inheritance diagram for iopc::Query:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual std::string getSql (Driver &drv, const Type &type) const =0
 Returns SQL SELECT statement representing the current query.

Protected Member Functions

std::string substituteQuery (std::string query, const Type &type, bool useSV=false) const
 Substitutes type, attribute names and metadata codes in a query.


Detailed Description

Base query class.

The class serves as an interface for other Quary implementations.

The only funcitonality provided by this class is the substituteQuery method which substitutes type or attribute names and metadata codes in a query.

See substituteQuery documentation for the substitution rules.


Member Function Documentation

virtual std::string iopc::Query::getSql ( Driver drv,
const Type type 
) const [pure virtual]

Returns SQL SELECT statement representing the current query.

Parameters:
drv Database driver used to generate the statement
type Type for which to generate the statement. Determines the columns/attributes that the SELECT returns.

Implemented in iopc::FreeQuery, and iopc::SimpleQuery.

std::string iopc::Query::substituteQuery ( std::string  query,
const Type type,
bool  useSV = false 
) const [protected]

Substitutes type, attribute names and metadata codes in a query.

In a query it searches for the TYPE_DELIMITER delimited strings which surround type, attribute names with optional metadat code attached and replaces them with type, view names or metadata values. Format of the delimited strings is:

 $(namespace)::TypeName$                // Represents a type (table, view)
 $(namespace)::TypeName::AttributeName$    // Represents an attribute (qualified column name)

To specify metadata for which the TypeName or AttributeName is substituted, following format can be used:

 $::TypeName[metadata.code]$            // Type is substituted for its metadata value
 $::TypeName::AttributeName[metadata.code]$             // Attribute is substituted for its metadata value
 $::TypeName[metadata.code]::AttributeName[metadata.code]$      // Both the Type and Attribute are substituted for the metadata specified

If no metadata is used (like in the first example) and if OidObject is queried, the [db.view.pv] table metadata and [db.viewColumn] attribute metadata is used. If non-OID object is queried, the [db.table] and [db.column] metadata are used.

A special [db.query.skip] table metadata can be specified to skip the table or view column qualification:

 $::TypeName[db.query.skip]::AttributeName$
 // translates only to a column name instead of table(view).columnName

Parameters:
query The query which to translate
type A Type whose instance will be loaded using the query
useSV Forces to use simple view instead of polymorfphic views


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

Generated on Tue Apr 14 16:46:51 2009 for IOPC 2 by  doxygen 1.5.6