1 /***************** FilAmDbf H Declares Source Code File (.H) ****************/
2 /*  Name: filamdbf.h    Version 1.4                                         */
3 /*                                                                          */
4 /*  (C) Copyright to the author Olivier BERTRAND          2005-2014         */
5 /*                                                                          */
6 /*  This file contains the DBF file access method classes declares.         */
7 /****************************************************************************/
8 
9 #ifndef __FILAMDBF_H
10 #define __FILAMDBF_H
11 
12 #include "filamfix.h"
13 #include "filamap.h"
14 
15 typedef class DBFBASE *PDBF;
16 typedef class DBFFAM  *PDBFFAM;
17 typedef class DBMFAM  *PDBMFAM;
18 
19 /****************************************************************************/
20 /*  Functions used externally.                                              */
21 /****************************************************************************/
22 PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, PTOS tiop, bool info);
23 
24 /****************************************************************************/
25 /*  This is the base class for dBASE file access methods.                   */
26 /****************************************************************************/
27 class DllExport DBFBASE {
28  public:
29   // Constructors
30   DBFBASE(PDOSDEF tdp);
31   DBFBASE(PDBF txfp);
32 
33   // Implementation
34   int  ScanHeader(PGLOBAL g, PCSZ fname, int lrecl, int *rlen, PCSZ defpath);
35 
36  protected:
37   // Default constructor, not to be used
DBFBASE(void)38   DBFBASE(void) {}
39 
40   // Members
41   int  Records;                     /*  records in the file                 */
42   bool Accept;                      /*  true if bad lines are accepted      */
43   int  Nerr;                        /*  Number of bad records               */
44   int  Maxerr;                      /*  Maximum number of bad records       */
45   int  ReadMode;                    /*  1: ALL 2: DEL 0: NOT DEL            */
46   }; // end of class DBFBASE
47 
48 /****************************************************************************/
49 /*  This is the DOS/UNIX Access Method class declaration for DBase files.   */
50 /****************************************************************************/
51 class DllExport DBFFAM : public FIXFAM, public DBFBASE {
52  public:
53   // Constructors
DBFFAM(PDOSDEF tdp)54   DBFFAM(PDOSDEF tdp) : FIXFAM(tdp), DBFBASE(tdp) {}
DBFFAM(PDBFFAM txfp)55   DBFFAM(PDBFFAM txfp) : FIXFAM(txfp), DBFBASE((PDBF)txfp) {}
56 
57   // Implementation
GetAmType(void)58   virtual AMT  GetAmType(void) {return TYPE_AM_DBF;}
Duplicate(PGLOBAL g)59   virtual PTXF Duplicate(PGLOBAL g)
60                 {return (PTXF)new(g) DBFFAM(this);}
61 
62   // Methods
GetNerr(void)63   virtual int  GetNerr(void) {return Nerr;}
64   virtual int  Cardinality(PGLOBAL g);
65   virtual bool OpenTableFile(PGLOBAL g);
66   virtual bool AllocateBuffer(PGLOBAL g);
67   virtual void ResetBuffer(PGLOBAL g);
68   virtual int  ReadBuffer(PGLOBAL g);
69   virtual int  DeleteRecords(PGLOBAL g, int irc);
70   virtual void CloseTableFile(PGLOBAL g, bool abort);
71   virtual void Rewind(void);
72 
73  protected:
74   virtual bool CopyHeader(PGLOBAL g);
75 //virtual int  InitDelete(PGLOBAL g, int fpos, int spos);
76 
77   // Members
78   }; // end of class DBFFAM
79 
80 /****************************************************************************/
81 /*  This is the DOS/UNIX Access Method class declaration for DBase files    */
82 /*  using file mapping to access the file.                                  */
83 /****************************************************************************/
84 class DllExport DBMFAM : public MPXFAM, public DBFBASE {
85  public:
86   // Constructors
DBMFAM(PDOSDEF tdp)87   DBMFAM(PDOSDEF tdp) : MPXFAM(tdp), DBFBASE(tdp) {}
DBMFAM(PDBMFAM txfp)88   DBMFAM(PDBMFAM txfp) : MPXFAM(txfp), DBFBASE((PDBF)txfp) {}
89 
90   // Implementation
GetAmType(void)91   virtual AMT  GetAmType(void) {return TYPE_AM_DBF;}
Duplicate(PGLOBAL g)92   virtual PTXF Duplicate(PGLOBAL g)
93                 {return (PTXF)new(g) DBMFAM(this);}
94   virtual  int  GetDelRows(void);
95 
96   // Methods
GetNerr(void)97   virtual int  GetNerr(void) {return Nerr;}
98   virtual int  Cardinality(PGLOBAL g);
99   virtual bool AllocateBuffer(PGLOBAL g);
100   virtual int  ReadBuffer(PGLOBAL g);
101   virtual int  DeleteRecords(PGLOBAL g, int irc);
102   virtual void Rewind(void);
103 
104  protected:
105   // Members
106   }; // end of class DBFFAM
107 
108 #endif // __FILAMDBF_H
109