00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef __XB_INDEX_H__
00044 #define __XB_INDEX_H__
00045
00046 #ifdef __GNU LesserG__
00047 #pragma interface
00048 #endif
00049
00050 #include <xbase64/xbase64.h>
00051 #include <string.h>
00055 #define XB_UNIQUE 1
00056 #define XB_NOT_UNIQUE 0
00057
00059
00062 class XBDLLEXPORT xbIndex: protected xbFile
00063 {
00064 public:
00065 xbIndex() {}
00066 xbIndex(xbDbf *);
00067
00068 virtual ~xbIndex();
00069
00070 xbShort OpenIndex ( const char * );
00071 xbShort CloseIndex();
00072 virtual xbShort CreateIndex( const char *, const char *, xbShort, xbShort ) = 0;
00073 virtual xbLong GetTotalNodes() = 0;
00074 virtual xbULong GetCurDbfRec() = 0;
00075 virtual xbShort CreateKey( xbShort, xbShort ) = 0;
00076 virtual xbShort GetCurrentKey(char *key) = 0;
00077 virtual xbShort AddKey( xbLong ) = 0;
00078 virtual xbShort UniqueIndex() = 0;
00079 virtual xbShort DeleteKey( xbLong ) = 0;
00080 virtual xbShort KeyWasChanged() = 0;
00081 virtual xbShort FindKey( const char * ) = 0;
00082 virtual xbShort FindKey() = 0;
00083 virtual xbShort FindKey( xbDouble ) = 0;
00084 virtual xbShort GetNextKey() = 0;
00085 virtual xbShort GetLastKey() = 0;
00086 virtual xbShort GetFirstKey() = 0;
00087 virtual xbShort GetPrevKey() = 0;
00088 virtual xbShort ReIndex(void (*statusFunc)(xbLong itemNum, xbLong numItems) = 0) = 0;
00089
00090 virtual xbShort KeyExists( xbDouble ) = 0;
00091 virtual xbShort TouchIndex() { return XB_NO_ERROR; }
00092 virtual void SetNodeSize(xbShort size) {}
00093 virtual xbShort GetNodeSize() { return NodeSize; }
00094 virtual void GetExpression(char *buf, int len) = 0;
00095 virtual void Flush();
00096 virtual const char * GetIxName() {return GetFileName().getData();}
00097 xbShort AllocKeyBufs();
00098 xbBool IsOpen() {return indexfp!=NULL;}
00099
00100 #ifdef XBASE_DEBUG
00101 virtual void DumpHdrNode( xbShort Option ) = 0;
00102 virtual void DumpNodeRec( xbLong ) = 0;
00103 virtual void DumpNodeChain() = 0;
00104 virtual xbShort CheckIndexIntegrity( xbShort ) = 0;
00105 #endif
00106
00107 #ifdef XB_LOCKING_ON
00108
00109
00110 #else
00111
00112 #endif
00113
00114 protected:
00115 virtual xbShort GetHeadNode()=0;
00116 virtual xbUShort GetKeyLen()=0;
00117 virtual const char* GetKeyExpression()=0;
00118 virtual void FreeNodesMemory()=0;
00119
00120 xbIndex *index;
00121 xbDbf *dbf;
00122 xbExpn *IxExp;
00123 FILE *indexfp;
00124
00125
00126 xbULong CurDbfRec;
00127 char *KeyBuf;
00128 char *KeyBuf2;
00129 xbShort NodeSize;
00130
00131 #ifdef XB_LOCKING_ON
00132 int LockCnt;
00133 int CurLockCount;
00134 int CurLockType;
00135 #endif
00136 };
00137
00138
00139 #endif