Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbindex.h
Go to the documentation of this file.
1/* xbindex.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014, 2018, 2022 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14*/
15
16
17#ifndef __XB_INDEX_H__
18#define __XB_INDEX_H__
19
20#ifdef XB_INDEX_SUPPORT
21
22
23#define XB_ADD_KEY 1
24#define XB_UPD_KEY 2
25#define XB_DEL_KEY 3
26
27namespace xb{
28
29
30
32// structure for index nodes, each node contains information regarding one block
33struct XBDLLEXPORT xbIxNode {
34 xbIxNode *npPrev; // pointer to previous node in chain
35 xbIxNode *npNext; // pointer to next node in chain
36 xbUInt32 iCurKeyNo; // current key number in the node, 0 offset
37 xbUInt32 ulBlockNo; // this block number
38 xbUInt32 ulBufSize; // size of cpBlockData
39 char *cpBlockData; // pointer to memory version of block data stored in file
40};
42
43
45
120class XBDLLEXPORT xbIx : public xbFile {
121 public:
122 xbIx( xbDbf * d );
123 virtual ~xbIx();
124
125 virtual xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt ) = 0;
126 virtual xbInt16 Close();
127 virtual xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag ) = 0;
128 virtual xbInt16 FindKey( void *vpTag, const xbString &sKey, xbInt16 iRetrieveSw );
129 virtual xbInt16 FindKey( void *vpTag, const char * cKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
130 virtual xbInt16 FindKey( void *vpTag, const xbBcd &bcd, xbInt16 iRetrieveSw );
131 virtual xbInt16 FindKey( void *vpTag, const xbDate &dtKey, xbInt16 iRetrieveSw );
132 virtual xbInt16 FindKey( void *vpTag, xbDouble dKey, xbInt16 iRetrieveSw );
133 virtual xbInt16 FindKey( void *vpTag, const void *vKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw ) = 0;
134 virtual void *GetCurTag() const;
135 virtual xbDbf *GetDbf() const;
136
137 virtual xbString &GetKeyExpression( const void *vpTag ) const = 0;
138 virtual xbString &GetKeyFilter( const void *vpTag ) const = 0;
139 virtual char GetKeyType( const void *vpTag ) const = 0;
140 virtual xbBool GetLocked() const;
141
142 virtual xbInt16 GetFirstKey( void *vpTag, xbInt16 iRetrieveSw ) = 0;
143 virtual xbInt16 GetFirstKey( void *vpTag );
144 virtual xbInt16 GetFirstKey();
145
146 virtual xbInt16 GetLastKey( void *vpTag, xbInt16 lRetrieveSw ) = 0;
147 virtual xbInt16 GetLastKey( void *vpTag );
148 virtual xbInt16 GetLastKey();
149
150 virtual xbInt16 GetNextKey( void *vpTag, xbInt16 iRetrieveSw ) = 0;
151 virtual xbInt16 GetNextKey( void *vpTag );
152 virtual xbInt16 GetNextKey();
153
154 virtual xbInt16 GetPrevKey( void *vpTag, xbInt16 iRetrieveSw ) = 0;
155 virtual xbInt16 GetPrevKey( void *vpTag );
156 virtual xbInt16 GetPrevKey();
157
158 virtual void *GetTag( xbInt16 iTagNo ) const = 0;
159 virtual void *GetTag( xbString &sTagName ) const = 0;
160 virtual xbInt16 GetTagCount() const = 0;
161
162 virtual xbString &GetTagName( void *vpTag ) const = 0;
163 virtual const char * GetTagName( void *vpTag, xbInt16 iOpt ) const = 0;
164 virtual void GetTagName( void *vpTag, xbString &sTagName ) {};
165
166 virtual xbBool GetUnique( void *vpTag ) const = 0;
167 virtual xbBool GetSortOrder( void *vpTag ) const = 0;
168
169 virtual xbInt16 Open( const xbString &sFileName );
170 virtual xbInt16 Reindex( void **vpTag ) = 0;
171 virtual xbInt16 SetCurTag( xbInt16 iTagNo ) = 0;
172 virtual xbInt16 SetCurTag( xbString &sTagName ) = 0;
173 virtual void SetCurTag( void * vpCurTag );
174 virtual void SetLocked( xbBool bLocked );
175
176 virtual void TestStub( char *s, void *vpTag ) {};
177
178
179 #ifdef XB_DEBUG_SUPPORT
180 virtual xbInt16 DumpFreeBlocks( xbInt16 iOpt = 0 ) { return XB_NO_ERROR; }
181 virtual xbInt16 DumpHeader( xbInt16 iDestOpt = 0, xbInt16 iFmtOpt = 0 ) = 0;
182 virtual xbInt16 DumpIxForTag( void *vpTag, xbInt16 iOutputOpt ) = 0;
183 virtual void DumpIxNodeChain( void *vpTag, xbInt16 iOutputOpt ) const = 0;
184 virtual xbInt16 DumpNode( void * vpTag, xbIxNode * pNode, xbInt16 iOption ) const;
185 virtual xbInt16 DumpTagBlocks( xbInt16 iOpt = 1, void *vpTag = NULL ) = 0;
186
187 #endif
188
189 protected:
190 friend class xbDbf;
191
192 virtual xbInt16 AddKey( void *vpTag, xbUInt32 ulRecNo ) = 0;
193 virtual xbInt16 AddKeys( xbUInt32 ulRecNo );
194 virtual xbIxNode *AllocateIxNode( xbUInt32 ulBufSize = 0, xbInt16 iOption = 0 );
195 virtual xbInt16 BSearchBlock( char cKeyType, xbIxNode *npNode, xbInt32 lKeyLen, const void *vpKey, xbInt32 lSearchKeyLen, xbInt16 &iCompRc, xbBool bDescending = xbFalse ) const;
196 virtual xbInt16 CheckForDupKeys();
197 virtual xbInt16 CheckForDupKey( void *vpTag ) = 0;
198 virtual xbInt16 CompareKey( char cKeyType, const void *v1, const void *v2, size_t lKeyLen ) const;
199 virtual xbInt16 CreateKeys( xbInt16 iOpt );
200 virtual xbInt16 CreateKey( void * vpTag, xbInt16 iOpt ) = 0;
201 virtual xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo ) = 0;
202// virtual xbInt16 DeleteKeys( xbUInt32 ulRecNo );
203 virtual xbInt16 DeleteKeys();
204 virtual xbInt16 DeleteKey( void *vpTag ) = 0;
205
206 virtual xbInt16 DeleteTag( void *vpTag ) = 0;
207
208
209 virtual xbInt16 FindKeyForCurRec( void *vpTag ) = 0;
210 virtual xbIxNode *FreeNodeChain( xbIxNode *np );
211 virtual xbInt16 GetBlock( void *vpTag, xbUInt32 ulBlockNo, xbInt16 iOpt, xbUInt32 ulAddlBuf = 0 );
212// virtual xbBool GetIndexUpdated() const = 0;
213 virtual xbInt32 GetKeyCount( xbIxNode *npNode ) const;
214 virtual char *GetKeyData( xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iKeyItemLen ) const;
215 virtual xbInt16 GetKeySts( void *vpTag ) const = 0;
216 virtual xbInt16 GetLastKey( xbUInt32 ulNodeNo, void *vpTag, xbInt16 lRetrieveSw ) = 0;
217 virtual xbInt16 InsertNodeL( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, char * cpKeyBuf, xbUInt32 uiPtr ) = 0;
218 virtual xbInt16 InsertNodeI( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, xbUInt32 uiPtr ) = 0;
219 virtual xbInt16 KeyExists( void * ) = 0;
220// virtual xbInt16 KeyUpdated( void *vpTag ) const = 0;
221 virtual void NodeFree( xbIxNode * ixNode );
222 virtual xbInt16 ReadHeadBlock( xbInt16 iOpt = 0 ) = 0;
223 virtual void SetDbf( xbDbf *dbf );
224 virtual xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr ) = 0;
225 virtual xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr ) = 0;
226 virtual xbInt16 UpdateTagKey( char cAction, void *vpTag, xbUInt32 ulRecNo = 0 ) = 0;
227 virtual xbInt16 WriteHeadBlock( xbInt16 iOption ) = 0;
228
229 xbDbf *dbf;
230 char *cNodeBuf; // pointer to memory for processing in a block of index data
231 void *vpCurTag; // pointer to active tag. Single index files have only one tag
232
233 private:
234 virtual void AppendNodeChain( void *vpTag, xbIxNode *npNode ) = 0;
235 virtual xbInt16 GetKeyPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulKeyPtr ) const = 0;
236 virtual xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const = 0;
237 // virtual void SetCurNode( void *vpTag, xbIxNode *npNode ) = 0;
238
239 xbBool bLocked; // index file locked?
240};
241
242#ifdef XB_NDX_SUPPORT
243
244#define XB_NDX_BLOCK_SIZE 512
245
246
248struct XBDLLEXPORT xbNdxTag {
249
250 // NDX File Header Fields
251 xbUInt32 ulRootBlock; // header node is 0
252 xbUInt32 ulTotalBlocks; // includes header node
253 char cKeyType; // C = Char, F = Numeric, D = Date
254 xbInt16 iKeyLen; // length of key data
255 xbInt16 iKeysPerBlock; // max number keys per block <=100
256 xbInt16 iKeyType; // 00 = Char, 01 = Numeric
257 xbInt16 iKeyItemLen; // KeyLen + 8 bytes
258 char cSerNo; // rolling incrementing serial number +1 on each index update
259 xbInt16 iUnique; // True if unique
260 xbString sKeyExpression; // index expression
261 // end of NDX Header field
262
263 xbExp *exp; // pointer to expression for expression keys
264 time_t tNodeChainTs; // node chain time stamp
265 xbIxNode *npNodeChain;
266 xbIxNode *npCurNode;
267 char *cpKeyBuf; // key buffer, for searches and adds
268 char *cpKeyBuf2; // key buffer, for deletes
269 xbString sTagName; // tag name - is the file name without the extension
270// xbInt16 iKeyUpdated; // key updated? set in method KeyUpdated, checked in AddKey and DeleteKey routines
271 xbBool bFoundSts; // key found? used to determine if new key should be added in XB_EMULATE_DBASE mode in AddKey
272
273
274 xbInt16 iKeySts; // key updated? set in method CreateKey, checked in AddKey and DeleteKey routines
275 // old key filtered new key filtered iKeySts
276 // Y Y XB_UPD_KEY 2 - update key if changed (delete and add)
277 // Y N XB_DEL_KEY 3 - delete key
278 // N Y XB_ADD_KEY 1 - add key
279 // N N 0 - no update
280
281};
283
285
304class XBDLLEXPORT xbIxNdx : public xbIx {
305 public:
306 xbIxNdx( xbDbf * d );
307 ~xbIxNdx();
308 xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt );
309 xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
310// xbInt16 DeleteTag( void *vpTag );
311 xbInt16 FindKey( void *vpTag, const void *vpKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
312 xbInt16 GetFirstKey( void *vpTag, xbInt16 iRetrieveSw );
313
314 xbInt16 GetLastKey( void *vpTag, xbInt16 iRetrieveSw = 1 );
315 xbInt16 GetNextKey( void *vpTag, xbInt16 iRetrieveSw = 1 );
316 xbInt16 GetPrevKey( void *vpTag, xbInt16 iRetrieveSw = 1 );
317 xbInt32 GetKeyLen ( const void *vpTag ) const;
318 char GetKeyType ( const void *vpTag ) const;
319 xbString &GetKeyExpression( const void *vpTag ) const;
320 xbString &GetKeyFilter( const void *vpTag ) const;
321 void *GetTag( xbInt16 iTagNo ) const;
322 void *GetTag( xbString &sTagName ) const;
323 xbString &GetTagName( void *vpTag ) const;
324 const char * GetTagName( void *vpTag, xbInt16 iOpt ) const;
325
326 xbInt16 GetTagCount() const;
327 xbBool GetUnique( void *vpTag = NULL ) const;
328 xbBool GetSortOrder( void *vpTag ) const;
329 xbInt16 Reindex( void **vpTag );
330 xbInt16 SetCurTag( xbInt16 iTagNo );
331 xbInt16 SetCurTag( xbString &sTagName );
332
333
334
335 #ifdef XB_DEBUG_SUPPORT
336 xbInt16 DumpTagBlocks( xbInt16 iOpt = 1, void *vpTag = NULL );
337 xbInt16 DumpHeader( xbInt16 iOpt = 0, xbInt16 iFmt = 0 );
338 xbInt16 DumpIxForTag( void *vpTag, xbInt16 iOutputOpt );
339 void DumpIxNodeChain( void *vpTag, xbInt16 iOutputOpt ) const;
340 xbInt16 DumpNode( void * vpTag, xbIxNode * pNode, xbInt16 iOption ) const;
341 #endif
342
343 protected:
344 friend class xbDbf;
345 xbInt16 AddKey( void *vpTag, xbUInt32 ulRecNo );
346 xbIxNode *AllocateIxNode( xbUInt32 ulBufSize = 0, xbInt16 iOption = 0 );
347 xbInt16 CheckForDupKey( void *vpTag );
348 xbIxNode *CreateIxNode( xbUInt32 ulBufSize );
349 xbInt16 CreateKey( void * vpTag, xbInt16 iOpt );
350 xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo );
351 xbInt16 DeleteKey( void *vpTag );
352
353 xbInt16 DeleteTag( void *vpTag );
354
355 xbInt16 FindKeyForCurRec( void *vpTag );
356// xbBool GetIndexUpdated() const;
357 xbInt16 GetKeyTypeN( const void *vpTag ) const;
358 xbInt16 GetKeySts( void *vpTag ) const;
359 xbInt16 GetLastKey( xbUInt32 ulNodeNo, void *vpTag, xbInt16 iRetrieveSw = 1 );
360 xbInt16 InsertNodeI( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, xbUInt32 uiPtr );
361 xbInt16 InsertNodeL( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo, char * cpKeyBuf, xbUInt32 uiPtr );
362 xbInt16 KeyExists( void *vpTag = NULL );
363// xbBool KeyFiltered( void *vpTag ) const;
364// xbInt16 KeyUpdated( void *vpTag ) const;
365 xbInt16 ReadHeadBlock(xbInt16 iOpt); // read the header node of the disk NDX file
366 xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr );
367 xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
368 xbInt16 UpdateTagKey( char cAction, void *vpTag, xbUInt32 ulRecNo = 0 );
369 xbInt16 WriteHeadBlock( xbInt16 iOption );
370
371 private:
372 xbInt16 AddKeyNewRoot( xbNdxTag *npTag, xbIxNode *npLeft, xbIxNode *npRight );
373 void AppendNodeChain( void *vpTag, xbIxNode *npNode );
374 xbInt16 GetDbfPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulDbfPtr ) const;
375 xbInt16 GetKeyPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulKeyPtr ) const;
376 xbInt16 GetLastKeyForBlockNo( void *vpTag, xbUInt32 ulBlockNo, char *cpKeyBuf );
377 xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const;
378 xbInt16 KeySetPosAdd( xbNdxTag *npTag, xbUInt32 ulAddKeyRecNo );
379 xbInt16 KeySetPosDel( xbNdxTag *npTag );
380 // void SetCurNode( void *vpTag, xbIxNode *np );
381 xbNdxTag *ndxTag;
382};
383
384#endif /* XB_NDX_SUPPORT */
385
386
387#ifdef XB_MDX_SUPPORT
388//#define XB_MDX_BLOCK_SIZE 1024
389
390struct XBDLLEXPORT xbMdxTag {
391
392 // next 7 fields comprise the tag table entry
393 xbUInt32 ulTagHdrPageNo; // 512 byte page number, NOT block number
394 char cTagName[11];
395 char cKeyFmt; // always 0x10 w/ DBase V7
396 char cLeftChild; // cFwdTagThread
397 char cRightChild; // cFwdTagThread2
398 char cParent; // cBwdTagThread
399 char c2;
400 char cKeyType; // C,D,N
401
402 xbUInt32 ulRootPage; // 512 byte page number, NOT block number
403 xbUInt32 ulTagSize; // Number of 512 byte pages allocated to the tag. Tag size of two is a single 1024 block
404
405 char cKeyFmt2; // 0x10 - base
406 // 0x08 - descending
407 // 0x40 - unique
408 char cKeyType2;
409 // one unused byte fits here
410
411 char cTag11; // dbase sets to 0x1B
412
413 xbInt16 iKeyLen;
414 xbInt16 iKeysPerBlock;
415 xbInt16 iSecKeyType;
416 xbInt16 iKeyItemLen; // iKeyLen + 4
417
418 char cSerialNo; // Increments +1 for each tag update
419 char cUnique;
420 xbString *sKeyExp; // Key expression
421
422 char cHasFilter; // 0x00 or 0x01
423 char cHasKeys; // 0x00 or 0x01
424
425 xbUInt32 ulLeftChild; // dbase 7 sets this to the root page on tag creation
426 xbUInt32 ulRightChild; // dbase 7 sets this to the root page on tag creation
427
428 char cTagYY;
429 char cTagMM;
430 char cTagDD;
431
432 char cKeyFmt3; // dbase 7 sets this 0x01 if discreet field or 0x00 if calculated or combination field key expression on tag creation
433
434 xbString *sFiltExp; // Filter expression
435
436 time_t tNodeChainTs;
437 xbIxNode *npNodeChain;
438 xbIxNode *npCurNode;
439 xbExp *exp; // pointer to expression for expression based tags
440 xbExp *filter; // pointer to expression for index filter
441
442 char *cpKeyBuf; // key buffer
443 char *cpKeyBuf2; // key buffer
444// xbBool iKeyUpdated; // key updated? set in method CreateKey, checked in AddKey and DeleteKey routines
445 // 0 - no update
446 // 1 - Add
447 // 2 - Update
448 // 3 - Delete
449// xbBool bKeyFiltered; // key filtered? True if included key, False if excluded key. Set in method CreateKey, checked in AddKey and DeleteKey routines
450 xbString *sTagName; // string tag name
451
452
453 xbMdxTag *next;
454 xbBool bFoundSts; // key found? used to determine if new key should be added in XB_EMULATE_DBASE mode in AddKey
455
456
457 xbInt16 iKeySts; // key updated? set in method CreateKey, checked in AddKey and DeleteKey routines
458 // old key filtered new key filtered iKeySts
459 // Y Y XB_UPD_KEY 2 - update key if changed (delete and add)
460 // Y N XB_DEL_KEY 3 - delete key
461 // N Y XB_ADD_KEY 1 - add key
462 // N N 0 - no update
463
464
465};
466
467
468class XBDLLEXPORT xbIxMdx : public xbIx {
469 public:
470 xbIxMdx( xbDbf * d );
471 ~xbIxMdx();
472 xbInt16 CheckTagIntegrity( void *vpTag, xbInt16 iOpt );
473 xbInt16 CreateTag( const xbString &sName, const xbString &sKey, const xbString &sFilter, xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverlay, void **vpTag );
474// xbInt16 DeleteTag( void *vpTag );
475 xbInt16 FindKey( void *vpTag, const void *vKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
476 xbInt16 FindKey( void *vpTag, xbDouble dKey, xbInt16 iRetrieveSw );
477 xbInt16 GetFirstKey( void *vpTag, xbInt16 lRetrieveSw );
478 xbString &GetKeyExpression( const void *vpTag ) const;
479 xbString &GetKeyFilter( const void *vpTag ) const;
480 char GetKeyType( const void *vpTag ) const;
481 xbInt16 GetLastKey( void *vpTag, xbInt16 lRetrieveSw );
482 xbInt16 GetNextKey( void *vpTag, xbInt16 lRetrieveSw );
483 xbInt16 GetPrevKey( void *vpTag, xbInt16 lRetrieveSw );
484 xbBool GetReuseEmptyNodesSw() const;
485 xbBool GetSortOrder( void *vpTag ) const;
486 void *GetTag( xbInt16 iTagNo ) const;
487 void *GetTag( xbString &sTagName ) const;
488 xbInt16 GetTagCount() const;
489
490 xbString &GetTagName( void *vpTag ) const;
491 const char * GetTagName( void *vpTag, xbInt16 iOpt ) const;
492 void GetTagName( void *vpTag, xbString &sTagName );
493
494 xbInt16 GetUnique( void *vpTag ) const;
495 xbInt16 Reindex( void **vpTag );
496 xbInt16 SetCurTag( xbInt16 iTagNo );
497 xbInt16 SetCurTag( xbString &sTagName );
498 void SetReuseEmptyNodesSw( xbBool bReuse );
499
500 void TestStub( char *s, void *vpTag );
501
502 protected:
503 friend class xbDbf;
504
505 xbInt16 AddKey( void *vpTag, xbUInt32 ulRecNo );
506 xbIxNode *AllocateIxNode( xbMdxTag * mpTag, xbUInt32 ulBufSize, xbUInt32 ulBlock2 );
507 xbInt16 CheckForDupKey( void *vpTag );
508 xbInt16 Close();
509 xbInt16 CreateKey( void * vpTag, xbInt16 iOpt );
510 xbInt16 DeleteFromNode( void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo );
511 xbInt16 DeleteKey( void *vpTag );
512
513 xbInt16 DeleteTag( void *vpTag );
514
515 xbInt16 FindKeyForCurRec( void *vpTag );
516 xbInt16 GetKeySts( void *vpTag ) const;
517 xbInt16 GetLastKey( xbUInt32 ulBlockNo, void *vpTag, xbInt16 lRetrieveSw );
518 void *GetTagTblPtr() const;
519 void Init( xbInt16 iOpt = 0 );
520 xbInt16 InsertNodeI( void *vpTag, xbIxNode *npNode, xbInt16 iSlotNo, xbUInt32 uiPtr );
521 xbInt16 InsertNodeL( void *vpTag, xbIxNode *npNode, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
522 xbInt16 KeyExists( void * );
523 xbInt16 LoadTagTable();
524 xbInt16 ReadHeadBlock(xbInt16 iOpt); // read the header node of the disk file
525 xbInt16 SplitNodeI( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, xbUInt32 uiPtr );
526 xbInt16 SplitNodeL( void *vpTag, xbIxNode * npLeft, xbIxNode *npRight, xbInt16 iSlotNo, char *cpKeyBuf, xbUInt32 uiPtr );
527 xbInt16 UpdateTagKey( char cAction, void *vpTag, xbUInt32 ulRecNo = 0 );
528 xbInt16 WriteHeadBlock( xbInt16 iOption );
529
530 #ifdef XB_DEBUG_SUPPORT
531 xbInt16 DumpTagBlocks( xbInt16 iOpt = 1, void *vpTag = NULL );
532 xbInt16 DumpFreeBlocks( xbInt16 iOpt = 0 );
533 xbInt16 DumpHeader( xbInt16 iOpt = 0, xbInt16 iFmtOpt = 0 );
534 xbInt16 DumpIxForTag( void *vpTag, xbInt16 iOutputOpt );
535 void DumpIxNodeChain( void *vpTag, xbInt16 iOutputOpt ) const;
536 #endif
537
538 private:
539 xbInt16 AddKeyNewRoot( xbMdxTag *npTag, xbIxNode *npLeft, xbIxNode *npRight );
540 void AppendNodeChain( void *vpTag, xbIxNode *npNode );
541 xbUInt32 BlockToPage( xbUInt32 ulBlockNo );
542 void CalcBtreePointers();
543 char CalcTagKeyFmt( xbExp &exp );
544 char CalcTagFwdThread1();
545 char CalcTagFwdThread2();
546 xbMdxTag *ClearTagTable();
547 xbInt16 DumpBlock( xbInt16 iOpt, xbUInt32 ulBlockNo, xbMdxTag * mpTag );
548 xbInt16 GetDbfPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulDbfPtr ) const;
549 xbInt16 GetKeyPtr( void *vpTag, xbInt16 iKeyNo, xbIxNode *npNode, xbUInt32 &ulKeyPtr ) const;
550 xbInt16 GetLastKeyForBlockNo( void *vpTag, xbUInt32 ulBlockNo, char *cpKeyBuf );
551 xbInt16 HarvestEmptyNode( xbMdxTag *mpTag, xbIxNode *npNode, xbInt16 iOpt, xbBool bHarvestRoot = xbFalse );
552 xbInt16 HarvestTagNodes( xbMdxTag *mpTag, xbBool bRecycleRoot = xbFalse );
553 xbBool IsLeaf( void *vpTag, xbIxNode *npNode ) const;
554 xbInt16 KeySetPosAdd( xbMdxTag *mpTag, xbUInt32 ulAddKeyRecNo );
555 xbInt16 KeySetPosDel( xbMdxTag *mpTag );
556 xbInt16 LoadTagDetail( xbInt16 iOption, xbMdxTag *tte );
557 xbUInt32 PageToBlock( xbUInt32 ulPageNo );
558 xbInt16 TagSerialNo( xbInt16 iOption, xbMdxTag *mpTag );
559 xbInt16 UpdateTagSize( xbMdxTag *mpTag, xbUInt32 ulTagSz );
560
561 #ifdef XB_DEBUG_SUPPORT
562 xbInt16 PrintKey( void *vpTag, xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iDepth, char cType, xbInt16 iOutputOpt );
563 #endif
564
565 // MDX File Header Fields
566 char cVersion;
567 char cCreateYY;
568 char cCreateMM;
569 char cCreateDD;
570 xbString sFileName;
571 xbInt16 iBlockFactor; // 1-32 #of 512 byte segments in a block
572
573 // use file version
574 // xbInt16 iBlockSize; // Stored at the xbFile level
575
576 char cProdIxFlag;
577 char cTagEntryCnt;
578 xbInt16 iTagLen;
579 xbInt16 iTagUseCnt;
580 char cNextTag; // byte 28 +1
581 char c1B; // always 0x1B
582 xbUInt32 ulPageCnt; // number of 512 byte pages in the mdx file
583 xbUInt32 ulFirstFreePage; // page number corresponding to the next free block
584 xbUInt32 ulNoOfBlockAvail; // might be improperly named?? not sure how it is used
585 char cUpdateYY;
586 char cUpdateMM;
587 char cUpdateDD;
588 // end of MDX Header fields
589
590
591
592 xbMdxTag *mdxTagTbl;
593
594 xbBool bReuseEmptyNodes; // Reuese empty MDX nodes when all keys deleted?
595 // DBase 7.x and MS ODBC drivers do not reuse empty nodes, leaves them stranded in the file
596 // Codebase 6.x reuses empty nodes.
597 // Setting this to True will reuse empty nodes in the same manner Codebase 6.x reuses them.
598
599};
600#endif /* XB_MDX_SUPPORT */
601
602
603} /* namespace xb */
604#endif /* XB_INDEX_SUPPORT */
605#endif /* __XB_INDEX_H__ */
Definition: xbdate.cpp:19
double xbDouble
Definition: xbtypes.h:23
short int xbBool
Definition: xbtypes.h:24
class XBDLLEXPORT xbDbf
Definition: xbtblmgr.h:28
#define XB_NO_ERROR
Definition: xbretcod.h:24
#define xbFalse
Definition: xbtypes.h:29