20#ifdef XB_INDEX_SUPPORT
33struct XBDLLEXPORT xbIxNode {
120class XBDLLEXPORT xbIx :
public xbFile {
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;
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;
142 virtual xbInt16 GetFirstKey(
void *vpTag, xbInt16 iRetrieveSw ) = 0;
143 virtual xbInt16 GetFirstKey(
void *vpTag );
144 virtual xbInt16 GetFirstKey();
146 virtual xbInt16 GetLastKey(
void *vpTag, xbInt16 lRetrieveSw ) = 0;
147 virtual xbInt16 GetLastKey(
void *vpTag );
148 virtual xbInt16 GetLastKey();
150 virtual xbInt16 GetNextKey(
void *vpTag, xbInt16 iRetrieveSw ) = 0;
151 virtual xbInt16 GetNextKey(
void *vpTag );
152 virtual xbInt16 GetNextKey();
154 virtual xbInt16 GetPrevKey(
void *vpTag, xbInt16 iRetrieveSw ) = 0;
155 virtual xbInt16 GetPrevKey(
void *vpTag );
156 virtual xbInt16 GetPrevKey();
158 virtual void *GetTag( xbInt16 iTagNo )
const = 0;
159 virtual void *GetTag( xbString &sTagName )
const = 0;
160 virtual xbInt16 GetTagCount()
const = 0;
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 ) {};
166 virtual xbBool GetUnique(
void *vpTag )
const = 0;
167 virtual xbBool GetSortOrder(
void *vpTag )
const = 0;
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 );
176 virtual void TestStub(
char *s,
void *vpTag ) {};
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;
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;
203 virtual xbInt16 DeleteKeys();
204 virtual xbInt16 DeleteKey(
void *vpTag ) = 0;
206 virtual xbInt16 DeleteTag(
void *vpTag ) = 0;
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 );
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;
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;
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;
244#define XB_NDX_BLOCK_SIZE 512
248struct XBDLLEXPORT xbNdxTag {
251 xbUInt32 ulRootBlock;
252 xbUInt32 ulTotalBlocks;
255 xbInt16 iKeysPerBlock;
260 xbString sKeyExpression;
265 xbIxNode *npNodeChain;
304class XBDLLEXPORT xbIxNdx :
public xbIx {
306 xbIxNdx(
xbDbf * d );
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 );
311 xbInt16 FindKey(
void *vpTag,
const void *vpKey, xbInt32 lKeyLen, xbInt16 iRetrieveSw );
312 xbInt16 GetFirstKey(
void *vpTag, xbInt16 iRetrieveSw );
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;
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 );
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;
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 );
353 xbInt16 DeleteTag(
void *vpTag );
355 xbInt16 FindKeyForCurRec(
void *vpTag );
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 );
365 xbInt16 ReadHeadBlock(xbInt16 iOpt);
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 );
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 );
390struct XBDLLEXPORT xbMdxTag {
393 xbUInt32 ulTagHdrPageNo;
414 xbInt16 iKeysPerBlock;
425 xbUInt32 ulLeftChild;
426 xbUInt32 ulRightChild;
437 xbIxNode *npNodeChain;
468class XBDLLEXPORT xbIxMdx :
public xbIx {
470 xbIxMdx(
xbDbf * d );
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 );
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;
490 xbString &GetTagName(
void *vpTag )
const;
491 const char * GetTagName(
void *vpTag, xbInt16 iOpt )
const;
492 void GetTagName(
void *vpTag, xbString &sTagName );
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 );
500 void TestStub(
char *s,
void *vpTag );
505 xbInt16 AddKey(
void *vpTag, xbUInt32 ulRecNo );
506 xbIxNode *AllocateIxNode( xbMdxTag * mpTag, xbUInt32 ulBufSize, xbUInt32 ulBlock2 );
507 xbInt16 CheckForDupKey(
void *vpTag );
509 xbInt16 CreateKey(
void * vpTag, xbInt16 iOpt );
510 xbInt16 DeleteFromNode(
void *vpTag, xbIxNode * npNode, xbInt16 iSlotNo );
511 xbInt16 DeleteKey(
void *vpTag );
513 xbInt16 DeleteTag(
void *vpTag );
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);
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 );
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;
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 );
561 #ifdef XB_DEBUG_SUPPORT
562 xbInt16 PrintKey(
void *vpTag, xbIxNode *npNode, xbInt16 iKeyNo, xbInt16 iDepth,
char cType, xbInt16 iOutputOpt );
571 xbInt16 iBlockFactor;
583 xbUInt32 ulFirstFreePage;
584 xbUInt32 ulNoOfBlockAvail;
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