Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

LcgInfo::SQLPredicateTree Class Reference

This class is the base for those implementing a binary tree of nodes that stores a SQL "WHERE predicate". More...

#include <SQLPredicateTree.h>

Inheritance diagram for LcgInfo::SQLPredicateTree:

LcgInfo::PredicateTree LcgInfo::SQLtoLDAPPredicateTree LcgInfo::SQLtoSQLPredicateTree List of all members.

Public Methods

 SQLPredicateTree ()
 Constructor of the class. More...

virtual ~SQLPredicateTree ()
 Destructor of the class.

virtual SQLPredicateTree * create ()=0
 Creates a new node of the type of the node. More...

virtual SQLPredicateTree * clone ()=0
 Recursively copies this node and all the nodes below it. More...

virtual void insertPredicate (std::string const &pPred)
 Modifies this node, creates the necessary children and passes them the appropriate sub-predicates, to make the tree of which this node is the root represent the specified SQL WHERE predicate. More...

virtual std::string evaluate (std::vector< std::string > &pQueries)=0
 Returns the predicate (and possibly list of necessary subqueries) resulting of evaluating this node and all its descendants. More...


Protected Methods

virtual std::string getCHARS_TO_TOKENIZE_PREDICATES ()
 Returns the chars to be used as delimiters when tokenizing predicates to be added to a PredicateTree, in order to parse the table names to be added to the new list of tables for the resulting query. More...


Static Protected Attributes

std::string const CHARS_TO_ESCAPE_IN_SQL_LITERALS = "\t ><=!()"

Detailed Description

This class is the base for those implementing a binary tree of nodes that stores a SQL "WHERE predicate".

Each object is a node linked to its two children nodes (left and right). This class extends the PredicateTree, and overloads the insertPredicate() method, so that the predicate can be built using SQL as query language. Extending classes will overload the evaluate() method and thus define the output query language.

Author:
LCG's EIS Group. CERN.
Version:
1.0
Date:
2004.

Definition at line 23 of file SQLPredicateTree.h.


Constructor & Destructor Documentation

SQLPredicateTree::SQLPredicateTree  
 

Constructor of the class.

It just creates an empty object.

Definition at line 18 of file SQLPredicateTree.cpp.


Member Function Documentation

virtual SQLPredicateTree* LcgInfo::SQLPredicateTree::clone   [pure virtual]
 

Recursively copies this node and all the nodes below it.

The resulting object's dynamic type will be that of the extending class redefining this method It is a trick (similar to a virtual copy constructor) used to allow the recursive copy of the tree.

See also:
create
Returns:
a pointer to a new Predicate node with the same values as this node

Implements LcgInfo::PredicateTree.

Implemented in LcgInfo::SQLtoLDAPPredicateTree.

virtual SQLPredicateTree* LcgInfo::SQLPredicateTree::create   [pure virtual]
 

Creates a new node of the type of the node.

It uses some default values (in order to use a template, use the PredicateTree::clone() method). As said, the object's dynamic type will be that of the extending class redefining this method. It is a trick (virtual constructor) used to allow the recursive creation of the tree when inserting predicates.

See also:
clone
Returns:
a pointer to a new SQLPredicate node with default values

Implements LcgInfo::PredicateTree.

Implemented in LcgInfo::SQLtoLDAPPredicateTree.

Referenced by insertPredicate.

virtual std::string LcgInfo::SQLPredicateTree::evaluate std::vector< std::string > &    pQueries [pure virtual]
 

Returns the predicate (and possibly list of necessary subqueries) resulting of evaluating this node and all its descendants.

Extending classes implementing this method will specify the query language used in the output. It may throw a QueryTranslationException if the node (or one of its children) cannot be parsed properly.

Parameters:
pQueries  to store the list of necessary subqueries (if any)
Returns:
resulting predicate

Implements LcgInfo::PredicateTree.

Implemented in LcgInfo::SQLtoLDAPPredicateTree.

string SQLPredicateTree::getCHARS_TO_TOKENIZE_PREDICATES   [protected, virtual]
 

Returns the chars to be used as delimiters when tokenizing predicates to be added to a PredicateTree, in order to parse the table names to be added to the new list of tables for the resulting query.

It is used by the PredicateTree::addAndPredicate() method.

Reimplemented from LcgInfo::PredicateTree.

Definition at line 154 of file SQLPredicateTree.cpp.

void SQLPredicateTree::insertPredicate std::string const &    pPred [virtual]
 

Modifies this node, creates the necessary children and passes them the appropriate sub-predicates, to make the tree of which this node is the root represent the specified SQL WHERE predicate.

It may throw an QueryTranslationException, if the predicate is not well-formed.

Parameters:
pPredicate  a string with the SQL WHERE predicate to store in the tree

Implements LcgInfo::PredicateTree.

Definition at line 25 of file SQLPredicateTree.cpp.

References create, LcgInfo::delSurroundingChars, LcgInfo::escapeLiterals, LcgInfo::PredicateTree::left, LcgInfo::PredicateTree::right, LcgInfo::PredicateTree::setLeft, and LcgInfo::PredicateTree::setRight.


The documentation for this class was generated from the following files:
Generated on Tue Oct 5 14:42:45 2004 for LCG Information System Interface by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002