00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #ifndef BUFFERITERATOR_H 00036 #define BUFFERITERATOR_H 00037 00038 #include <vector> 00039 #include <stack> 00040 #include "buffernode.h" 00041 #include "streampreprocessor.h" 00042 #include "tagnode.h" 00043 #include "pathstepattributeposition.h" 00044 #include "runtimeexception.h" 00045 00053 #define READ_UP_TO_CLOSE_BASE 0 00054 00063 #define READ_UP_TO_CLOSE_CONTEXT 1 00064 00073 #define READ_UP_TO_CLOSE_NONE 2 00074 00082 #define LOCK_CONTEXT_NO_CLEAR 10 00083 00092 #define LOCK_CONTEXT_LAST_CLEAR 11 00093 00101 #define LOCK_CONTEXT_ALWAYS_CLEAR 12 00102 00111 #define LOCK_NONE_NO_CLEAR 13 00112 00119 #define BIT_DEBUG_MODE_FULL 0 00120 00127 #define BIT_DEBUG_MODE_PARTIAL 1 00128 00136 #define BIT_DEBUG_MODE_SIMPLE 2 00137 00152 class BufferIterator { 00153 00154 public: 00160 BufferIterator(BufferNode * _base, PathExpression * _path); 00161 00165 virtual ~ BufferIterator(); 00166 00174 void init(BufferNode * _base); 00175 00185 void debugPrint(OutputStream & dos, unsigned debug_mode = 00186 BIT_DEBUG_MODE_SIMPLE); 00187 00203 BufferNode *getNext(unsigned read_up_to_closing = READ_UP_TO_CLOSE_NONE, 00204 unsigned lock_node = LOCK_NONE_NO_CLEAR); 00205 00213 void reset(); 00214 00223 void clear(); 00224 00225 private: 00235 BufferNode * isSatisfyingPath(BufferNode * nnode); 00236 00246 bool isMatchingNodeTestAndPredicates(BufferNode * nnode, unsigned ps_idx); 00247 00253 BufferNode *getPrevPSNode(); 00254 00262 void unsignPSNode(BufferNode * nnode); 00263 00269 BufferNode *base; 00270 00276 BufferNode *cur; 00277 00283 BufferNode *cur_old; 00284 00291 bool cur_locked; 00292 00299 PathExpression *path; 00300 00305 StreamPreProcessor *spp; 00306 00311 vector < BufferNode * >ps_context; 00312 00319 vector < unsigned >ps_context_position; 00320 00330 vector < bool > ps_skip_subtree; 00331 00338 vector < bool > ps_attribute; 00339 00346 vector < unsigned >ps_attribute_position; 00347 00354 vector < bool > ps_back_track; 00355 00362 unsigned ps_index; 00363 }; 00364 00365 #endif // BUFFERITERATOR_H