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