|
50 | 50 |
|
51 | 51 | #define UCDB_VERSION_MAJOR 0 |
52 | 52 | #define UCDB_VERSION_MINOR 5 |
53 | | -#define UCDB_VERSION_PATCH 3 |
| 53 | +#define UCDB_VERSION_PATCH 4 |
54 | 54 |
|
55 | 55 | #ifdef TRACE_CDB |
56 | 56 | #ifndef TracePrinter |
@@ -85,7 +85,15 @@ template <class TFileSystem, class TFile> |
85 | 85 | class uCDB |
86 | 86 | { |
87 | 87 | public: |
88 | | - uCDB(TFileSystem& fs); |
| 88 | + |
| 89 | + /** |
| 90 | + uCDB constructor |
| 91 | + */ |
| 92 | + uCDB(TFileSystem& fs) : |
| 93 | + fs_(fs), |
| 94 | + slotsToScan_(0), |
| 95 | + nextSlotPos_(0), |
| 96 | + state_(CDB_CLOSED) {} |
89 | 97 |
|
90 | 98 | /** |
91 | 99 | Open CDB file |
@@ -119,12 +127,22 @@ class uCDB |
119 | 127 | /** |
120 | 128 | Total records number in CDB |
121 | 129 | */ |
122 | | - unsigned long recordsNumber() const; |
| 130 | + unsigned long recordsNumber() const { |
| 131 | + switch (state_) { |
| 132 | + case CDB_CLOSED: |
| 133 | + case CDB_ERROR: |
| 134 | + return 0; |
| 135 | + default: |
| 136 | + return (slotsNum_ >> 1); |
| 137 | + } |
| 138 | + } |
123 | 139 |
|
124 | 140 | /** |
125 | 141 | The number of `value' bytes available for reading |
126 | 142 | */ |
127 | | - unsigned long valueAvailable() const; |
| 143 | + unsigned long valueAvailable() const { |
| 144 | + return (state_ == KEY_FOUND ? valueBytesAvail_ : 0); |
| 145 | + } |
128 | 146 |
|
129 | 147 | /** |
130 | 148 | Close CDB |
@@ -185,12 +203,6 @@ static unsigned long unpack(const byte *buff); |
185 | 203 | template <class TFile> |
186 | 204 | static bool readDescriptor(TFile& file, byte *buff, unsigned long pos); |
187 | 205 |
|
188 | | -template <class TFileSystem, class TFile> |
189 | | -uCDB<TFileSystem, TFile>::uCDB(TFileSystem& fs) : fs_(fs) { |
190 | | - zero(); |
191 | | - state_ = CDB_CLOSED; |
192 | | -} |
193 | | - |
194 | 206 | template <class TFileSystem, class TFile> |
195 | 207 | cdbResult uCDB<TFileSystem, TFile>::open(const char *fileName, unsigned long (*userHashFunc)(const void *key, unsigned long keyLen)) { |
196 | 208 | unsigned long htPos; |
@@ -405,23 +417,6 @@ int uCDB<TFileSystem, TFile>::readValue(void *buff, unsigned int byteNum) { |
405 | 417 | return -1; |
406 | 418 | } |
407 | 419 |
|
408 | | -template <class TFileSystem, class TFile> |
409 | | -unsigned long uCDB<TFileSystem, TFile>::recordsNumber() const { |
410 | | - // Check CDB state |
411 | | - switch (state_) { |
412 | | - case CDB_CLOSED: |
413 | | - case CDB_ERROR: |
414 | | - return 0; |
415 | | - default: |
416 | | - return (slotsNum_ >> 1); |
417 | | - } |
418 | | -} |
419 | | - |
420 | | -template <class TFileSystem, class TFile> |
421 | | -unsigned long uCDB<TFileSystem, TFile>::valueAvailable() const { |
422 | | - return ((state_ == KEY_FOUND) ? valueBytesAvail_ : 0); |
423 | | -} |
424 | | - |
425 | 420 | template <class TFileSystem, class TFile> |
426 | 421 | cdbResult uCDB<TFileSystem, TFile>::close() { |
427 | 422 | zero(); |
|
0 commit comments