Xbase64 Class Library
3.1.2
|
00001 /* xbindex.h 00002 00003 Xbase64 project source code 00004 00005 This file contains a header file for the NTX object, which is used 00006 for handling NTX type indices. NTX are the Clipper equivalant of xbNdx 00007 files. 00008 00009 Copyright (C) 1998 SynXis Corp., Bob Cotton 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU Lesser General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public License 00022 along with this program; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 00026 Contact: 00027 00028 Email: 00029 00030 xdb-devel@lists.sourceforge.net 00031 xdb-users@lists.sourceforge.net 00032 00033 00034 Regular Mail: 00035 00036 XBase Support 00037 149C South Main St 00038 Keller Texas, 76248 00039 USA 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 // virtual xbShort KeyExists( char * Key ) { return FindKey( Key, strlen( Key ), 0 ); } 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 // xbShort LockIndex( xbShort LockType ); 00109 // virtual xbShort LockIndex( const xbShort, const xbShort ); 00110 #else 00111 // virtual xbShort LockIndex( const xbShort, const xbShort ) const { return XB_NO_ERROR; } 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; /* index expression defines keys */ 00123 FILE *indexfp; 00124 /* NULL = closed, other = open */ 00125 // int IndexStatus; /* old - 0 = closed, 1 = open */ 00126 xbULong CurDbfRec; /* current Dbf record number */ 00127 char *KeyBuf; /* work area key buffer */ 00128 char *KeyBuf2; /* work area key buffer */ 00129 xbShort NodeSize; 00130 00131 #ifdef XB_LOCKING_ON 00132 int LockCnt; /* current index lock count */ 00133 int CurLockCount; /* old locking field */ 00134 int CurLockType; /* old locking field */ 00135 #endif 00136 }; 00137 00138 00139 #endif /* __XB_INDEX_H__ */