| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #ifndef OM_HGUARD_FLINT_BTREEBASE_H |
|---|
| 23 | #define OM_HGUARD_FLINT_BTREEBASE_H |
|---|
| 24 | |
|---|
| 25 | #include <string> |
|---|
| 26 | |
|---|
| 27 | #include <xapian/visibility.h> |
|---|
| 28 | |
|---|
| 29 | #include "flint_types.h" |
|---|
| 30 | #include "flint_btreeutil.h" |
|---|
| 31 | |
|---|
| 32 | class XAPIAN_VISIBILITY_DEFAULT FlintTable_base { |
|---|
| 33 | public: |
|---|
| 34 | |
|---|
| 35 | FlintTable_base(); |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | FlintTable_base(const FlintTable_base &other); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | ~FlintTable_base(); |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | bool read(const std::string &name, char ch, std::string &err_msg); |
|---|
| 54 | |
|---|
| 55 | uint4 get_revision() const { return revision; } |
|---|
| 56 | uint4 get_block_size() const { return block_size; } |
|---|
| 57 | uint4 get_root() const { return root; } |
|---|
| 58 | uint4 get_level() const { return level; } |
|---|
| 59 | uint4 get_bit_map_size() const { return bit_map_size; } |
|---|
| 60 | uint4 get_item_count() const { return item_count; } |
|---|
| 61 | uint4 get_last_block() const { return last_block; } |
|---|
| 62 | bool get_have_fakeroot() const { return have_fakeroot; } |
|---|
| 63 | bool get_sequential() const { return sequential; } |
|---|
| 64 | |
|---|
| 65 | void set_revision(uint4 revision_) { |
|---|
| 66 | revision = revision_; |
|---|
| 67 | } |
|---|
| 68 | void set_block_size(uint4 block_size_) { |
|---|
| 69 | block_size = block_size_; |
|---|
| 70 | } |
|---|
| 71 | void set_root(uint4 root_) { |
|---|
| 72 | root = root_; |
|---|
| 73 | } |
|---|
| 74 | void set_level(uint4 level_) { |
|---|
| 75 | level = level_; |
|---|
| 76 | } |
|---|
| 77 | void set_item_count(uint4 item_count_) { |
|---|
| 78 | item_count = item_count_; |
|---|
| 79 | } |
|---|
| 80 | void set_have_fakeroot(bool have_fakeroot_) { |
|---|
| 81 | have_fakeroot = have_fakeroot_; |
|---|
| 82 | } |
|---|
| 83 | void set_sequential(bool sequential_) { |
|---|
| 84 | sequential = sequential_; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | void write_to_file(const std::string &filename); |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | bool block_free_at_start(uint4 n) const; |
|---|
| 95 | |
|---|
| 96 | void free_block(uint4 n); |
|---|
| 97 | |
|---|
| 98 | uint4 next_free_block(); |
|---|
| 99 | |
|---|
| 100 | bool block_free_now(uint4 n); |
|---|
| 101 | |
|---|
| 102 | void calculate_last_block(); |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | void clear_bit_map(); |
|---|
| 106 | |
|---|
| 107 | void commit(); |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | bool is_empty() const; |
|---|
| 111 | |
|---|
| 112 | void swap(FlintTable_base &other); |
|---|
| 113 | |
|---|
| 114 | private: |
|---|
| 115 | |
|---|
| 116 | void operator=(const FlintTable_base &other); |
|---|
| 117 | |
|---|
| 118 | void extend_bit_map(); |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | bool do_unpack_uint(const char **start, const char *end, |
|---|
| 122 | uint4 *dest, std::string &err_msg, |
|---|
| 123 | const std::string &basename, |
|---|
| 124 | const char *varname); |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | uint4 revision; |
|---|
| 128 | uint4 block_size; |
|---|
| 129 | uint4 root; |
|---|
| 130 | uint4 level; |
|---|
| 131 | uint4 bit_map_size; |
|---|
| 132 | uint4 item_count; |
|---|
| 133 | uint4 last_block; |
|---|
| 134 | bool have_fakeroot; |
|---|
| 135 | bool sequential; |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | uint4 bit_map_low; |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | byte *bit_map0; |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | byte *bit_map; |
|---|
| 148 | }; |
|---|
| 149 | |
|---|
| 150 | #endif |
|---|