Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbxbase.h
Go to the documentation of this file.
1/* xbxbase.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014,2022,2023 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14*/
15
16
17#ifndef __XB_XBDBLIST_H__
18#define __XB_XBDBLIST_H__
19
20#ifdef CMAKE_COMPILER_IS_GNUCC
21#pragma interface
22#endif
23
24namespace xb{
25
26class XBDLLEXPORT xbLog;
27
28/************************************************************************/
29/*
30 Xbase functions
31
32 Min Parm Count is the minimum number of input parms needed by the function
33
34 Return Type
35 C Char or string
36 D Date
37 L Logical
38 N Numeric
39 1 Varies - pull return type from first sibling
40 2 Varies - pull return type from second sibling
41*/
42
43#ifdef XB_FUNCTION_SUPPORT
44
45/*
46struct XBDLLEXPORT xbFunctionInfo {
47 const char * FuncName; // function name
48 char ReturnType; // return type of function
49 xbInt16 iReturnLenCalc; // used to calculate the function return value is
50 // 1 = use value specified in iReturnLenVal
51 // 2 = use length of operand specified in col 4
52 // 3 = use valued of numeric operand specified in col 4
53 // 4 = length of parm 1 * numeric value parm
54 // 5 = larger length of parm 2 or length of parm 3
55 // 6 = if two or more parms, use numeric value from second parm,
56 // otherwise use col4 value
57 xbInt16 iReturnLenVal; // Used in combination with iReturnLenCalc
58
59};
60*/
61/*
62static xbFunctionInfo FunctionList[] =
63// Func Return -Rtrn Len-
64// Name Type -Calc Val-
65{
66 { "ABS", 'N', 1, 4 },
67 { "ALLTRIM", 'C', 2, 1 },
68 { "ASC", 'N', 1, 4 },
69 { "AT", 'N', 1, 4 },
70 { "CDOW", 'C', 1, 9 },
71 { "CHR", 'C', 1, 1 },
72 { "CMONTH", 'C', 1, 9 },
73 { "CTOD", 'D', 1, 8 },
74 { "DATE", 'D', 1, 8 },
75 { "DAY", 'N', 1, 4 },
76 { "DEL", 'C', 1, 1 },
77 { "DELETED", 'L', 1, 1 },
78 { "DESCEND", '1', 2, 1 },
79 { "DOW", 'N', 1, 4 },
80 { "DTOC", 'C', 1, 8 },
81 { "DTOS", 'C', 1, 8 },
82 { "EXP", 'N', 1, 4 },
83 { "IIF", 'C', 5, 0 },
84 { "INT", 'N', 1, 4 },
85 { "ISALPHA", 'L', 1, 1 },
86 { "ISLOWER", 'L', 1, 1 },
87 { "ISUPPER", 'L', 1, 1 },
88 { "LEFT", 'C', 3, 2 },
89 { "LEN", 'N', 1, 4 },
90 { "LOG", 'N', 1, 4 },
91 { "LOWER", 'C', 2, 1 },
92 { "LTRIM", 'C', 2, 1 },
93 { "MAX", 'N', 1, 4 },
94 { "MIN", 'N', 1, 4 },
95 { "MONTH", 'N', 1, 4 },
96 { "RECNO", 'N', 1, 4 },
97 { "RECCOUNT", 'N', 1, 4 },
98 { "REPLICATE", 'C', 4, 0 },
99 { "RIGHT", 'C', 3, 2 },
100 { "RTRIM", 'C', 2, 1 },
101 { "SPACE", 'C', 3, 1 },
102 { "SQRT", 'N', 1, 4 },
103 { "STOD", 'D', 1, 8 },
104 { "STR", 'C', 6, 10 },
105 { "STRZERO", 'C', 3, 2 },
106 { "SUBSTR", 'C', 3, 3 },
107 { "TRIM", 'C', 2, 1 },
108 { "UPPER", 'C', 2, 1 },
109 { "VAL", 'N', 1, 4 },
110 { "YEAR", 'N', 1, 4 },
111 { 0, 0, 0, 0 },
112};
113*/
114#endif
115
116
117
119
123class XBDLLEXPORT xbXBase : public xbTblMgr{
124 public:
125 xbXBase();
126 ~xbXBase();
127
128 xbInt16 CloseAllTables();
129 xbInt16 CreateFqn( const xbString &sDirIn, const xbString &sNameIn, const xbString &sExtIn, xbString &sFqfnOut );
130 void DisableMsgLogging();
131 void EnableMsgLogging ();
132 xbInt16 FlushLog();
133
134 //const xbString &GetLogDirectory () const;
135 //const xbString &GetLogFileName () const;
136 const xbString &GetLogFqFileName() const;
137 xbBool GetLogStatus () const;
138
139 xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf &dbf, int dummy );
140 xbInt16 OpenHighestVersion( const xbString &sTableName, const xbString &sAlias, xbDbf **dbf );
141
142 xbDbf * Open( const xbString &sTableName, xbInt16 &iRc );
143 xbDbf * Open( const xbString &sTableName, const xbString &sAlias, xbInt16 iOpenMode, xbInt16 iShareMode, xbInt16 iVersion, xbInt16 &iRc );
144
145 // next three methods moved to xbssv for consistency
146 // void SetLogDirectory( const xbString &sLogFileDirectory );
147 // void SetLogFileName ( const xbString &sLogFileName );
148 void SetLogSize ( size_t lSize );
149 size_t GetLogSize () const;
150
151 xbInt16 WriteLogMessage( const xbString &sLogMessage, xbInt16 iOutputOpt = 0 );
152 xbInt16 WriteLogBytes ( xbUInt32 lCnt, const char *p );
153
154 void xbSleep ( xbInt32 lMillisecs );
155
156 xbInt16 GetCmdLineOpt ( xbInt32 lArgc, char **argv, const char *sOptRqst, xbString &sParmOut );
157 xbInt16 GetCmdLineOpt ( xbInt32 lArgc, char **argv, xbString &sOptRqst, xbString &sParmOut );
158
159
160 /* xbase functions */
161 #ifdef XB_FUNCTION_SUPPORT
162 xbInt16 ABS( xbDouble dIn, xbDouble &dOut );
163 xbInt16 ALLTRIM( const xbString &sIn, xbString &sOut );
164 xbInt16 ASC( const xbString &s, xbDouble &dAscOut );
165 xbInt16 AT( const xbString &sSrchFor, const xbString &sBase, xbDouble &dPos );
166 xbInt16 CDOW( xbDate &dInDate, xbString &sOutDow );
167 xbInt16 CHR( xbDouble dAsciCd, xbString &sOut );
168 xbInt16 CMONTH( xbDate &dInDate, xbString &sOutMonth );
169 xbInt16 CTOD( const xbString &sInDate, xbDate &dOutDate );
170 xbInt16 DATE( xbDate &dOutDate );
171 xbInt16 DAY( const xbDate &dInDate, xbDouble &dOutDay );
172 xbInt16 DEL( xbDbf * d, xbString &sOut, xbInt16 iRecBufSw = 0 );
173 xbInt16 DELETED( xbDbf * d, xbBool &bOut, xbInt16 iRecBufSw = 0 );
174 xbInt16 DESCEND( const xbString &sIn, xbString &sOut );
175 xbInt16 DESCEND( const xbDate &dInDate, xbDate &dOutDate );
176 xbInt16 DESCEND( const xbDouble dIn, xbDouble &dsOut );
177 xbInt16 DOW( const xbDate &sInDate, xbDouble &dDowOut );
178 xbInt16 DTOC( xbDate &dInDate, xbString &sOutFmtDate );
179 xbInt16 DTOS( xbDate &dInDate, xbString &sOutFmtDate );
180 xbInt16 EXP( xbDouble dIn, xbDouble &dOut );
181 xbInt16 IIF( xbBool bResult, const xbString &sTrueResult, const xbString &sFalseResult, xbString &sResult );
182 xbInt16 INT( xbDouble dIn, xbDouble &dOut );
183 xbInt16 ISALPHA( const xbString &s, xbBool &bResult );
184 xbInt16 ISLOWER( const xbString &s, xbBool &bResult );
185 xbInt16 ISUPPER( const xbString &s, xbBool &bResult );
186 xbInt16 LEFT( const xbString &sIn, xbUInt32 lCharCnt, xbString &sOut );
187 xbInt16 LEN( const xbString &sIn, xbDouble &dLen );
188 xbInt16 LOG( xbDouble dIn, xbDouble &dOut );
189 xbInt16 LOWER( const xbString &sIn, xbString &sOut );
190 xbInt16 LTRIM( const xbString &sIn, xbString & sOut );
191 xbInt16 MAX( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut );
192 xbInt16 MIN( xbDouble dIn1, xbDouble dIn2, xbDouble &dOut );
193 xbInt16 MONTH( xbDate &dInDate, xbDouble &dMonthOut );
194 xbInt16 RECCOUNT( xbDbf * d, xbDouble &dRecOut );
195 xbInt16 RECNO( xbDbf * d, xbDouble &dRecOut );
196 xbInt16 REPLICATE( const xbString &sIn, xbUInt32 ulRepCnt, xbString &sOut );
197 xbInt16 RIGHT( const xbString &sIn, xbUInt32 iCharCnt, xbString &sOut );
198 xbInt16 RTRIM( const xbString &sIn, xbString &sOut );
199 xbInt16 SPACE( xbInt32 lCnt, xbString &sOut );
200 xbInt16 SQRT( xbDouble dBase, xbDouble &dSqrRt );
201 xbInt16 STOD( const xbString &sIn, xbDate &sDateOut );
202 xbInt16 STR( xbDouble dIn, xbString &sOut );
203 xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbString &sOut );
204 xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut );
205 xbInt16 STR( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sPadChar, xbString &sOut );
206 xbInt16 STRZERO( xbDouble dIn, xbUInt32 ulLen, xbUInt32 ulDec, xbString &sOut );
207 xbInt16 SUBSTR( const xbString &sIn, xbUInt32 ulStartPos, xbUInt32 ulLen, xbString &sOut );
208 xbInt16 TRIM( const xbString &sIn, xbString &sOut );
209 xbInt16 UPPER( const xbString &sIn, xbString &sOut );
210 xbInt16 VAL( const xbString &sIn, xbDouble &dOut );
211 xbInt16 YEAR( xbDate &dInDate, xbDouble &dOutYear );
212 #endif
213
214 protected:
215 friend class xbBcd;
216 friend class xbExp;
217
218 #ifdef XB_BLOCKREAD_SUPPORT
219 friend class xbBlockRead;
220 #endif // XB_BLOCKREAD_SUPPORT
221
222
223 xbInt16 GetFunctionInfo( const xbString &sExpLine, char &cReturnType, xbInt16 &iReturnLenCalc, xbInt32 &lReturnLenVal ) const;
224 static xbInt16 xbMemcmp( const unsigned char *s1, const unsigned char *s2, size_t n );
225
226 private:
227
228#ifdef XB_LOGGING_SUPPORT
229 xbLog *xLog;
230#endif
231
232};
233
234} /* namespace xb */
235#endif /* __XB_DBLIST_H__ */
xbDate class.
Definition: xbdate.h:62
Base class for handling dbf files/tables.
Definition: xbdbf.h:150
Class for handling string data.
Definition: xbstring.h:50
Definition: xbtblmgr.h:39
xbXbase class.
Definition: xbxbase.h:123
xbInt16 OpenHighestVersion(const xbString &sTableName, const xbString &sAlias, xbDbf &dbf, int dummy)
xbInt16 GetFunctionInfo(const xbString &sExpLine, char &cReturnType, xbInt16 &iReturnLenCalc, xbInt32 &lReturnLenVal) const
size_t GetLogSize() const
Definition: xbdate.cpp:19
double xbDouble
Definition: xbtypes.h:23
class XBDLLEXPORT xbLog
Definition: xbxbase.h:26
class XBDLLEXPORT xbXBase
Definition: xbssv.h:27
short int xbBool
Definition: xbtypes.h:24