1/*************** TabDos H Declares Source Code File (.H) ***************/
2/* Name: TABFIX.H Version 2.4 */
3/* */
4/* (C) Copyright to the author Olivier BERTRAND 1999-2015 */
5/* */
6/* This file contains the TDBFIX and (FIX/BIN)COL classes declares. */
7/***********************************************************************/
8#ifndef __TABFIX__
9#define __TABFIX__
10#include "tabdos.h" /* Base class declares */
11#include "filamdbf.h"
12
13typedef class FIXCOL *PFIXCOL;
14typedef class BINCOL *PBINCOL;
15typedef class TXTFAM *PTXF;
16
17/***********************************************************************/
18/* This is the DOS/UNIX Access Method class declaration for files */
19/* that are standard files with columns starting at fixed offset. */
20/* This class is for fixed formatted files. */
21/***********************************************************************/
22class DllExport TDBFIX : public TDBDOS {
23 friend class FIXCOL;
24 friend class BINCOL;
25 public:
26 // Constructor
27 TDBFIX(PDOSDEF tdp, PTXF txfp);
28 TDBFIX(PGLOBAL g, PTDBFIX tdbp);
29
30 // Implementation
31 virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
32 virtual void RestoreNrec(void);
33 virtual PTDB Duplicate(PGLOBAL g)
34 {return (PTDB)new(g) TDBFIX(g, this);}
35
36 // Methods
37 virtual PTDB Clone(PTABS t);
38 virtual void ResetDB(void);
39 virtual bool IsUsingTemp(PGLOBAL g);
40 virtual int RowNumber(PGLOBAL g, bool b = false);
41 virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
42 virtual void ResetSize(void);
43 virtual int GetBadLines(void) {return Txfp->GetNerr();}
44
45 // Database routines
46 virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
47 virtual int GetProgMax(PGLOBAL g);
48 virtual int Cardinality(PGLOBAL g);
49 virtual int GetMaxSize(PGLOBAL g);
50 virtual bool OpenDB(PGLOBAL g);
51 virtual int WriteDB(PGLOBAL g);
52
53 protected:
54 virtual bool PrepareWriting(PGLOBAL g) {return false;}
55
56 // Members
57 char Teds; /* Binary table default endian setting */
58 }; // end of class TDBFIX
59
60/***********************************************************************/
61/* Class BINCOL: BIN access method column descriptor. */
62/* This A.M. is used for file processed by blocks. */
63/***********************************************************************/
64class DllExport BINCOL : public DOSCOL {
65 friend class TDBFIX;
66 public:
67 // Constructors
68 BINCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PCSZ am = "BIN");
69 BINCOL(BINCOL *colp, PTDB tdbp); // Constructor used in copy process
70
71 // Implementation
72 virtual int GetAmType(void) {return TYPE_AM_BIN;}
73 int GetDeplac(void) {return Deplac;}
74 int GetFileSize(void)
75 {return N ? N : GetTypeSize(Buf_Type, Long);}
76
77 // Methods
78 virtual void ReadColumn(PGLOBAL g);
79 virtual void WriteColumn(PGLOBAL g);
80
81 // Static
82 static void SetEndian(void);
83
84 protected:
85 BINCOL(void) {} // Default constructor not to be used
86
87 // Members
88 static char Endian; // The host endian setting (L or B)
89 char *Buff; // Utility buffer
90 char Eds; // The file endian setting
91 char Fmt; // The converted value format
92 int N; // The number of bytes in the file
93 int M; // The buffer type size
94 int Lim; // Min(N,M)
95 }; // end of class BINCOL
96
97/***********************************************************************/
98/* This is the class declaration for the DBF columns catalog table. */
99/***********************************************************************/
100class TDBDCL : public TDBCAT {
101 public:
102 // Constructor
103 TDBDCL(PDOSDEF tdp) : TDBCAT(tdp) {Fn = tdp->GetFn();}
104
105 protected:
106 // Specific routines
107 virtual PQRYRES GetResult(PGLOBAL g)
108 {return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, false);}
109
110 // Members
111 PCSZ Fn; // The DBF file (path) name
112 }; // end of class TDBOCL
113
114
115#endif // __TABFIX__
116