// CodeGear C++Builder
// Copyright (c) 1995, 2021 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'ABSBTree.pas' rev: 35.00 (Windows)

#ifndef AbsbtreeHPP
#define AbsbtreeHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <System.Math.hpp>
#include <ABSPage.hpp>
#include <ABSBaseEngine.hpp>
#include <ABSExcept.hpp>
#include <ABSBase.hpp>
#include <ABSConverts.hpp>
#include <ABSMemory.hpp>
#include <ABSTypes.hpp>
#include <ABSVariant.hpp>
#include <ABSConst.hpp>

//-- user supplied -----------------------------------------------------------

namespace Absbtree
{
//-- forward type declarations -----------------------------------------------
struct TABSBTreePageHeader;
struct TABSKeyPathItem;
class DELPHICLASS TABSKeyPath;
struct TABSKeyPart;
class DELPHICLASS TABSBTreeKeyRef;
class DELPHICLASS TABSRecordKeyRef;
class DELPHICLASS TABSPageKeyRef;
class DELPHICLASS TABSBTreePage;
class DELPHICLASS TABSBTreePageController;
class DELPHICLASS TABSBTreeLeafController;
class DELPHICLASS TABSBTreeNodeController;
struct TABSBTreeSearchInfo;
class DELPHICLASS TABSBTreeRecordIndex;
class DELPHICLASS TABSBTreePageIndex;
class DELPHICLASS TABSBTreeRecordPageIndex;
class DELPHICLASS TABSBTreeBlobPageIndex;
//-- type declarations -------------------------------------------------------
#pragma pack(push,1)
struct DECLSPEC_DRECORD TABSBTreePageHeader
{
public:
	bool IsRoot;
	bool IsLeaf;
	int LeftPageNo;
	int RightPageNo;
	bool HasKeys;
	bool HasSuffixes;
	System::Word KeyPrefixSize;
	System::Word EntryCount;
	System::Word PagePrefixSize;
};
#pragma pack(pop)


typedef TABSBTreePageHeader *PABSBTreePageHeader;

enum DECLSPEC_DENUM TABSKeyPathPosition : unsigned char { kppUnknown, kppOnKey, kppBeforeKey, kppAfterKey, kppBOF, kppEOF };

typedef TABSKeyPathPosition *PABSKeyPathPosition;

struct DECLSPEC_DRECORD TABSKeyPathItem
{
public:
	int PageNo;
	int EntryNo;
	int EntryCount;
};


#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSKeyPath : public System::TObject
{
	typedef System::TObject inherited;
	
public:
	System::StaticArray<TABSKeyPathItem, 32> Items;
	int Count;
	int ItemNo;
	TABSKeyPathPosition PositionType;
	int IndexState;
	__fastcall TABSKeyPath();
	void __fastcall Clear();
	void __fastcall Assign(TABSKeyPath* KeyPath);
	void __fastcall AddItem(int aPageNo, int aEntryNo, int aEntryCount);
	void __fastcall DeleteLastItem();
	void __fastcall IncLevel();
	void __fastcall DecLevel();
	int __fastcall GetCurrentPageNo();
	void __fastcall SetCurrentPageNo(int Value);
	bool __fastcall PageExists(int aPageNo);
	int __fastcall Compare(TABSKeyPath* aKeyPath);
	double __fastcall GetApproxRecNoInPercents();
	__int64 __fastcall GetBitmapRecNoByIndexPosition(int MaxEntriesPerPage);
	void __fastcall FillItemsByBitmapRecNo(int RecordNo, int MaxEntriesPerPage);
	__property int CurrentPageNo = {read=GetCurrentPageNo, write=SetCurrentPageNo, nodefault};
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSKeyPath() { }
	
};

#pragma pack(pop)

struct DECLSPEC_DRECORD TABSKeyPart
{
public:
	int OffsetInShortKeyBuffer;
	int OffsetInFullKeyBuffer;
	int OffsetInRecordBuffer;
	int FieldNo;
	int ShortSize;
	int FullSize;
	int AddedSize;
	Abstypes::TABSBaseFieldType DataType;
	bool Descending;
	bool CaseInsensitive;
};


#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeKeyRef : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<TABSKeyPart> _TABSBTreeKeyRef__1;
	
	
private:
	int FShortKeySize;
	int FFullKeySize;
	System::Word FReferenceSize;
	bool FKeyIsReference;
	int FCompareFieldCount;
	int __fastcall GetPartCount();
	
protected:
	virtual void __fastcall SetPartCount(int Value);
	
public:
	_TABSBTreeKeyRef__1 Parts;
	System::PByte __fastcall AllocShortKeyBuffer();
	System::PByte __fastcall AllocFullKeyBuffer();
	void __fastcall FreeAndNilKeyBuffer(System::PByte &Buffer);
	virtual int __fastcall CompareShortKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2, bool MayUseFullKeys = false, int SessionID = 0xffffffff, System::PByte Reference1 = (System::PByte)(0x0), System::PByte Reference2 = (System::PByte)(0x0)) = 0 ;
	virtual int __fastcall CompareFullKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2) = 0 ;
	int __fastcall CompareReferences(System::PByte Reference1, System::PByte Reference2, int Size);
	__property int PartCount = {read=GetPartCount, write=SetPartCount, nodefault};
	__property int ShortKeySize = {read=FShortKeySize, nodefault};
	__property int FullKeySize = {read=FFullKeySize, nodefault};
	__property System::Word ReferenceSize = {read=FReferenceSize, write=FReferenceSize, nodefault};
	__property bool KeyIsReference = {read=FKeyIsReference, write=FKeyIsReference, nodefault};
	__property int CompareFieldCount = {read=FCompareFieldCount, write=FCompareFieldCount, nodefault};
