backends/flint/flint_cursor.h

Go to the documentation of this file.
00001 /* bcursor.h: Interface to Btree cursors
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002,2003,2004,2006,2007 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_FLINT_CURSOR_H
00023 #define OM_HGUARD_FLINT_CURSOR_H
00024 
00025 #include <xapian/visibility.h>
00026 
00027 #include "flint_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 FlintTable;
00063 
00067 class XAPIAN_VISIBILITY_DEFAULT FlintCursor {
00068     private:
00070         FlintCursor(const FlintCursor &);
00071 
00073         FlintCursor & operator=(const FlintCursor &);
00074 
00080         bool is_positioned;
00081 
00084         bool is_after_end;
00085 
00087         enum { UNREAD, UNCOMPRESSED, COMPRESSED } tag_status;
00088 
00090         FlintTable * B;
00091 
00093         Cursor_ * C;
00094 
00096         int level;
00097 
00117         void get_key(string * key) const;
00118 
00119     public:
00131         FlintCursor(FlintTable *B);
00132 
00134         ~FlintCursor();
00135 
00138         string current_key;
00139 
00143         string current_tag;
00144 
00157         bool read_tag(bool keep_compressed = false);
00158 
00173         bool next();
00174  
00180         bool prev();
00181 
00204         bool find_entry(const string &key);
00205 
00207         void find_entry_lt(const string &key) {
00208             if (find_entry(key)) prev();
00209         }
00210 
00216         bool find_entry_ge(const string &key);
00217 
00220         void to_end() { is_after_end = true; }
00221 
00227         bool after_end() const { return is_after_end; }
00228 
00234         bool del();
00235 
00237         FlintTable * get_table() const { return B; }
00238 };
00239 
00240 #endif /* OM_HGUARD_FLINT_CURSOR_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.