00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OM_HGUARD_FLINT_BTREEBASE_H
00023 #define OM_HGUARD_FLINT_BTREEBASE_H
00024
00025 #include <string>
00026
00027 #include <xapian/visibility.h>
00028
00029 #include "flint_types.h"
00030 #include "flint_btreeutil.h"
00031
00032 class XAPIAN_VISIBILITY_DEFAULT FlintTable_base {
00033 public:
00035 FlintTable_base();
00036
00038 FlintTable_base(const FlintTable_base &other);
00039
00041 ~FlintTable_base();
00042
00053 bool read(const std::string &name, char ch, std::string &err_msg);
00054
00055 uint4 get_revision() const { return revision; }
00056 uint4 get_block_size() const { return block_size; }
00057 uint4 get_root() const { return root; }
00058 uint4 get_level() const { return level; }
00059 uint4 get_bit_map_size() const { return bit_map_size; }
00060 uint4 get_item_count() const { return item_count; }
00061 uint4 get_last_block() const { return last_block; }
00062 bool get_have_fakeroot() const { return have_fakeroot; }
00063 bool get_sequential() const { return sequential; }
00064
00065 void set_revision(uint4 revision_) {
00066 revision = revision_;
00067 }
00068 void set_block_size(uint4 block_size_) {
00069 block_size = block_size_;
00070 }
00071 void set_root(uint4 root_) {
00072 root = root_;
00073 }
00074 void set_level(uint4 level_) {
00075 level = level_;
00076 }
00077 void set_item_count(uint4 item_count_) {
00078 item_count = item_count_;
00079 }
00080 void set_have_fakeroot(bool have_fakeroot_) {
00081 have_fakeroot = have_fakeroot_;
00082 }
00083 void set_sequential(bool sequential_) {
00084 sequential = sequential_;
00085 }
00086
00088 void write_to_file(const std::string &filename);
00089
00090
00094 bool block_free_at_start(uint4 n) const;
00095
00096 void free_block(uint4 n);
00097
00098 uint4 next_free_block();
00099
00100 bool block_free_now(uint4 n);
00101
00102 void calculate_last_block();
00103
00104
00105 void clear_bit_map();
00106
00107 void commit();
00108
00109
00110 bool is_empty() const;
00111
00112 void swap(FlintTable_base &other);
00113
00114 private:
00116 void operator=(const FlintTable_base &other);
00117
00118 void extend_bit_map();
00119
00121 bool do_unpack_uint(const char **start, const char *end,
00122 uint4 *dest, std::string &err_msg,
00123 const std::string &basename,
00124 const char *varname);
00125
00126
00127 uint4 revision;
00128 uint4 block_size;
00129 uint4 root;
00130 uint4 level;
00131 uint4 bit_map_size;
00132 uint4 item_count;
00133 uint4 last_block;
00134 bool have_fakeroot;
00135 bool sequential;
00136
00137
00140 uint4 bit_map_low;
00141
00144 byte *bit_map0;
00145
00147 byte *bit_map;
00148 };
00149
00150 #endif