VarExpression Class Reference

Represents an XQuery variable. More...

#include <varexpression.h>

Inheritance diagram for VarExpression:

Inheritance graph
[legend]
Collaboration diagram for VarExpression:

Collaboration graph
[legend]

List of all members.

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.
VarExpressionclone ()
 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 ValuegetNextValue ()

Protected Attributes

unsigned id
 The entered variable.

Private Attributes

BufferIteratorbit
 The initialized BufferIterator for this variable.


Detailed Description

Represents an XQuery 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.

Note:
Variables are internally represented by numbers!

To get a variable name from a numeric value a look up in VarName is needed!

Author:
Michael Schmidt

Gunnar Jehl

Version:
2.1
License:
Software License Agreement (BSD License)

Definition at line 53 of file varexpression.h.


Constructor & Destructor Documentation

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).

Parameters:
[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).

Parameters:
[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.

Parameters:
[in] _type EXP_TYPE.
[in] _id Numeric value of a variable.

Definition at line 56 of file varexpression.cpp.

VarExpression::~VarExpression (  )  [virtual]

Destructor.

Definition at line 63 of file varexpression.cpp.

References bit.


Member Function Documentation

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.

Return values:
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.

Parameters:
[in] eos Pointer to a OutputStream object.
[in] env Pointer to an Environment object.
[in] modus The query evaluation mode.
Exceptions:
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.

Parameters:
[in,out] depset Pointer to a vector containing Pointer to DependencySet objects.
Return values:
void 

Reimplemented from Expression.

Reimplemented in VarStepExpression.

Definition at line 85 of file varexpression.cpp.

References id.

unsigned VarExpression::getId (  )  [inline]

Value * VarExpression::getNextValue (  )  [virtual]

Returns the next value of the operand.

Returns the next value of the operand for iteration.

Return values:
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.

Parameters:
[in] root Pointer to a BufferNode object.
Return values:
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.

Return values:
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.

Parameters:
[in] eos Pointer to a OutputStream object.
[in] env Pointer to a Environment object.
[in] modus Evaluation modus.
Return values:
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.

Parameters:
[in] dos Pointer to a OutputStream object.
Return values:
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().

Parameters:
[in] old_id Old variable ID.
[in] new_id New variable ID, which should be introduced instead.
Return values:
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.

Parameters:
[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.
Return values:
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.

Parameters:
[in] _id New (numeric) value for a variable.
Return values:
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.

Return values:
void 

Implements OperandExpression.

Reimplemented in VarStepExpression.

Definition at line 141 of file varexpression.cpp.

References bit, and BufferIterator::reset().


Member Data Documentation

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().


Generated on Sun May 24 20:20:31 2009 for G(arbage) C(ollected) X(Query) Engine by  doxygen 1.5.9