public:
	/* TObject.Create */ inline __fastcall TABSBTreeKeyRef() : System::TObject() { }
	/* TObject.Destroy */ inline __fastcall virtual ~TABSBTreeKeyRef() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSRecordKeyRef : public TABSBTreeKeyRef
{
	typedef TABSBTreeKeyRef inherited;
	
	
private:
	typedef System::DynamicArray<int> _TABSRecordKeyRef__1;
	
	
private:
	System::Byte *LRecordBuffer;
	void *LTableData;
	_TABSRecordKeyRef__1 FCompareLengths;
	void __fastcall RetrieveFullKeyByRecordID(const Abstypes::TABSPageItemID &RecordID, System::PByte FullKey, int SessionID);
	
protected:
	virtual void __fastcall SetPartCount(int Value);
	
public:
	__fastcall TABSRecordKeyRef();
	void __fastcall Assign(Absbase::TABSIndexDef* IndexDef, void * aTableData);
	void __fastcall MakeShortKeyFromRecordBuffer(System::PByte RecordBuffer, System::PByte KeyBuffer);
	void __fastcall MakeFullKeyFromRecordBuffer(System::PByte RecordBuffer, System::PByte KeyBuffer);
	virtual int __fastcall CompareShortKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2, bool MayUseFullKeys = false, int SessionID = 0xffffffff, System::PByte Reference1 = (System::PByte)(0x0), System::PByte Reference2 = (System::PByte)(0x0));
	virtual int __fastcall CompareFullKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2);
	void __fastcall SetPartialCompare(System::PByte RecordBuffer, bool PartialCompare);
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSRecordKeyRef() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSPageKeyRef : public TABSBTreeKeyRef
{
	typedef TABSBTreeKeyRef inherited;
	
public:
	__fastcall TABSPageKeyRef();
	virtual int __fastcall CompareShortKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2, bool MayUseFullKeys = false, int SessionID = 0xffffffff, System::PByte Reference1 = (System::PByte)(0x0), System::PByte Reference2 = (System::PByte)(0x0));
	virtual int __fastcall CompareFullKeys(System::PByte KeyBuffer1, System::PByte KeyBuffer2);
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSPageKeyRef() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreePage : public Abspage::TABSPageController
{
	typedef Abspage::TABSPageController inherited;
	
private:
	TABSBTreeKeyRef* LKeyRef;
	Abspage::TABSPageManager* LPageManager;
	TABSBTreeLeafController* FLeafController;
	TABSBTreeNodeController* FNodeController;
	bool __fastcall GetIsRoot();
	void __fastcall SetIsRoot(bool Value);
	bool __fastcall GetIsLeaf();
	void __fastcall SetIsLeaf(bool Value);
	int __fastcall GetLeftPageNo();
	void __fastcall SetLeftPageNo(int Value);
	int __fastcall GetRightPageNo();
	void __fastcall SetRightPageNo(int Value);
	bool __fastcall GetHasKeys();
	void __fastcall SetHasKeys(bool Value);
	bool __fastcall GetHasSuffixes();
	void __fastcall SetHasSuffixes(bool Value);
	System::Word __fastcall GetKeyPrefixSize();
	void __fastcall SetKeyPrefixSize(System::Word Value);
	int __fastcall GetEntryCount();
	void __fastcall SetEntryCount(int Value);
	System::Word __fastcall GetPagePrefixSize();
	void __fastcall SetPagePrefixSize(System::Word Value);
	int __fastcall GetEntrySize();
	int __fastcall GetReferenceSize();
	int __fastcall GetEntriesOffset();
	int __fastcall GetSuffixPtrSize();
	
public:
	__fastcall TABSBTreePage(Abspage::TABSPageManager* PageManager, TABSBTreeKeyRef* KeyRef);
	__fastcall virtual ~TABSBTreePage();
	void __fastcall AddIndexPage(int SessionID, TABSBTreePage* &Page);
	void __fastcall RemoveIndexPage(int SessionID, int PageNo);
	void __fastcall GetIndexPage(int SessionID, int PageNo, TABSBTreePage* &Page);
	void __fastcall PutIndexPage(TABSBTreePage* Page);
	void __fastcall Init();
	void __fastcall InitAsRoot();
	void __fastcall CopyFrom(TABSBTreePage* Source, int StartNo, int Count);
	void __fastcall AppendFrom(TABSBTreePage* Source, int StartNo, int Count);
	void __fastcall InsertFrom(TABSBTreePage* Source, int StartNo, int Count);
	void __fastcall InsertLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	void __fastcall InsertNodeEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	bool __fastcall DeleteLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	void __fastcall DeleteNodeEntry(int SessionID, TABSKeyPath* KeyPath, bool MergeWithLeft);
	bool __fastcall FindEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* Position);
	bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall FindByCondition(int SessionID, bool First, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	void __fastcall FreeAllPages(int SessionID, bool KeepRootPage);
	void __fastcall CheckIntegrity(int SessionID, TABSKeyPath* KeyPath);
	System::PByte __fastcall GetPKey(int KeyPosition);
	System::PByte __fastcall GetPReference(int RefPosition);
	void __fastcall GetFirstKey(int SessionID, System::PByte Key);
	void __fastcall GetLastKey(int SessionID, System::PByte Key);
	void __fastcall GetFirstEntry(int SessionID, System::PByte Key, System::PByte Reference);
	void __fastcall GetLastEntry(int SessionID, System::PByte Key, System::PByte Reference);
	void __fastcall UpdateKey(int Position, System::PByte Key);
	void __fastcall UpdateReference(int Position, System::PByte Reference);
	__property bool IsRoot = {read=GetIsRoot, write=SetIsRoot, nodefault};
	__property bool IsLeaf = {read=GetIsLeaf, write=SetIsLeaf, nodefault};
	__property int LeftPageNo = {read=GetLeftPageNo, write=SetLeftPageNo, nodefault};
	__property int RightPageNo = {read=GetRightPageNo, write=SetRightPageNo, nodefault};
	__property bool HasKeys = {read=GetHasKeys, write=SetHasKeys, nodefault};
	__property bool HasSuffixes = {read=GetHasSuffixes, write=SetHasSuffixes, nodefault};
	__property System::Word KeyPrefixSize = {read=GetKeyPrefixSize, write=SetKeyPrefixSize, nodefault};
	__property int EntryCount = {read=GetEntryCount, write=SetEntryCount, nodefault};
	__property System::Word PagePrefixSize = {read=GetPagePrefixSize, write=SetPagePrefixSize, nodefault};
	__property int EntrySize = {read=GetEntrySize, nodefault};
	__property int ReferenceSize = {read=GetReferenceSize, nodefault};
	__property int EntriesOffset = {read=GetEntriesOffset, nodefault};
	__property int SuffixPtrSize = {read=GetSuffixPtrSize, nodefault};
	__property TABSBTreeKeyRef* KeyRef = {read=LKeyRef, write=LKeyRef};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreePageController : public System::TObject
{
	typedef System::TObject inherited;
	
protected:
	TABSBTreePage* FPage;
	TABSBTreeKeyRef* __fastcall GetKeyRef();
	bool __fastcall CanAddEntry();
	bool __fastcall IsOverflow();
	bool __fastcall CanUnderflow();
	bool __fastcall CanMergeWithPage(TABSBTreePage* Page);
	void __fastcall EnlargePageBuffer();
	int __fastcall CompareKeys(bool MayUseFullKeys, int SessionID, System::PByte Key1, System::Word Key2Index);
	int __fastcall CompareReferences(System::PByte Reference1, System::Word Reference2Index);
	virtual int __fastcall CompareEntries(bool MayUseFullKeys, int SessionID, System::PByte Key1, System::PByte Reference1, System::Word Entry2Index) = 0 ;
	System::Word __fastcall GetKeyPosition(bool MayUseFullKeys, int SessionID, System::PByte Key, System::PByte Reference, int StartPosition = 0x0, PABSKeyPathPosition PositionType = (PABSKeyPathPosition)(0x0), Abstypes::TABSKeySearchType SearchType = (Abstypes::TABSKeySearchType)(0x2));
	void __fastcall InsertEntry(System::PByte Key, System::PByte Reference, int Position);
	void __fastcall DeleteEntry(int Position);
	void __fastcall RootSplit(int SessionID, TABSKeyPath* KeyPath);
	void __fastcall NonRootSplit(int SessionID, TABSKeyPath* KeyPath);
	bool __fastcall TryMergeWithPage(int SessionID, int MergePageNo, TABSKeyPath* KeyPath);
	bool __fastcall TryMerge(int SessionID, TABSKeyPath* KeyPath);
	void __fastcall MergeWithLeftPage(int SessionID, TABSBTreePage* LeftPage, TABSKeyPath* KeyPath);
	void __fastcall MergeWithRightPage(int SessionID, TABSBTreePage* RightPage, TABSKeyPath* KeyPath);
	
public:
	__fastcall TABSBTreePageController(TABSBTreePage* aPage);
	virtual void __fastcall InsertLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath) = 0 ;
	virtual bool __fastcall DeleteLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath) = 0 ;
	virtual void __fastcall FreeAllPages(int SessionID, bool KeepRootPage) = 0 ;
	virtual void __fastcall CheckIntegrity(int SessionID, TABSKeyPath* KeyPath) = 0 ;
	virtual bool __fastcall FindEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* Position) = 0 ;
	virtual bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position) = 0 ;
	virtual bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position) = 0 ;
	virtual bool __fastcall FindByCondition(int SessionID, bool First, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position) = 0 ;
	System::PByte __fastcall GetPKey(int KeyPosition);
	System::PByte __fastcall GetPReference(int RefPosition);
	virtual void __fastcall GetFirstKey(int SessionID, System::PByte Key) = 0 ;
	virtual void __fastcall GetLastKey(int SessionID, System::PByte Key) = 0 ;
	virtual void __fastcall GetFirstEntry(int SessionID, System::PByte Key, System::PByte Reference) = 0 ;
	virtual void __fastcall GetLastEntry(int SessionID, System::PByte Key, System::PByte Reference) = 0 ;
	void __fastcall Split(int SessionID, TABSKeyPath* KeyPath);
	__property TABSBTreeKeyRef* KeyRef = {read=GetKeyRef};
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSBTreePageController() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeLeafController : public TABSBTreePageController
{
	typedef TABSBTreePageController inherited;
	
private:
	bool __fastcall FindEntryOnPage(int SessionID, System::PByte Key, System::PByte Reference, int &EntryNo);
	bool __fastcall FindFirstByCondition(int SessionID, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	bool __fastcall FindLastByCondition(int SessionID, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	
protected:
	virtual int __fastcall CompareEntries(bool MayUseFullKeys, int SessionID, System::PByte Key1, System::PByte Reference1, System::Word Entry2Index);
	
public:
	virtual void __fastcall InsertLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	virtual bool __fastcall DeleteLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	virtual void __fastcall GetFirstKey(int SessionID, System::PByte Key);
	virtual void __fastcall GetLastKey(int SessionID, System::PByte Key);
	virtual void __fastcall GetFirstEntry(int SessionID, System::PByte Key, System::PByte Reference);
	virtual void __fastcall GetLastEntry(int SessionID, System::PByte Key, System::PByte Reference);
	virtual bool __fastcall FindEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* Position);
	virtual bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position);
	virtual bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position);
	virtual bool __fastcall FindByCondition(int SessionID, bool First, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	virtual void __fastcall FreeAllPages(int SessionID, bool KeepRootPage);
	virtual void __fastcall CheckIntegrity(int SessionID, TABSKeyPath* KeyPath);
public:
	/* TABSBTreePageController.Create */ inline __fastcall TABSBTreeLeafController(TABSBTreePage* aPage) : TABSBTreePageController(aPage) { }
	
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSBTreeLeafController() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeNodeController : public TABSBTreePageController
{
	typedef TABSBTreePageController inherited;
	
private:
	bool __fastcall FindByConditionOnOneOfPages(int SessionID, bool First, int StartEntryNo, int EndEntryNo, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	bool __fastcall FindEntryOnOneOfPages(int SessionID, int StartEntryNo, int EndEntryNo, System::PByte Key, System::PByte Reference, TABSKeyPath* Position);
	void __fastcall GetChildPagesToCheck(int SessionID, System::PByte Key, Abstypes::TABSSearchCondition SearchCondition, int &StartEntryNo, int &EndEntryNo);
	void __fastcall DecreaseTreeDepth(int SessionID);
	
protected:
	virtual int __fastcall CompareEntries(bool MayUseFullKeys, int SessionID, System::PByte Key1, System::PByte Reference1, System::Word Entry2Index);
	
public:
	virtual void __fastcall InsertLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	void __fastcall InsertNodeEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	virtual bool __fastcall DeleteLeafEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* KeyPath);
	void __fastcall DeleteNodeEntry(int SessionID, TABSKeyPath* KeyPath, bool MergeWithLeft);
	virtual void __fastcall GetFirstKey(int SessionID, System::PByte Key);
	virtual void __fastcall GetLastKey(int SessionID, System::PByte Key);
	virtual void __fastcall GetFirstEntry(int SessionID, System::PByte Key, System::PByte Reference);
	virtual void __fastcall GetLastEntry(int SessionID, System::PByte Key, System::PByte Reference);
	virtual bool __fastcall FindEntry(int SessionID, System::PByte Key, System::PByte Reference, TABSKeyPath* Position);
	virtual bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position);
	virtual bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position);
	virtual bool __fastcall FindByCondition(int SessionID, bool First, System::PByte Key, Abstypes::TABSSearchCondition Operator, TABSKeyPath* Position);
	virtual void __fastcall FreeAllPages(int SessionID, bool KeepRootPage);
	virtual void __fastcall CheckIntegrity(int SessionID, TABSKeyPath* KeyPath);
