Xbase64 Class Library  3.1.2
xbase64.h
Go to the documentation of this file.
1 /* xbase64.h
2 
3  Xbase project source code
4 
5  This file contains a header file for the xbXBase class, which is the
6  base class for using the Xbase DBMS library.
7 
8  Copyright (C) 1997,2003 Gary A Kunkel
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 
25  Contact:
26 
27  Email:
28 
29  xdb-devel@lists.sourceforge.net
30  xdb-users@lists.sourceforge.net
31 
32 
33  Regular Mail:
34 
35  XBase Support
36  149C South Main St
37  Keller Texas, 76248
38  USA
39 
40 */
41 
42 #ifndef __XB_XBASE_H__
43 #define __XB_XBASE_H__
44 
45 #ifdef __GNU_LesserG__
46 #pragma interface
47 #endif
48 
49 #ifdef __WIN32__
50 #include <xbase64/xbwincfg.h>
51 #else
52 #include <xbase64/xbconfig.h>
53 #endif
54 
55 #include <string.h>
56 #include <cstdio>
57 
58 #if defined(__WIN32__)
59 #include "windows.h"
60 
61 // ripped from wxWindows
62 
63 // _declspec works in BC++ 5 and later, as well as VC++
64 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNU_LesserC__)
65 # ifdef XBMAKINGDLL
66 # define XBDLLEXPORT __declspec( dllexport )
67 # define XBDLLEXPORT_DATA(type) __declspec( dllexport ) type
68 # define XBDLLEXPORT_CTORFN
69 # elif defined(XBUSINGDLL)
70 # define XBDLLEXPORT __declspec( dllimport )
71 # define XBDLLEXPORT_DATA(type) __declspec( dllimport ) type
72 # define XBDLLEXPORT_CTORFN
73 # else
74 # define XBDLLEXPORT
75 # define XBDLLEXPORT_DATA(type) type
76 # define XBDLLEXPORT_CTORFN
77 # endif
78 
79 #else
80 
81 # define XBDLLEXPORT
82 # define XBDLLEXPORT_DATA(type) type
83 # define XBDLLEXPORT_CTORFN
84 #endif
85 
86 #else // !Windows
87 # define XBDLLEXPORT
88 # define XBDLLEXPORT_DATA(type) type
89 # define XBDLLEXPORT_CTORFN
90 #endif // Win/!Win
91 
92 
93 #define XB_SINGLE_USER_MODE 0
94 #define XB_UNLOCK 200
95 #define XB_LOCK 201
96 #define XB_LOCK_HOLD 202
97 
98 #ifdef XB_LOCKING_ON
99 
100  #ifdef HAVE_SYS_LOCKING_H
101  #include <sys/locking.h>
102  #ifdef __MINGW32__
103  #defibe locking _locking
104  #endif
105  #endif
106 
107  #ifdef HAVE_FCNTL_H
108  #include <fcntl.h>
109  #endif
110 
111  #ifdef HAVE_UNISTD_H
112  #include <unistd.h>
113  #endif
114 
115  #define XB_XBASE_LOCK_MODE 200
116  #define XB_DBASE5_LOCK_MODE 201
117  #define XB_CLIPPER5_LOCK_MODE 202
118  #define XB_FOXPRO3_LOCK_MODE 203
119 
120 #endif // XB_LOCKING_ON
121 
122 #include "xbtypes.h"
123 #include "xbretcod.h"
124 #include "xbdate.h"
125 #include "xbstring.h"
126 
127 #ifndef XB_MIN
128 #define XB_MIN(a, b) (((a) < (b)) ? (a) : (b))
129 #endif /* XB_MIN */
130 
131 // 3/18/04 next macro isn't currently used in the library - GK
132 //#ifndef XB_MAX
133 //#define XB_MAX(a, b) (((a) < (b)) ? (b) : (a))
134 //#endif /* XB_MAX */
135 
140 
142 
146  char * DbfName;
148 };
149 
151 
154  public:
155  ~xbXBase();
156  xbXBase();
157  xbShort AddDbfToDbfList(xbDbf *d, const char *DatabaseName);
158  xbDbf * GetDbfPtr( const char *Name );
159  xbShort DirectoryExistsInName( const char *Name );
160  xbShort GetEndianType() { return EndianType; }
161  void DisplayError( xbShort ErrorCode ) const;
162  static const char* GetErrorMessage( xbShort ErrorCode );
163  xbString & GetDefaultDateFormat() { return DefaultDateFormat; }
164  void SetDefaultDateFormat( const xbString & f ){ DefaultDateFormat = f; }
165 
166  /* next 6 routines handle both big endian and little endian machines */
167  xbDouble GetDouble( const char *p );
168  xbLong GetLong ( const char *p );
169  xbULong GetULong ( const char *p );
170  xbShort GetShort ( const char *p );
171  xbULong GetHBFULong( const char *p );
172  xbShort GetHBFShort ( const char *p );
173 
174  void PutLong ( char *p, const xbLong l );
175  void PutShort ( char *p, const xbShort s );
176  void PutULong ( char *p, const xbULong l );
177  void PutUShort( char *p, const xbUShort s );
178  void PutDouble( char *p, const xbDouble d );
179 
180  xbShort RemoveDbfFromDbfList( xbDbf * );
181 
182 #ifdef XB_LOCKING_ON
183  xbShort GetLockRetryCount(){ return LockRetryCount; }
184  void SetLockRetryCount( xbShort lrc ) { LockRetryCount = lrc; }
185  xbShort LockFile( int fn, xbShort type, xbOffT len );
186  xbShort GetLockMode() { return LockMode; }
187  xbShort SetLockMode( xbShort nlm );
188 #endif
189 
190 protected:
193  xbShort EndianType; /* B = Big Endian, L = Little Endian */
194 
195 private:
196  xbString DefaultDateFormat;
197 
198 #ifdef XB_LOCKING_ON
199  xbShort LockRetryCount;
200  xbShort LockMode;
201 #endif
202 };
203 
204 #include "xbdbf.h"
205 
206 #if defined(XB_EXPRESSIONS)
207 #include "xbexp.h"
208 #endif
209 
210 #if defined(XB_INDEX_ANY)
211 #include "xbindex.h"
212 #include "xbmindex.h"
213 #endif
214 
215 #ifdef XB_LOCKING_ON
216 #include "xblock.h"
217 #endif
218 
219 #ifdef XB_INDEX_NDX
220 #include "xbndx.h"
221 #endif
222 
223 #ifdef XB_INDEX_NTX
224 #include "xbntx.h"
225 #endif
226 
227 #ifdef XB_INDEX_CDX
228 #include "xbcdx.h"
229 #endif
230 
231 #if defined(XB_FILTERS) && !defined(XB_INDEX_ANY)
232 #error XB_FILTERS cant be used without index support
233 #elif defined(XB_FILTERS)
234 #include "xbfilter.h"
235 #endif
236 
237 #endif // __XB_XBASE_H__
238 
239 
240 
xbXBase class
Definition: xbase64.h:153
xbDbList * FreeDbfList
Definition: xbase64.h:192
void SetDefaultDateFormat(const xbString &f)
Definition: xbase64.h:164
xbShort EndianType
Definition: xbase64.h:193
char * DbfName
Definition: xbase64.h:146
xbShort GetEndianType()
Definition: xbase64.h:160
#define XBDLLEXPORT
Definition: xbase64.h:87
long xbLong
Definition: xbtypes.h:61
short int xbShort
xbShort type
Definition: xbtypes.h:60
xbString & GetDefaultDateFormat()
Definition: xbase64.h:163
xbDbList * NextDbf
Definition: xbase64.h:145
xbDbList struct
Definition: xbase64.h:144
unsigned long int xbULong
xbULong type
Definition: xbtypes.h:50
xbString class
Definition: xbstring.h:63
double xbDouble
xbDouble type
Definition: xbtypes.h:73
unsigned short int xbUShort
xbUShort type
Definition: xbtypes.h:55
xbDbf * dbf
Definition: xbase64.h:147
long xbOffT
Definition: xbtypes.h:98
xbMH struct
Definition: xbdbf.h:190
xbDbList * DbfList
Definition: xbase64.h:191