00001 /* $Id: index.h,v 1.5 2000/11/10 19:04:17 dbryson Exp $ 00002 00003 Xbase 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 library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Lesser General Public 00013 License as published by the Free Software Foundation; either 00014 version 2.1 of the License, or (at your option) any later version. 00015 00016 This library 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 GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public 00022 License along with this library; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 Contact: 00026 00027 Mail: 00028 00029 Technology Associates, Inc. 00030 XBase Project 00031 1455 Deming Way #11 00032 Sparks, NV 89434 00033 USA 00034 00035 Email: 00036 00037 xbase@techass.com 00038 00039 See our website at: 00040 00041 xdb.sourceforge.net 00042 00043 00044 V 1.0 9/1/98 - Initial release of software 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; /* 0 = closed, 1 = open */ 00078 00079 xbLong CurDbfRec; /* current Dbf record number */ 00080 char *KeyBuf; /* work area key buffer */ 00081 char *KeyBuf2; /* work area key buffer */ 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 // virtual xbShort KeyExists( char * Key ) { return FindKey( Key, strlen( Key ), 0 ); } 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 /* __XB_INDEX_H__ */