public:
	/* TABSBTreePageController.Create */ inline __fastcall TABSBTreeNodeController(TABSBTreePage* aPage) : TABSBTreePageController(aPage) { }
	
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSBTreeNodeController() { }
	
};

#pragma pack(pop)

#pragma pack(push,1)
struct DECLSPEC_DRECORD TABSBTreeSearchInfo
{
public:
	bool GoForward;
	bool IsFilled;
	TABSKeyPath* EndKeyPath;
	TABSKeyPath* CurrentKeyPath;
};
#pragma pack(pop)


typedef TABSBTreeSearchInfo *PABSBTreeSearchInfo;

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeRecordIndex : public Absbaseengine::TABSIndex
{
	typedef Absbaseengine::TABSIndex inherited;
	
private:
	TABSBTreePage* FRootPage;
	TABSRecordKeyRef* FKeyRef;
	TABSBTreePage* __fastcall AddIndexPage(int SessionID);
	TABSBTreePage* __fastcall GetIndexPage(int SessionID, int PageNo);
	void __fastcall PutIndexPage(TABSBTreePage* Page);
	Abstypes::TABSPageItemID __fastcall GetRecordID(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetNextPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetPriorPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetPosition(int SessionID, bool Restart, bool GoForward, TABSKeyPath* Position);
	
public:
	__fastcall TABSBTreeRecordIndex(Absbaseengine::TABSBaseIndexManager* aIndexManager);
	__fastcall virtual ~TABSBTreeRecordIndex();
	virtual void __fastcall CreateIndex(Absbase::TABSCursor* Cursor, Absbase::TABSIndexDef* aIndexDef);
	virtual void __fastcall DropIndex(int SessionID);
	virtual void __fastcall EmptyIndex(int SessionID);
	virtual void __fastcall OpenIndex(Absbase::TABSIndexDef* aIndexDef);
	virtual void __fastcall RebuildTemporaryIndex(Absbase::TABSCursor* Cursor);
	virtual void __fastcall GetRecordBuffer(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo, Abstypes::TABSIndexPositionCache* IndexPositionCache, int TableState);
	virtual void __fastcall GetClosestRecordBuffer(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo, Abstypes::TABSIndexPositionCache* IndexPositionCache, int TableState);
	virtual System::TObject* __fastcall CreateIndexPosition();
	virtual void __fastcall FreeIndexPosition(System::TObject* &IndexPosition);
	virtual bool __fastcall GetIndexPosition(int SessionID, const Abstypes::TABSPageItemID &RecordID, System::PByte RecordBuffer, System::TObject* IndexPosition);
	virtual int __fastcall CompareRecordPositionsInIndex(System::TObject* RecordPosition1, System::TObject* RecordPosition2);
	virtual __int64 __fastcall GetRecNoByRecordID(int SessionID, const Abstypes::TABSPageItemID &RecordID, System::PByte RecordBuffer);
	virtual Abstypes::TABSPageItemID __fastcall GetRecordIDByRecNo(int SessionID, __int64 RecNo);
	virtual void __fastcall ApplyDistinctToRecordBitmap(int SessionID, Absbaseengine::TABSRecordBitmap* Bitmap, int DistinctFieldCount);
	virtual void * __fastcall CreateSearchInfo();
	virtual void __fastcall FreeSearchInfo(void * SearchInfo);
	
private:
	bool __fastcall GetCurrentPosition(int SessionID, bool Restart, bool GoForward, Abstypes::TABSScanSearchCondition* StartScanCondition, System::PByte RecordBuffer, const Abstypes::TABSPageItemID &RecordID, void * SearchInfo);
	bool __fastcall GetEndPosition(int SessionID, bool GoForward, Abstypes::TABSScanSearchCondition* StartScanCondition, Abstypes::TABSScanSearchCondition* EndScanCondition, void * SearchInfo);
	
public:
	virtual bool __fastcall FindRecord(int SessionID, bool Restart, bool GoForward, Abstypes::TABSScanSearchCondition* StartScanCondition, Abstypes::TABSScanSearchCondition* EndScanCondition, System::PByte RecordBuffer, Abstypes::TABSPageItemID &RecordID, void * SearchInfo);
	virtual int __fastcall CompareRecordBuffersByIndex(System::PByte Buffer1, System::PByte Buffer2, int IndexFieldCount);
	virtual int __fastcall CompareConditions(Abstypes::TABSScanSearchCondition* Condition1, Abstypes::TABSScanSearchCondition* Condition2);
	virtual __int64 __fastcall GetApproxRangeRecordCount(int SessionID, __int64 TableRecordCount, Abstypes::TABSScanSearchCondition* RangeCondition1, Abstypes::TABSScanSearchCondition* RangeCondition2);
	virtual bool __fastcall CanInsertRecord(int SessionID, System::PByte RecordBuffer);
	virtual bool __fastcall CanUpdateRecord(int SessionID, System::PByte OldRecordBuffer, System::PByte NewRecordBuffer);
	virtual void __fastcall InsertRecord(Absbase::TABSCursor* Cursor);
	virtual void __fastcall UpdateRecord(Absbase::TABSCursor* Cursor, bool BeforeNewRecordIsStored);
	virtual void __fastcall DeleteRecord(Absbase::TABSCursor* Cursor);
	virtual int __fastcall GetMaxEntriesPerPage();
	virtual void __fastcall GetRecordIDByIndexPosition(int SessionID, System::TObject* IndexPos, Abstypes::TABSPageItemID &RecordID);
	__property TABSRecordKeyRef* KeyRef = {read=FKeyRef};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreePageIndex : public System::TObject
{
	typedef System::TObject inherited;
	
protected:
	int FRootPageNo;
	TABSPageKeyRef* FKeyRef;
	Abspage::TABSPageManager* LPageManager;
	int FMaxRecordsOnPage;
	TABSBTreePage* __fastcall AddIndexPage(int SessionID);
	TABSBTreePage* __fastcall GetIndexPage(int SessionID, int PageNo);
	void __fastcall PutIndexPage(TABSBTreePage* Page);
	bool __fastcall GetFirstPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetLastPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetNextPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetPriorPosition(int SessionID, TABSKeyPath* Position);
	bool __fastcall GetPosition(int SessionID, int PageNo, TABSKeyPath* Position);
	System::Word __fastcall GetPageValue(int SessionID, TABSKeyPath* Position);
	void __fastcall SetPageValue(int SessionID, TABSKeyPath* Position, System::Word Value);
	int __fastcall GetPageNo(int SessionID, TABSKeyPath* Position);
	virtual bool __fastcall CanAddNewItem(int OldValue, int NewItemSize) = 0 ;
	bool __fastcall FindPageForNewItem(int SessionID, int ItemSize, int &PageNo);
	void __fastcall AddPageItem(int SessionID, int ItemSize, int PageNo);
	void __fastcall DeletePageItem(int SessionID, int ItemSize, int PageNo, int NewItemCount);
	
public:
	__fastcall TABSBTreePageIndex(Abspage::TABSPageManager* PageManager);
	__fastcall virtual ~TABSBTreePageIndex();
	void __fastcall CreateIndex(int SessionID);
	void __fastcall DropIndex(int SessionID);
	void __fastcall EmptyIndex(int SessionID);
	void __fastcall OpenIndex(int RootPageNo);
	__property TABSPageKeyRef* KeyRef = {read=FKeyRef};
	__property int RootPageNo = {read=FRootPageNo, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeRecordPageIndex : public TABSBTreePageIndex
{
	typedef TABSBTreePageIndex inherited;
	
private:
	int FMaxRecordsOnPage;
	System::Word __fastcall GetPageRecordCount(int SessionID, TABSKeyPath* Position);
	
protected:
	virtual bool __fastcall CanAddNewItem(int OldValue, int NewItemSize);
	
public:
	bool __fastcall FindPageForNewRecord(int SessionID, int &PageNo);
	void __fastcall AddRecord(int SessionID, int PageNo, int AddCount = 0x1);
	void __fastcall DeleteRecord(int SessionID, int PageNo, int NewItemCount);
	bool __fastcall GetFirstRecordPage(int SessionID, int &PageNo);
	bool __fastcall GetLastRecordPage(int SessionID, int &PageNo);
	bool __fastcall GetNextRecordPage(int SessionID, int CurrentPageNo, int &NextPageNo);
	bool __fastcall GetPriorRecordPage(int SessionID, int CurrentPageNo, int &PriorPageNo);
	void __fastcall GetRecordByRecNo(int SessionID, __int64 RecNo, int &PageNo, int &RecNoOnPage);
	void __fastcall GetRecNoByRecord(int SessionID, int PageNo, int RecNoOnPage, __int64 &RecNo);
	void __fastcall Validate(int SessionID, int StoredRecordCount);
	__property int MaxRecordsOnPage = {read=FMaxRecordsOnPage, write=FMaxRecordsOnPage, nodefault};
public:
	/* TABSBTreePageIndex.Create */ inline __fastcall TABSBTreeRecordPageIndex(Abspage::TABSPageManager* PageManager) : TABSBTreePageIndex(PageManager) { }
	/* TABSBTreePageIndex.Destroy */ inline __fastcall virtual ~TABSBTreeRecordPageIndex() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSBTreeBlobPageIndex : public TABSBTreePageIndex
{
	typedef TABSBTreePageIndex inherited;
	
protected:
	virtual bool __fastcall CanAddNewItem(int OldValue, int NewItemSize);
	
public:
	bool __fastcall FindPageForNewBlob(int SessionID, int BlobSize, int &PageNo);
	void __fastcall AddBlob(int SessionID, int BlobSize, int PageNo);
	void __fastcall DeleteBlob(int SessionID, int BlobSize, int PageNo);
	int __fastcall GetBlobPageAllocatedSpace(int SessionID, int PageNo);
public:
	/* TABSBTreePageIndex.Create */ inline __fastcall TABSBTreeBlobPageIndex(Abspage::TABSPageManager* PageManager) : TABSBTreePageIndex(PageManager) { }
	/* TABSBTreePageIndex.Destroy */ inline __fastcall virtual ~TABSBTreeBlobPageIndex() { }
	
};

#pragma pack(pop)

//-- var, const, procedure ---------------------------------------------------
}	/* namespace Absbtree */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_ABSBTREE)
using namespace Absbtree;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// AbsbtreeHPP
