#include <bufferiterator.h>
Public Member Functions | |
BufferIterator (BufferNode *_base, PathExpression *_path) | |
Constructor. | |
virtual | ~BufferIterator () |
void | init (BufferNode *_base) |
Inits the BufferIterator. | |
void | debugPrint (OutputStream &dos, unsigned debug_mode=BIT_DEBUG_MODE_SIMPLE) |
Prints all stored information. | |
BufferNode * | getNext (unsigned read_up_to_closing=READ_UP_TO_CLOSE_NONE, unsigned lock_node=LOCK_NONE_NO_CLEAR) |
Returns the next context node for the entered path. | |
void | reset () |
Resets this BufferIterator object. | |
void | clear () |
Resets this BufferIterator object. | |
Private Member Functions | |
BufferNode * | isSatisfyingPath (BufferNode *nnode) |
Checks if a node, which is the argument of this method, is satisyfying the entered path. | |
bool | isMatchingNodeTestAndPredicates (BufferNode *nnode, unsigned ps_idx) |
Checks if a node, which is the first argument of this method, matches the given path step index, which is the second argument of this method. | |
BufferNode * | getPrevPSNode () |
Returns the assigned node of the previous processed path step. | |
void | unsignPSNode (BufferNode *nnode) |
Invoked method on upward traversal of the XML tree. | |
Private Attributes | |
BufferNode * | base |
The entered BufferNode. | |
BufferNode * | cur |
The stored returned node after each invocation of method getNext(). | |
BufferNode * | cur_old |
The stored previous returned node after each invocation of method getNext(). | |
bool | cur_locked |
The indicator if a returned BufferNode was locked. | |
PathExpression * | path |
The entered PathExpression. | |
StreamPreProcessor * | spp |
vector< BufferNode * > | ps_context |
vector< unsigned > | ps_context_position |
The stored number of assignments, which has been made up to now, of BufferNode for each path step of the entered PathExpression. | |
vector< bool > | ps_skip_subtree |
The indicator for each path step of the entered PathExpression if subtrees could be skipped. | |
vector< bool > | ps_attribute |
vector< unsigned > | ps_attribute_position |
vector< bool > | ps_back_track |
unsigned | ps_index |
The current processed path step (index). |
Represents iterator over nodes stored in buffer for a given path, which takes therefore a BufferNode to which a VarExpression (variable), e.g. $x
, $z
or $root
, is currently bound and a PathExpression, e.g. /bib//book
or /bib/book/title
, as arguments.
[position
()=n]
for any path step and in any combination has been implemented and should work (maybe) BUT these two cases have never been tested and therefore there is no warranty that they are really working. Definition at line 152 of file bufferiterator.h.
BufferIterator::BufferIterator | ( | BufferNode * | _base, | |
PathExpression * | _path | |||
) |
Constructor.
Constructor - creating object for a BufferNode and a PathExpression.
[in] | _base | Pointer to a BufferNode object. |
[in] | _path | Pointer to a PathExpression object. |
Definition at line 37 of file bufferiterator.cpp.
References base, cur, PathStepExpression::getAttribute(), PathStepExpression::getAxisType(), PathExpression::getPathSize(), PathExpression::getPathStepAfterTextNodeTest(), PathExpression::getPathStepAt(), PathStepAttribute::getType(), PathStepExpression::hasAttribute(), PathExpression::hasInnerTextNodeTest(), PathExpression::hasPreviousDescendantOrDosUpTo(), PathStepExpression::isDosNodeStep(), path, ps_attribute, ps_attribute_position, ps_back_track, ps_context, ps_context_position, ps_skip_subtree, BufferNode::type, and TYPE_PCDATA.
BufferIterator::~BufferIterator | ( | ) | [virtual] |
Destructor.
Definition at line 136 of file bufferiterator.cpp.
void BufferIterator::clear | ( | ) |
Resets this BufferIterator object.
Resets this BufferIterator object, i.e. resets most of the member variables to avoid time-consuming setting of member variables by creating a new object. This method is similar to method reset() BUT does nothing at that time, i.e. is not implemented, and is currently called after every evaluation step of an Expression.
void |
Definition at line 456 of file bufferiterator.cpp.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), VarStepExpression::eval(), VarExpression::eval(), SignOffExpression::eval(), and ForExpression::eval().
void BufferIterator::debugPrint | ( | OutputStream & | dos, | |
unsigned | debug_mode = BIT_DEBUG_MODE_SIMPLE | |||
) |
Prints all stored information.
Prints all stored information, which are the extracted informations of the entered PathExpression and stored nodes.
[in] | dos | Pointer to a OutputStream object. |
[in] | debug_mode | Indicates the grade of information output (see also predefined variables BIT_DEBUG_MODE_FULL, BIT_DEBUG_MODE_PARTIAL, BIT_DEBUG_MODE_SIMPLE). |
void |
Definition at line 158 of file bufferiterator.cpp.
References base, BIT_DEBUG_MODE_FULL, BIT_DEBUG_MODE_PARTIAL, cur, cur_locked, cur_old, BufferNode::debugPrint(), PathExpression::getPathStepAt(), PathExpression::getPathSteps(), BufferNode::isRoot(), NEWLINE, path, BufferNode::printNoSubnodes(), ps_attribute, ps_attribute_position, ps_back_track, ps_context, ps_context_position, ps_index, ps_skip_subtree, BufferNode::type, and TYPE_TAG.
BufferNode * BufferIterator::getNext | ( | unsigned | read_up_to_closing = READ_UP_TO_CLOSE_NONE , |
|
unsigned | lock_node = LOCK_NONE_NO_CLEAR | |||
) |
Returns the next context node for the entered path.
Returns the next context node for the entered path, which is located from the entered base BufferNode after execution of the PathExpression. Needed or not up to now available BufferNode in the Buffer are requested from the StreamPreProcessor.
[in] | read_up_to_closing | Forces the StreamPreProcessor to read the input stream up to the closing tag of a specific BufferNode (see also predefined variables READ_UP_TO_CLOSE_BASE, READ_UP_TO_CLOSE_CONTEXT, READ_UP_TO_CLOSE_NONE). |
[in] | lock_node | Locks, unlocks and invokes garbage collection on a BufferNode by invoking method lock(), unlock() and clear() on a BufferNode (see also predefined variables LOCK_CONTEXT_NO_CLEAR, LOCK_CONTEXT_LAST_CLEAR, LOCK_CONTEXT_ALWAYS_CLEAR, LOCK_NONE_NO_CLEAR). |
BufferNode | Pointer to a BufferNode object. |
Definition at line 271 of file bufferiterator.cpp.
References base, BufferNode::clear(), cur, cur_locked, cur_old, BufferNode::isClosed(), BufferNode::isLocked(), isSatisfyingPath(), BufferNode::lock(), LOCK_CONTEXT_ALWAYS_CLEAR, LOCK_CONTEXT_NO_CLEAR, LOCK_NONE_NO_CLEAR, BufferNode::node, BufferNode::parent, path, ps_context, ps_context_position, ps_index, BufferNode::r_sibling, READ_UP_TO_CLOSE_BASE, READ_UP_TO_CLOSE_CONTEXT, StreamPreProcessor::readNext(), spp, BufferNode::type, TYPE_TAG, BufferNode::unlock(), and unsignPSNode().
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), VarStepExpression::eval(), VarExpression::eval(), SignOffExpression::eval(), ForExpression::eval(), ExistsCondExpression::evalCond(), VarStepExpression::getNextValue(), and VarExpression::getNextValue().
BufferNode * BufferIterator::getPrevPSNode | ( | ) | [private] |
Returns the assigned node of the previous processed path step.
Returns the assigned node of the previous processed path step.
BufferNode | Pointer to a BufferNode object. |
Definition at line 1021 of file bufferiterator.cpp.
References base, ps_context, and ps_index.
Referenced by isSatisfyingPath().
void BufferIterator::init | ( | BufferNode * | _base | ) |
Inits the BufferIterator.
Inits the BufferIterator, i.e. partially resetting stored informations and setting new iteration base (variable).
[in] | _base | Pointer to a BufferNode object (new variable for iteration base). |
void |
Definition at line 139 of file bufferiterator.cpp.
References base, cur, cur_locked, cur_old, PathExpression::getPathStepAfterTextNodeTest(), PathExpression::getPathStepAt(), PathExpression::hasInnerTextNodeTest(), PathStepExpression::isDosNodeStep(), path, ps_index, BufferNode::type, and TYPE_PCDATA.
Referenced by AggregateFunctVarSampExpression::calculateValue(), AggregateFunctVarPopExpression::calculateValue(), AggregateFunctSumExpression::calculateValue(), AggregateFunctStdDevSampExpression::calculateValue(), AggregateFunctStdDevPopExpression::calculateValue(), AggregateFunctMinExpression::calculateValue(), AggregateFunctMedianExpression::calculateValue(), AggregateFunctMaxExpression::calculateValue(), AggregateFunctCountExpression::calculateValue(), AggregateFunctAvgExpression::calculateValue(), VarStepExpression::eval(), VarExpression::eval(), SignOffExpression::eval(), ForExpression::eval(), ExistsCondExpression::evalCond(), VarStepExpression::prepareOperand(), and VarExpression::prepareOperand().
bool BufferIterator::isMatchingNodeTestAndPredicates | ( | BufferNode * | nnode, | |
unsigned | ps_idx | |||
) | [private] |
Checks if a node, which is the first argument of this method, matches the given path step index, which is the second argument of this method.
Checks if a node, which is the first argument of this method, matches the given path step index, which is the second argument of this method.
[in] | nnode | The BufferNode, which should to be checked for matching the path step index. |
[in] | ps_idx | The path step index, which should be checked for matching the BufferNode. |
bool | true if the node matches the given path step (index), false otherwise. |
Definition at line 983 of file bufferiterator.cpp.
References PathStepExpression::getNodeTestType(), PathExpression::getPathStepAt(), BufferNode::node, path, ps_attribute, ps_attribute_position, ps_context_position, BufferNode::type, TYPE_PCDATA, and TYPE_TAG.
Referenced by isSatisfyingPath().
BufferNode * BufferIterator::isSatisfyingPath | ( | BufferNode * | nnode | ) | [private] |
Checks if a node, which is the argument of this method, is satisyfying the entered path.
Checks if a node, which is the argument of this method, is satisyfying the entered path.
[in] | nnode | Pointer to a BufferNode object, which is checked if it satisfy the entered PathExpression. |
BufferNode | Pointer to a BufferNode object, which is the next node (if a subtree could be skipped) beeing processed by the left-to-right depth-first traversal or NULL if the entered PathExpression is fully satisfied. |
Definition at line 460 of file bufferiterator.cpp.
References cur, cur_old, PathStepExpression::getAxisType(), PathExpression::getPathSize(), PathExpression::getPathStepAt(), getPrevPSNode(), BufferNode::isClosed(), isMatchingNodeTestAndPredicates(), BufferNode::isRoot(), BufferNode::node, BufferNode::parent, path, ps_back_track, ps_context, ps_context_position, ps_index, ps_skip_subtree, BufferNode::r_sibling, StreamPreProcessor::readNext(), spp, BufferNode::type, and TYPE_TAG.
Referenced by getNext().
void BufferIterator::reset | ( | ) |
Resets this BufferIterator object.
Resets this BufferIterator object, i.e. resets most of the member variables to avoid time-consuming setting of member variables by creating a new object. This method is needed because of the nested loop joins in method evalCond() of CondOperandExpression.
void |
Definition at line 432 of file bufferiterator.cpp.
References base, cur, cur_locked, cur_old, PathExpression::getPathSize(), PathExpression::getPathStepAfterTextNodeTest(), PathExpression::getPathStepAt(), PathExpression::hasInnerTextNodeTest(), PathStepExpression::isDosNodeStep(), path, ps_context, ps_context_position, ps_index, BufferNode::type, and TYPE_PCDATA.
Referenced by ExistsCondExpression::evalCond(), VarStepExpression::unprepareOperand(), and VarExpression::unprepareOperand().
void BufferIterator::unsignPSNode | ( | BufferNode * | nnode | ) | [private] |
Invoked method on upward traversal of the XML tree.
Invoked method on upward traversal of the XML tree, which unsigns/removes stored nodes and decrement the current processed path step index (member variable ps_index).
[in] | nnode | The BufferNode, which is processed while upward traversal of the XML tree. |
void |
Definition at line 1025 of file bufferiterator.cpp.
References ps_context, ps_context_position, and ps_index.
Referenced by getNext().
BufferNode * BufferIterator::base [private] |
The entered BufferNode.
The entered BufferNode, which is the first argument of the constructor and is the BufferNode of the current binding of the VarExpression of the entered PathExpression.
Definition at line 269 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), getNext(), getPrevPSNode(), init(), and reset().
BufferNode * BufferIterator::cur [private] |
The stored returned node after each invocation of method getNext().
The stored returned node after each invocation of method getNext(), which is the (current) context node of the entered PathExpression.
Definition at line 276 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), getNext(), init(), isSatisfyingPath(), and reset().
bool BufferIterator::cur_locked [private] |
The indicator if a returned BufferNode was locked.
The indicator if a returned BufferNode was locked, which is the case, i.e. this member variable is true
, if it was locked from this object and this member variable is false
, if it was locked by another (BufferIterator) object.
Definition at line 291 of file bufferiterator.h.
Referenced by debugPrint(), getNext(), init(), and reset().
BufferNode * BufferIterator::cur_old [private] |
The stored previous returned node after each invocation of method getNext().
The stored previous returned node after each invocation of method getNext(), which was the (previous returned) context node of the entered PathExpression.
Definition at line 283 of file bufferiterator.h.
Referenced by debugPrint(), getNext(), init(), isSatisfyingPath(), and reset().
PathExpression * BufferIterator::path [private] |
The entered PathExpression.
The entered PathExpression, which is the second argument of the constructor and determines iteration over the Buffer, beginning from the BufferNode of the VarExpression.
Definition at line 299 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), getNext(), init(), isMatchingNodeTestAndPredicates(), isSatisfyingPath(), and reset().
vector< bool > BufferIterator::ps_attribute [private] |
The indicator for each path step of the entered PathExpression if a path step has a PathStepAttribute.
Definition at line 338 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), and isMatchingNodeTestAndPredicates().
vector< unsigned > BufferIterator::ps_attribute_position [private] |
The stored number of the PathStepAttributePosition for each path step of the entered PathExpression, which needs to be satisfied for matching a path step.
Definition at line 346 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), and isMatchingNodeTestAndPredicates().
vector< bool > BufferIterator::ps_back_track [private] |
The indicator for each path step of the entered PathExpression if it is needed to backtrack one or more path steps to find all matching nodes.
Definition at line 354 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), and isSatisfyingPath().
vector< BufferNode * > BufferIterator::ps_context [private] |
The stored BufferNode for each path step of the entered PathExpression.
Definition at line 311 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), getNext(), getPrevPSNode(), isSatisfyingPath(), reset(), and unsignPSNode().
vector< unsigned > BufferIterator::ps_context_position [private] |
The stored number of assignments, which has been made up to now, of BufferNode for each path step of the entered PathExpression.
The stored number of assignments, which has been made up to now, to BufferNode for each path step of the entered PathExpression.
Definition at line 319 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), getNext(), isMatchingNodeTestAndPredicates(), isSatisfyingPath(), reset(), and unsignPSNode().
unsigned BufferIterator::ps_index [private] |
The current processed path step (index).
The current processed path step (index), which is on a find of a matching node for a path step incremented and on upward traversal of the XML tree decremented by method unsignPSNode().
Definition at line 362 of file bufferiterator.h.
Referenced by debugPrint(), getNext(), getPrevPSNode(), init(), isSatisfyingPath(), reset(), and unsignPSNode().
vector< bool > BufferIterator::ps_skip_subtree [private] |
The indicator for each path step of the entered PathExpression if subtrees could be skipped.
The indicator for each path step of the entered PathExpression if subtrees could be skipped. If the entry for a path step is true
it is possible to skip/jump immediately to the next right sibling and avoid processing whole subtrees, false
otherwise, will process subtrees searching for a matching node for the current processed path step.
Definition at line 330 of file bufferiterator.h.
Referenced by BufferIterator(), debugPrint(), and isSatisfyingPath().
StreamPreProcessor * BufferIterator::spp [private] |
The StreamPreProcessor object to read the input stream if new nodes are required.
Definition at line 305 of file bufferiterator.h.
Referenced by getNext(), and isSatisfyingPath().