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
00044
00045 #ifndef __XB_INDEX_H__
00046 #define __XB_INDEX_H__
00047
00048 #ifdef __GNUG__
00049 #pragma interface
00050 #endif
00051
00052 #include <xbase/xbase.h>
00053 #include <string.h>
00054
00058 #define XB_UNIQUE 1
00059 #define XB_NOT_UNIQUE 0
00060
00062
00065 class XBDLLEXPORT xbIndex
00066 {
00067 public:
00068 xbIndex *index;
00069 xbDbf *dbf;
00070 xbExpNode *ExpressionTree;
00071
00072 xbString IndexName;
00073 FILE *indexfp;
00074
00075 int IndexStatus;
00076
00077 xbULong CurDbfRec;
00078 char *KeyBuf;
00079 char *KeyBuf2;
00080
00081 #ifdef XB_LOCKING_ON
00082 protected:
00083 int CurLockCount;
00084 int CurLockType;
00085 #endif
00086
00087 xbShort NodeSize;
00088
00089 public:
00090 xbIndex() {}
00091 xbIndex(xbDbf *);
00092
00093 virtual ~xbIndex() {}
00094
00095 virtual xbShort OpenIndex ( const char * ) = 0;
00096 virtual xbShort CloseIndex() = 0;
00097 #ifdef XBASE_DEBUG
00098 virtual void DumpHdrNode() = 0;
00099 virtual void DumpNodeRec( xbLong ) = 0;
00100 virtual void DumpNodeChain() = 0;
00101 virtual xbShort CheckIndexIntegrity( const xbShort ) = 0;
00102 #endif
00103 virtual xbShort CreateIndex( const char *, const char *, xbShort, xbShort ) = 0;
00104 virtual xbLong GetTotalNodes() = 0;
00105 virtual xbULong GetCurDbfRec() = 0;
00106 virtual xbShort CreateKey( xbShort, xbShort ) = 0;
00107 virtual xbShort GetCurrentKey(char *key) = 0;
00108 virtual xbShort AddKey( xbLong ) = 0;
00109 virtual xbShort UniqueIndex() = 0;
00110 virtual xbShort DeleteKey( xbLong ) = 0;
00111 virtual xbShort KeyWasChanged() = 0;
00112 virtual xbShort FindKey( const char * ) = 0;
00113 virtual xbShort FindKey() = 0;
00114 virtual xbShort FindKey( xbDouble ) = 0;
00115 virtual xbShort GetNextKey() = 0;
00116 virtual xbShort GetLastKey() = 0;
00117 virtual xbShort GetFirstKey() = 0;
00118 virtual xbShort GetPrevKey() = 0;
00119 virtual xbShort ReIndex(void (*statusFunc)(xbLong itemNum, xbLong numItems) = 0) = 0;
00120
00121 virtual xbShort KeyExists( xbDouble ) = 0;
00122
00123 #ifdef XB_LOCKING_ON
00124 virtual xbShort LockIndex( const xbShort, const xbShort );
00125 #else
00126 virtual xbShort LockIndex( const xbShort, const xbShort ) const { return XB_NO_ERROR; }
00127 #endif
00128
00129 virtual xbShort TouchIndex( void ) { return XB_NO_ERROR; }
00130
00131 virtual void SetNodeSize(xbShort size) {}
00132 virtual xbShort GetNodeSize(void) { return NodeSize; }
00133
00134 virtual void GetExpression(char *buf, int len) = 0;
00135
00136 virtual void Flush();
00137 };
00138
00139
00140 #endif