00001 /* bcursor.h: Interface to Btree cursors 00002 * 00003 * Copyright 1999,2000,2001 BrightStation PLC 00004 * Copyright 2002,2003,2004,2006 Olly Betts 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License as 00008 * published by the Free Software Foundation; either version 2 of the 00009 * License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00019 * USA 00020 */ 00021 00022 #ifndef OM_HGUARD_BCURSOR_H 00023 #define OM_HGUARD_BCURSOR_H 00024 00025 #include <xapian/visibility.h> 00026 00027 #include "quartz_types.h" 00028 00029 #include <string> 00030 using std::string; 00031 00032 #define BLK_UNUSED uint4(-1) 00033 00034 class Cursor { 00035 private: 00036 // Prevent copying 00037 Cursor(const Cursor &); 00038 Cursor & operator=(const Cursor &); 00039 00040 public: 00042 Cursor() : p(0), c(-1), n(BLK_UNUSED), rewrite(false) 00043 {} 00044 00046 byte * p; 00048 int c; 00057 uint4 n; 00059 bool rewrite; 00060 }; 00061 00062 class Btree; 00063 00067 class XAPIAN_VISIBILITY_DEFAULT Bcursor { 00068 private: 00070 Bcursor(const Bcursor &); 00071 00073 Bcursor & operator=(const Bcursor &); 00074 00080 bool is_positioned; 00081 00084 bool is_after_end; 00085 00088 bool have_read_tag; 00089 00091 Btree * B; 00092 00094 Cursor * C; 00095 00097 int level; 00098 00119 bool get_key(string * key) const; 00120 00121 public: 00133 Bcursor(Btree *B); 00134 00136 ~Bcursor(); 00137 00140 string current_key; 00141 00145 string current_tag; 00146 00152 void read_tag(); 00153 00168 bool next(); 00169 00175 bool prev(); 00176 00201 bool find_entry(const string &key); 00202 00208 bool after_end() { return is_after_end; } 00209 00213 void del(); 00214 }; 00215 00216 #endif /* OM_HGUARD_BCURSOR_H */