Xbase64 Class Library
3.1.2
|
00001 /* xbase64.h 00002 00003 Xbase project source code 00004 00005 This file contains a header file for the xbXBase class, which is the 00006 base class for using the Xbase DBMS library. 00007 00008 Copyright (C) 1997,2003 Gary A Kunkel 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU Lesser General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 00024 00025 Contact: 00026 00027 Email: 00028 00029 xdb-devel@lists.sourceforge.net 00030 xdb-users@lists.sourceforge.net 00031 00032 00033 Regular Mail: 00034 00035 XBase Support 00036 149C South Main St 00037 Keller Texas, 76248 00038 USA 00039 00040 */ 00041 00042 #ifndef __XB_XBASE_H__ 00043 #define __XB_XBASE_H__ 00044 00045 #ifdef __GNU_LesserG__ 00046 #pragma interface 00047 #endif 00048 00049 #ifdef __WIN32__ 00050 #include <xbase64/xbwincfg.h> 00051 #else 00052 #include <xbase64/xbconfig.h> 00053 #endif 00054 00055 #include <string.h> 00056 00057 #if defined(__WIN32__) 00058 #include "windows.h" 00059 00060 // ripped from wxWindows 00061 00062 // _declspec works in BC++ 5 and later, as well as VC++ 00063 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNU_LesserC__) 00064 # ifdef XBMAKINGDLL 00065 # define XBDLLEXPORT __declspec( dllexport ) 00066 # define XBDLLEXPORT_DATA(type) __declspec( dllexport ) type 00067 # define XBDLLEXPORT_CTORFN 00068 # elif defined(XBUSINGDLL) 00069 # define XBDLLEXPORT __declspec( dllimport ) 00070 # define XBDLLEXPORT_DATA(type) __declspec( dllimport ) type 00071 # define XBDLLEXPORT_CTORFN 00072 # else 00073 # define XBDLLEXPORT 00074 # define XBDLLEXPORT_DATA(type) type 00075 # define XBDLLEXPORT_CTORFN 00076 # endif 00077 00078 #else 00079 00080 # define XBDLLEXPORT 00081 # define XBDLLEXPORT_DATA(type) type 00082 # define XBDLLEXPORT_CTORFN 00083 #endif 00084 00085 #else // !Windows 00086 # define XBDLLEXPORT 00087 # define XBDLLEXPORT_DATA(type) type 00088 # define XBDLLEXPORT_CTORFN 00089 #endif // Win/!Win 00090 00091 00092 #define XB_SINGLE_USER_MODE 0 00093 #define XB_UNLOCK 200 00094 #define XB_LOCK 201 00095 #define XB_LOCK_HOLD 202 00096 00097 #ifdef XB_LOCKING_ON 00098 00099 #ifdef HAVE_SYS_LOCKING_H 00100 #include <sys/locking.h> 00101 #ifdef __MINGW32__ 00102 #defibe locking _locking 00103 #endif 00104 #endif 00105 00106 #ifdef HAVE_FCNTL_H 00107 #include <fcntl.h> 00108 #endif 00109 00110 #ifdef HAVE_UNISTD_H 00111 #include <unistd.h> 00112 #endif 00113 00114 #define XB_XBASE_LOCK_MODE 200 00115 #define XB_DBASE5_LOCK_MODE 201 00116 #define XB_CLIPPER5_LOCK_MODE 202 00117 #define XB_FOXPRO3_LOCK_MODE 203 00118 00119 #endif // XB_LOCKING_ON 00120 00121 #include "xbtypes.h" 00122 #include "xbretcod.h" 00123 #include "xbdate.h" 00124 #include "xbstring.h" 00125 00126 #ifndef XB_MIN 00127 #define XB_MIN(a, b) (((a) < (b)) ? (a) : (b)) 00128 #endif /* XB_MIN */ 00129 00130 // 3/18/04 next macro isn't currently used in the library - GK 00131 //#ifndef XB_MAX 00132 //#define XB_MAX(a, b) (((a) < (b)) ? (b) : (a)) 00133 //#endif /* XB_MAX */ 00134 00138 class XBDLLEXPORT xbDbf; 00139 00141 00143 struct XBDLLEXPORT xbDbList{ 00144 xbDbList * NextDbf; 00145 char * DbfName; 00146 xbDbf * dbf; 00147 }; 00148 00150 00152 class XBDLLEXPORT xbXBase { 00153 public: 00154 ~xbXBase(); 00155 xbXBase(); 00156 xbShort AddDbfToDbfList(xbDbf *d, const char *DatabaseName); 00157 xbDbf * GetDbfPtr( const char *Name ); 00158 xbShort DirectoryExistsInName( const char *Name ); 00159 xbShort GetEndianType() { return EndianType; } 00160 void DisplayError( xbShort ErrorCode ) const; 00161 static const char* GetErrorMessage( xbShort ErrorCode ); 00162 xbString & GetDefaultDateFormat() { return DefaultDateFormat; } 00163 void SetDefaultDateFormat( const xbString & f ){ DefaultDateFormat = f; } 00164 00165 /* next 6 routines handle both big endian and little endian machines */ 00166 xbDouble GetDouble( const char *p ); 00167 xbLong GetLong ( const char *p ); 00168 xbULong GetULong ( const char *p ); 00169 xbShort GetShort ( const char *p ); 00170 xbULong GetHBFULong( const char *p ); 00171 xbShort GetHBFShort ( const char *p ); 00172 00173 void PutLong ( char *p, const xbLong l ); 00174 void PutShort ( char *p, const xbShort s ); 00175 void PutULong ( char *p, const xbULong l ); 00176 void PutUShort( char *p, const xbUShort s ); 00177 void PutDouble( char *p, const xbDouble d ); 00178 00179 xbShort RemoveDbfFromDbfList( xbDbf * ); 00180 00181 #ifdef XB_LOCKING_ON 00182 xbShort GetLockRetryCount(){ return LockRetryCount; } 00183 void SetLockRetryCount( xbShort lrc ) { LockRetryCount = lrc; } 00184 xbShort LockFile( int fn, xbShort type, xbOffT len ); 00185 xbShort GetLockMode() { return LockMode; } 00186 xbShort SetLockMode( xbShort nlm ); 00187 #endif 00188 00189 protected: 00190 xbDbList * DbfList; 00191 xbDbList * FreeDbfList; 00192 xbShort EndianType; /* B = Big Endian, L = Little Endian */ 00193 00194 private: 00195 xbString DefaultDateFormat; 00196 00197 #ifdef XB_LOCKING_ON 00198 xbShort LockRetryCount; 00199 xbShort LockMode; 00200 #endif 00201 }; 00202 00203 #include "xbdbf.h" 00204 00205 #if defined(XB_EXPRESSIONS) 00206 #include "xbexp.h" 00207 #endif 00208 00209 #if defined(XB_INDEX_ANY) 00210 #include "xbindex.h" 00211 #include "xbmindex.h" 00212 #endif 00213 00214 #ifdef XB_LOCKING_ON 00215 #include "xblock.h" 00216 #endif 00217 00218 #ifdef XB_INDEX_NDX 00219 #include "xbndx.h" 00220 #endif 00221 00222 #ifdef XB_INDEX_NTX 00223 #include "xbntx.h" 00224 #endif 00225 00226 #ifdef XB_INDEX_CDX 00227 #include "xbcdx.h" 00228 #endif 00229 00230 #if defined(XB_FILTERS) && !defined(XB_INDEX_ANY) 00231 #error XB_FILTERS cant be used without index support 00232 #elif defined(XB_FILTERS) 00233 #include "xbfilter.h" 00234 #endif 00235 00236 #endif // __XB_XBASE_H__ 00237 00238 00239