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 13 typedef class FIXCOL *PFIXCOL; 14 typedef class BINCOL *PBINCOL; 15 typedef 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 /***********************************************************************/ 22 class 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 GetAmType(void)31 virtual AMT GetAmType(void) {return TYPE_AM_FIX;} 32 virtual void RestoreNrec(void); Duplicate(PGLOBAL g)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); GetBadLines(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: PrepareWriting(PGLOBAL g)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 /***********************************************************************/ 64 class 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 GetAmType(void)72 virtual int GetAmType(void) {return TYPE_AM_BIN;} GetDeplac(void)73 int GetDeplac(void) {return Deplac;} GetFileSize(void)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: BINCOL(void)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 /***********************************************************************/ 100 class TDBDCL : public TDBCAT { 101 public: 102 // Constructor TDBDCL(PDOSDEF tdp)103 TDBDCL(PDOSDEF tdp) : TDBCAT(tdp) 104 {Fn = tdp->GetFn(); Topt = tdp->GetTopt();} 105 106 protected: 107 // Specific routines GetResult(PGLOBAL g)108 virtual PQRYRES GetResult(PGLOBAL g) 109 {return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Topt, false);} 110 111 // Members 112 PCSZ Fn; // The DBF file (path) name 113 PTOS Topt; 114 }; // end of class TDBOCL 115 116 117 #endif // __TABFIX__ 118