if-then-else
.
More...
#include <ifexpression.h>
Public Member Functions | |
IfExpression (CondExpression *_cond, Expression *_thenexp, Expression *_elseexp) | |
Constructor. | |
virtual | ~IfExpression () |
virtual void | scopeCheck (vector< unsigned > &def_vars, vector< unsigned > &introduced_vars, vector< unsigned > &violating_vars) |
virtual void | replaceVarId (unsigned old_id, unsigned new_id) |
virtual void | mergeSequences () |
virtual void | extractFSAMap (FSAMap *fsamap, unsigned parent_var) |
virtual void | extractParVarMap (ParVarMap *parvarmap) |
virtual void | extractDependencies (vector< DependencySet * > *depset) |
virtual Expression * | placeSignOffs (vector< SignOffExpression * > &signoffs) |
virtual void | rewriteWhereExps () |
virtual void | rewriteEmptyFuncts () |
virtual void | rewriteVarstepCondExps () |
virtual void | rewriteAggregateFuncts () |
virtual void | rewriteVarsteps () |
virtual void | print (OutputStream &dos) const |
virtual void | init (BufferNode *root) |
virtual void | eval (OutputStream &eos, Environment *env, unsigned modus) |
virtual bool | containsDirectOutput () |
Private Attributes | |
CondExpression * | cond |
The entered CondExpression. | |
Expression * | thenexp |
The entered Expression. | |
Expression * | elseexp |
The entered Expression. |
if-then-else
.
Represents XQuery conditional expression if-then-else
, which takes therefore one CondExpression and two Expression, e.g. if (fn:exists($x)) then $x/title else()
, as arguments and returns the then
Expression if the CondExpression is true
, the else
Expression otherwise.
Definition at line 54 of file ifexpression.h.
IfExpression::IfExpression | ( | CondExpression * | _cond, | |
Expression * | _thenexp, | |||
Expression * | _elseexp | |||
) |
Constructor.
Constructor - creating object for one CondExpression and two Expression.
[in] | _cond | Pointer to a CondExpression object. |
[in] | _thenexp | Pointer to a Expression object. |
[in] | _elseexp | Pointer to a Expression object. |
Definition at line 37 of file ifexpression.cpp.
IfExpression::~IfExpression | ( | ) | [virtual] |
bool IfExpression::containsDirectOutput | ( | ) | [virtual] |
Returns if the corresponding expression produces direct output.
Returns if the corresponding expression produces direct output. Direct output is meant that this subexpression produces output such as node constructs or strings.
bool | true if the corresponding expression produces direct output, false otherwise. |
Reimplemented from Expression.
Definition at line 194 of file ifexpression.cpp.
References Expression::containsDirectOutput(), elseexp, Expression::getType(), and thenexp.
Referenced by WhereExpression::containsDirectOutput().
void IfExpression::eval | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [virtual] |
Evaluates the expression in the given environment.
Evaluates the expression in the given environment. The evaluation takes place in the environment that is passed to this method. In addition, the parameter modus is one of the following: EVAL_QUERY, EVAL_QUERY_SILENT or EVAL_SIGNOFF (see also the corresponding defines for more information). This method implements the XQuery semantics for the standard expression types, but also the GCX specific extensions like signOff-statements.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to an Environment object. |
[in] | modus | The query evaluation mode. |
RuntimeException | If illegal evaluation mode. |
Reimplemented from Expression.
Definition at line 164 of file ifexpression.cpp.
References cond, elseexp, Expression::eval(), EVAL_QUERY, EVAL_SIGNOFF, CondExpression::evalCond(), and thenexp.
Referenced by WhereExpression::eval().
void IfExpression::extractDependencies | ( | vector< DependencySet * > * | depset | ) | [virtual] |
Extracts the needed dependencies of a query.
Extracts the needed dependencies of a query, which are needed for constructing the ProjectionTree.
[in,out] | depset | Pointer to a vector containing Pointer to DependencySet objects. |
void |
Reimplemented from Expression.
Definition at line 79 of file ifexpression.cpp.
References cond, elseexp, Expression::extractDependencies(), and thenexp.
Referenced by WhereExpression::extractDependencies().
void IfExpression::extractFSAMap | ( | FSAMap * | fsamap, | |
unsigned | parent_var | |||
) | [virtual] |
Extracts the needed first straight ancestor (FSA) variables map.
Extracts the needed first straight ancestor (FSA) variables map, which is needed for correct insertion of SignOffExpression.
[in,out] | fsamap | Pointer to a FSAMap object. |
[in] | parent_var | Parent variable. |
void |
Reimplemented from Expression.
Definition at line 67 of file ifexpression.cpp.
References cond, elseexp, Expression::extractFSAMap(), and thenexp.
Referenced by WhereExpression::extractFSAMap().
void IfExpression::extractParVarMap | ( | ParVarMap * | parvarmap | ) | [virtual] |
Extracts the needed parent variable (ParVar) map.
Extracts the needed parent variable (ParVar) map, which is needed for constructing the VariableTree.
[in,out] | parvarmap | Pointer to a ParVarMap object. |
void |
Reimplemented from Expression.
Definition at line 73 of file ifexpression.cpp.
References cond, elseexp, Expression::extractParVarMap(), and thenexp.
Referenced by WhereExpression::extractParVarMap().
void IfExpression::init | ( | BufferNode * | root | ) | [virtual] |
Initializes the query for evaluation.
Initializes the query for evaluation. Up to now only all required BufferIterator objects are created to speed up query evaluation.
[in] | root | Pointer to a BufferNode object. |
void |
Reimplemented from Expression.
Definition at line 158 of file ifexpression.cpp.
References cond, elseexp, Expression::init(), and thenexp.
Referenced by WhereExpression::init().
void IfExpression::mergeSequences | ( | ) | [virtual] |
Merges belonging together XQuery sequences into a single sequence.
Merges belonging together XQuery sequences into a single sequence, which is done because of better/nicer output look.
void |
Reimplemented from Expression.
Definition at line 61 of file ifexpression.cpp.
References cond, elseexp, Expression::mergeSequences(), and thenexp.
Referenced by WhereExpression::mergeSequences().
Expression * IfExpression::placeSignOffs | ( | vector< SignOffExpression * > & | signoffs | ) | [virtual] |
Places all signOff-statements in the corresponding query.
Places all signOff-statements in the corresponding query, which are needed for active garbage collection by removing Role from the BufferNode.
[in] | signoffs | Pointer to a vector containing Pointer to SignOffExpression objects. |
Expression* | Pointer to a Expression object (following expression in the corresponding query). |
Reimplemented from Expression.
Definition at line 85 of file ifexpression.cpp.
References cond, elseexp, Expression::placeSignOffs(), and thenexp.
Referenced by WhereExpression::placeSignOffs().
void IfExpression::print | ( | OutputStream & | dos | ) | const [virtual] |
Prints the expression.
Prints the expression.
[in] | dos | Pointer to a OutputStream object. |
void |
Implements Expression.
Definition at line 145 of file ifexpression.cpp.
References decrementIndents(), incrementIndents(), NEWLINE, and writeIndents().
void IfExpression::replaceVarId | ( | unsigned | old_id, | |
unsigned | new_id | |||
) | [virtual] |
Replaces all matching variable IDs by a new one.
Replaces all matching variable IDs by a new one, which is needed in case of calling method rewriteVarsteps().
[in] | old_id | Old variable ID. |
[in] | new_id | New variable ID, which should be introduced instead. |
void |
Reimplemented from Expression.
Definition at line 55 of file ifexpression.cpp.
References cond, elseexp, Expression::replaceVarId(), and thenexp.
void IfExpression::rewriteAggregateFuncts | ( | ) | [virtual] |
Rewrites all arguments of all aggregate functions into an equivalent for-clause (with return-clause).
Rewrites all arguments of all aggregate functions into an equivalent for-clause (with return-clause).
void |
Reimplemented from Expression.
Definition at line 111 of file ifexpression.cpp.
References cond, elseexp, Expression::rewriteAggregateFuncts(), and thenexp.
Referenced by WhereExpression::rewriteAggregateFuncts().
void IfExpression::rewriteEmptyFuncts | ( | ) | [virtual] |
Rewrites all fn:empty
XQuery functions into equivalent fn:not(fn:exists)
XQuery functions.
Rewrites all fn:empty
XQuery functions into equivalent fn:not(fn:exists)
XQuery functions.
void |
Reimplemented from Expression.
Definition at line 99 of file ifexpression.cpp.
References cond, elseexp, Expression::rewriteEmptyFuncts(), and thenexp.
Referenced by WhereExpression::rewriteEmptyFuncts().
void IfExpression::rewriteVarstepCondExps | ( | ) | [virtual] |
Rewrites all if($x)
if-conditions into equivalent if(fn:not(fn:empty($x)))
XQuery expressions.
Rewrites all if($x)
if-conditions into equivalent if(fn:not(fn:empty($x)))
XQuery expressions.
void |
Reimplemented from Expression.
Definition at line 105 of file ifexpression.cpp.
References cond, elseexp, Expression::rewriteVarstepCondExps(), and thenexp.
Referenced by WhereExpression::rewriteVarstepCondExps().
void IfExpression::rewriteVarsteps | ( | ) | [virtual] |
Rewrites all varstep expressions, which produces output into an equivalent for-clause (with return-clause).
Rewrites all varstep expressions, which produces output into an equivalent for-clause (with return-clause). This method belongs to the 'earlier execution of signoff-statements' optimization.
void |
Reimplemented from Expression.
Definition at line 117 of file ifexpression.cpp.
References VarExpression::clone(), elseexp, VarName::getInstance(), Expression::getType(), Expression::rewriteVarsteps(), and thenexp.
Referenced by WhereExpression::rewriteVarsteps().
void IfExpression::rewriteWhereExps | ( | ) | [virtual] |
Rewrites all where-clauses in the query into equivalent if-expressions.
Rewrites all where-clauses in the query into equivalent if-expressions, i.e. rewrites all WhereExpression into equivalent IfExpression.
void |
Reimplemented from Expression.
Definition at line 93 of file ifexpression.cpp.
References cond, elseexp, Expression::rewriteWhereExps(), and thenexp.
Referenced by WhereExpression::rewriteWhereExps().
void IfExpression::scopeCheck | ( | vector< unsigned > & | def_vars, | |
vector< unsigned > & | introduced_vars, | |||
vector< unsigned > & | violating_vars | |||
) | [virtual] |
Returns if all used variables were previously (through a for-clause) defined or if a variable leaves their defined scope.
Returns if all used variables were previously (through a for-clause) defined or if a variable leaves their defined scope.
[in] | def_vars | Vector containing all previously defined variables. |
[in] | introduced_vars | Vector containing all up to this expression defined variables. |
[in] | violating_vars | Vector containing all variables which violates the scope condition. |
void |
Reimplemented from Expression.
Definition at line 47 of file ifexpression.cpp.
References cond, elseexp, Expression::scopeCheck(), and thenexp.
CondExpression * IfExpression::cond [private] |
The entered CondExpression.
The entered CondExpression, which is the first argument of the constructor and defines the if
-condition.
Definition at line 159 of file ifexpression.h.
Referenced by eval(), extractDependencies(), extractFSAMap(), extractParVarMap(), init(), mergeSequences(), placeSignOffs(), replaceVarId(), rewriteAggregateFuncts(), rewriteEmptyFuncts(), rewriteVarstepCondExps(), rewriteWhereExps(), scopeCheck(), and ~IfExpression().
Expression * IfExpression::elseexp [private] |
The entered Expression.
The entered Expression, which is the third argument of the constructor and defines the else
-case.
Definition at line 173 of file ifexpression.h.
Referenced by containsDirectOutput(), eval(), extractDependencies(), extractFSAMap(), extractParVarMap(), init(), mergeSequences(), placeSignOffs(), replaceVarId(), rewriteAggregateFuncts(), rewriteEmptyFuncts(), rewriteVarstepCondExps(), rewriteVarsteps(), rewriteWhereExps(), scopeCheck(), and ~IfExpression().
Expression * IfExpression::thenexp [private] |
The entered Expression.
The entered Expression, which is the second argument of the constructor and defines the then
-case.
Definition at line 166 of file ifexpression.h.
Referenced by containsDirectOutput(), eval(), extractDependencies(), extractFSAMap(), extractParVarMap(), init(), mergeSequences(), placeSignOffs(), replaceVarId(), rewriteAggregateFuncts(), rewriteEmptyFuncts(), rewriteVarstepCondExps(), rewriteVarsteps(), rewriteWhereExps(), scopeCheck(), and ~IfExpression().