#include <varexpression.h>
Public Member Functions | |
VarExpression () | |
Constructor. | |
VarExpression (const char *_name) | |
Constructor. | |
VarExpression (const char *_name, bool _force) | |
Constructor. | |
VarExpression (EXP_TYPE _type, unsigned _id) | |
Constructor. | |
virtual | ~VarExpression () |
void | scopeCheck (vector< unsigned > &def_vars, vector< unsigned > &introduced_vars, vector< unsigned > &violating_vars) |
void | replaceVarId (unsigned old_id, unsigned new_id) |
void | extractDependencies (vector< DependencySet * > *depset) |
void | print (OutputStream &dos) const |
void | init (BufferNode *root) |
void | eval (OutputStream &eos, Environment *env, unsigned modus) |
unsigned | getId () |
Returns the current (numeric) value of a variable. | |
void | setId (unsigned _id) |
Sets a new (numeric) value for a variable. | |
VarExpression * | clone () |
Returns a new, independent copy of a variable or of this object respectively. | |
bool | isSingleValued () |
void | prepareOperand (OutputStream &eos, Environment *env, unsigned modus) |
void | unprepareOperand () |
virtual Value * | getNextValue () |
Protected Attributes | |
unsigned | id |
The entered variable. | |
Private Attributes | |
BufferIterator * | bit |
The initialized BufferIterator for this variable. |
Represents an XQuery variable, e.g. $x
, $z
or $root
, which takes a string as argument and returns the current binding to a BufferNode for a variable.
To get a variable name from a numeric value a look up in VarName is needed!
Definition at line 53 of file varexpression.h.
VarExpression::VarExpression | ( | ) |
Constructor.
Constructor - creating object for variable $root
.
Definition at line 37 of file varexpression.cpp.
Referenced by clone().
VarExpression::VarExpression | ( | const char * | _name | ) |
Constructor.
Constructor - creating object for a string (variable).
[in] | _name | Pointer to a char object. |
Definition at line 41 of file varexpression.cpp.
VarExpression::VarExpression | ( | const char * | _name, | |
bool | _force | |||
) |
Constructor.
Constructor - creating object for a string (variable).
[in] | _name | Pointer to a char object. |
[in] | _force | true if force insertion of variable into VarName, false otherwise. |
Definition at line 48 of file varexpression.cpp.
VarExpression::VarExpression | ( | EXP_TYPE | _type, | |
unsigned | _id | |||
) |
Constructor.
Constructor - creating object for an EXP_TYPE and a numeric value of a variable.
[in] | _type | EXP_TYPE. |
[in] | _id | Numeric value of a variable. |
Definition at line 56 of file varexpression.cpp.
VarExpression::~VarExpression | ( | ) | [virtual] |
VarExpression * VarExpression::clone | ( | ) |
Returns a new, independent copy of a variable or of this object respectively.
Returns a new, independent copy of a variable or of this object respectively.
VarExpression* | Copy of a variable or of this object respectively. |
Reimplemented in VarStepExpression.
Definition at line 128 of file varexpression.cpp.
References setId(), and VarExpression().
Referenced by AggregateFunctExpression::rewriteAggregateFuncts(), SequenceExpression::rewriteVarsteps(), NodeConstructExpression::rewriteVarsteps(), IfExpression::rewriteVarsteps(), and ForExpression::rewriteVarsteps().
void VarExpression::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.
Reimplemented in VarStepExpression.
Definition at line 104 of file varexpression.cpp.
References bit, BufferIterator::clear(), EVAL_QUERY, EVAL_SIGNOFF, BufferIterator::getNext(), Environment::getNodeBinding(), BufferIterator::init(), BufferNode::print(), and READ_UP_TO_CLOSE_BASE.
void VarExpression::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.
Reimplemented in VarStepExpression.
Definition at line 85 of file varexpression.cpp.
References id.
unsigned VarExpression::getId | ( | ) | [inline] |
Returns the current (numeric) value of a variable.
Returns the current (numeric) value of a variable, i.e. returns the member variable.
unsigned | Current (numeric) value of a variable. |
Definition at line 123 of file varexpression.h.
References id.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), SignOffExpression::eval(), ForExpression::eval(), ExistsCondExpression::evalCond(), ForExpression::evalSignOffForBinding(), ExistsCondExpression::extractDependencies(), ForExpression::extractFSAMap(), ForExpression::extractParVarMap(), SignOffExpression::getVar(), ForExpression::placeSignOffs(), ForExpression::replaceVarId(), ForExpression::scopeCheck(), and SignOffExpression::SignOffExpression().
Value * VarExpression::getNextValue | ( | ) | [virtual] |
Returns the next value of the operand.
Returns the next value of the operand for iteration.
Value* | Pointer to a Value object. |
Implements OperandExpression.
Reimplemented in VarStepExpression.
Definition at line 145 of file varexpression.cpp.
References bit, OperandExpression::cur_val, BufferIterator::getNext(), BufferNode::getPCDataRepresentation(), READ_UP_TO_CLOSE_CONTEXT, and Value::setStrVal().
void VarExpression::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.
Reimplemented in VarStepExpression.
Definition at line 98 of file varexpression.cpp.
References bit.
bool VarExpression::isSingleValued | ( | ) | [inline, virtual] |
Returns if the result/iteration of the operand is a single value.
Returns if the result/iteration of the operand is a single value, e.g a AggregateFunctExpression returns a single value whereas a VarStepExpression may return more than one value.
bool | if the result/iteration is a single value, false otherwise. |
Implements OperandExpression.
Reimplemented in VarStepExpression.
Definition at line 145 of file varexpression.h.
void VarExpression::prepareOperand | ( | OutputStream & | eos, | |
Environment * | env, | |||
unsigned | modus | |||
) | [virtual] |
Initializes the operand if necessary.
Initializes the operand if necessary.
[in] | eos | Pointer to a OutputStream object. |
[in] | env | Pointer to a Environment object. |
[in] | modus | Evaluation modus. |
void |
Implements OperandExpression.
Reimplemented in VarStepExpression.
Definition at line 136 of file varexpression.cpp.
References bit, Environment::getNodeBinding(), and BufferIterator::init().
void VarExpression::print | ( | OutputStream & | dos | ) | const [virtual] |
Prints the expression.
Prints the expression.
[in] | dos | Pointer to a OutputStream object. |
void |
Implements Expression.
Reimplemented in VarStepExpression.
Definition at line 94 of file varexpression.cpp.
References VarName::getInstance(), and VarName::getVarname().
void VarExpression::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 79 of file varexpression.cpp.
Referenced by VarstepCondExpression::replaceVarId(), SignOffExpression::replaceVarId(), ForExpression::replaceVarId(), ExistsCondExpression::replaceVarId(), EmptyCondExpression::replaceVarId(), and AggregateFunctExpression::replaceVarId().
void VarExpression::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 67 of file varexpression.cpp.
Referenced by VarstepCondExpression::scopeCheck(), SignOffExpression::scopeCheck(), ForExpression::scopeCheck(), ExistsCondExpression::scopeCheck(), EmptyCondExpression::scopeCheck(), and AggregateFunctExpression::scopeCheck().
void VarExpression::setId | ( | unsigned | _id | ) | [inline] |
Sets a new (numeric) value for a variable.
Sets a new (numeric) value for a variable, i.e. sets a new (numeric) value for the member variable.
[in] | _id | New (numeric) value for a variable. |
void |
Definition at line 131 of file varexpression.h.
Referenced by clone(), Role::getSignOffExpression(), ForExpression::scopeCheck(), and SignOffExpression::SignOffExpression().
void VarExpression::unprepareOperand | ( | ) | [virtual] |
Resets the operand if necessary.
Resets the operand if necessary.
void |
Implements OperandExpression.
Reimplemented in VarStepExpression.
Definition at line 141 of file varexpression.cpp.
References bit, and BufferIterator::reset().
BufferIterator * VarExpression::bit [private] |
The initialized BufferIterator for this variable.
The initialized BufferIterator for this variable after calling method init(). This member variable is NULL
on creation of object but should not be NULL
anymore after method init() has been executed.
Reimplemented in VarStepExpression.
Definition at line 179 of file varexpression.h.
Referenced by eval(), getNextValue(), init(), prepareOperand(), unprepareOperand(), and ~VarExpression().
unsigned VarExpression::id [protected] |
The entered variable.
The entered variable, which is the (first) argument of the constructor and internally represented by a number.
Definition at line 170 of file varexpression.h.
Referenced by VarStepExpression::extractDependencies(), extractDependencies(), and getId().