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 
57 #if defined(__WIN32__)
58 #include "windows.h"
59 
60 // ripped from wxWindows
61 
62 // _declspec works in BC++ 5 and later, as well as VC++
63 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNU_LesserC__)
64 # ifdef XBMAKINGDLL
65 # define XBDLLEXPORT __declspec( dllexport )
66 # define XBDLLEXPORT_DATA(type) __declspec( dllexport ) type
67 # define XBDLLEXPORT_CTORFN
68 # elif defined(XBUSINGDLL)
69 # define XBDLLEXPORT __declspec( dllimport )
70 # define XBDLLEXPORT_DATA(type) __declspec( dllimport ) type
71 # define XBDLLEXPORT_CTORFN
72 # else
73 # define XBDLLEXPORT
74 # define XBDLLEXPORT_DATA(type) type
75 # define XBDLLEXPORT_CTORFN
76 # endif
77 
78 #else
79 
80 # define XBDLLEXPORT
81 # define XBDLLEXPORT_DATA(type) type
82 # define XBDLLEXPORT_CTORFN
83 #endif
84 
85 #else // !Windows
86 # define XBDLLEXPORT
87 # define XBDLLEXPORT_DATA(type) type
88 # define XBDLLEXPORT_CTORFN
89 #endif // Win/!Win
90 
91 
92 #define XB_SINGLE_USER_MODE 0
93 #define XB_UNLOCK 200
94 #define XB_LOCK 201
95 #define XB_LOCK_HOLD 202
96 
97 #ifdef XB_LOCKING_ON
98 
99  #ifdef HAVE_SYS_LOCKING_H
100  #include <sys/locking.h>
101  #ifdef __MINGW32__
102  #defibe locking _locking
103  #endif
104  #endif
105 
106  #ifdef HAVE_FCNTL_H
107  #include <fcntl.h>
108  #endif
109 
110  #ifdef HAVE_UNISTD_H
111  #include <unistd.h>
112  #endif
113 
114  #define XB_XBASE_LOCK_MODE 200
115  #define XB_DBASE5_LOCK_MODE 201
116  #define XB_CLIPPER5_LOCK_MODE 202
117  #define XB_FOXPRO3_LOCK_MODE 203
118 
119 #endif // XB_LOCKING_ON
120 
121 #include "xbtypes.h"
122 #include "xbretcod.h"
123 #include "xbdate.h"
124 #include "xbstring.h"
125 
126 #ifndef XB_MIN
127 #define XB_MIN(a, b) (((a) < (b)) ? (a) : (b))
128 #endif /* XB_MIN */
129 
130 // 3/18/04 next macro isn't currently used in the library - GK
131 //#ifndef XB_MAX
132 //#define XB_MAX(a, b) (((a) < (b)) ? (b) : (a))
133 //#endif /* XB_MAX */
134 
138 class XBDLLEXPORT xbDbf;
139 
141 
145  char * DbfName;
147 };
148 
150 
153  public:
154  ~xbXBase();
155  xbXBase();
156  xbShort AddDbfToDbfList(xbDbf *d, const char *DatabaseName);
157  xbDbf * GetDbfPtr( const char *Name );
158  xbShort DirectoryExistsInName( const char *Name );
159  xbShort GetEndianType() { return EndianType; }
160  void DisplayError( xbShort ErrorCode ) const;
161  static const char* GetErrorMessage( xbShort ErrorCode );
162  xbString & GetDefaultDateFormat() { return DefaultDateFormat; }
163  void SetDefaultDateFormat( const xbString & f ){ DefaultDateFormat = f; }
164 
165  /* next 6 routines handle both big endian and little endian machines */
166  xbDouble GetDouble( const char *p );
167  xbLong GetLong ( const char *p );
168  xbULong GetULong ( const char *p );
169  xbShort GetShort ( const char *p );
170  xbULong GetHBFULong( const char *p );
171  xbShort GetHBFShort ( const char *p );
172 
173  void PutLong ( char *p, const xbLong l );
174  void PutShort ( char *p, const xbShort s );
175  void PutULong ( char *p, const xbULong l );
176  void PutUShort( char *p, const xbUShort s );
177  void PutDouble( char *p, const xbDouble d );
178 
179  xbShort RemoveDbfFromDbfList( xbDbf * );
180 
181 #ifdef XB_LOCKING_ON
182  xbShort GetLockRetryCount(){ return LockRetryCount; }
183  void SetLockRetryCount( xbShort lrc ) { LockRetryCount = lrc; }
184  xbShort LockFile( int fn, xbShort type, xbOffT len );
185  xbShort GetLockMode() { return LockMode; }
186  xbShort SetLockMode( xbShort nlm );
187 #endif
188 
189 protected:
192  xbShort EndianType; /* B = Big Endian, L = Little Endian */
193 
194 private:
195  xbString DefaultDateFormat;
196 
197 #ifdef XB_LOCKING_ON
198  xbShort LockRetryCount;
199  xbShort LockMode;
200 #endif
201 };
202 
203 #include "xbdbf.h"
204 
205 #if defined(XB_EXPRESSIONS)
206 #include "xbexp.h"
207 #endif
208 
209 #if defined(XB_INDEX_ANY)
210 #include "xbindex.h"
211 #include "xbmindex.h"
212 #endif
213 
214 #ifdef XB_LOCKING_ON
215 #include "xblock.h"
216 #endif
217 
218 #ifdef XB_INDEX_NDX
219 #include "xbndx.h"
220 #endif
221 
222 #ifdef XB_INDEX_NTX
223 #include "xbntx.h"
224 #endif
225 
226 #ifdef XB_INDEX_CDX
227 #include "xbcdx.h"
228 #endif
229 
230 #if defined(XB_FILTERS) && !defined(XB_INDEX_ANY)
231 #error XB_FILTERS cant be used without index support
232 #elif defined(XB_FILTERS)
233 #include "xbfilter.h"
234 #endif
235 
236 #endif // __XB_XBASE_H__
237 
238 
239 
xbMH struct
Definition: xbdbf.h:190
xbString class
Definition: xbstring.h:63
xbXBase class
Definition: xbase64.h:152
xbDbList * FreeDbfList
Definition: xbase64.h:191
xbDbList * DbfList
Definition: xbase64.h:190
xbShort GetEndianType()
Definition: xbase64.h:159
void SetDefaultDateFormat(const xbString &f)
Definition: xbase64.h:163
xbShort EndianType
Definition: xbase64.h:192
xbString & GetDefaultDateFormat()
Definition: xbase64.h:162
xbDbList struct
Definition: xbase64.h:143
xbDbList * NextDbf
Definition: xbase64.h:144
char * DbfName
Definition: xbase64.h:145
xbDbf * dbf
Definition: xbase64.h:146
#define XBDLLEXPORT
Definition: xbase64.h:86
long xbLong
Definition: xbtypes.h:61
short int xbShort
xbShort type
Definition: xbtypes.h:60
unsigned short int xbUShort
xbUShort type
Definition: xbtypes.h:55
double xbDouble
xbDouble type
Definition: xbtypes.h:73
unsigned long int xbULong
xbULong type
Definition: xbtypes.h:50
long xbOffT
Definition: xbtypes.h:97