1 /*************** TabSys H Declares Source Code File (.H) ***************/
2 /*  Name: TABSYS.H    Version 2.3                                      */
3 /*                                                                     */
4 /*  (C) Copyright to the author Olivier BERTRAND          2004-2014    */
5 /*                                                                     */
6 /*  This file contains the XDB system tables classes declares.         */
7 /***********************************************************************/
8 typedef class INIDEF *PINIDEF;
9 typedef class TDBINI *PTDBINI;
10 typedef class INICOL *PINICOL;
11 typedef class TDBXIN *PTDBXIN;
12 typedef class XINCOL *PXINCOL;
13 
14 /* --------------------------- INI classes --------------------------- */
15 
16 /***********************************************************************/
17 /*  INI, XDB and XCL tables.                                           */
18 /***********************************************************************/
19 class DllExport INIDEF : public TABDEF {      /* INI table description */
20   friend class TDBINI;
21   friend class TDBXIN;
22   friend class TDBXTB;
23   friend class TDBRTB;
24   friend class TDBXCL;
25  public:
26   // Constructor
27   INIDEF(void);
28 
29   // Implementation
GetType(void)30   virtual const char *GetType(void) {return "INI";}
31 
32   // Methods
33   virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
34   virtual PTDB GetTable(PGLOBAL g, MODE m);
35 
36  protected:
37   // Members
38   char   *Fn;                 /* Path/Name of corresponding file       */
39   char   *Xname;              /* The eventual table name               */
40   char    Layout;             /* R: Row, C: Column                     */
41   int     Ln;                 /* Length of section list buffer         */
42   }; // end of INIDEF
43 
44 /***********************************************************************/
45 /*  This is the class declaration for the INI tables.                  */
46 /*  These are tables represented by a INI like file.                   */
47 /***********************************************************************/
48 class TDBINI : public TDBASE {
49   friend class INICOL;
50  public:
51   // Constructor
52   TDBINI(PINIDEF tdp);
53   TDBINI(PTDBINI tdbp);
54 
55   // Implementation
GetAmType(void)56   virtual AMT   GetAmType(void) {return TYPE_AM_INI;}
Duplicate(PGLOBAL g)57   virtual PTDB  Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
58 
59   // Methods
60   virtual PTDB  Clone(PTABS t);
GetRecpos(void)61   virtual int   GetRecpos(void) {return N;}
GetProgCur(void)62   virtual int   GetProgCur(void) {return N;}
63 //virtual int   GetAffectedRows(void) {return 0;}
GetFile(PGLOBAL g)64   virtual PCSZ  GetFile(PGLOBAL g) {return Ifile;}
SetFile(PGLOBAL g,PCSZ fn)65   virtual void  SetFile(PGLOBAL g, PCSZ fn) {Ifile = fn;}
ResetDB(void)66   virtual void  ResetDB(void) {Seclist = Section = NULL; N = 0;}
ResetSize(void)67   virtual void  ResetSize(void) {MaxSize = -1; Seclist = NULL;}
68   virtual int   RowNumber(PGLOBAL g, bool b = false) {return N;}
69           char *GetSeclist(PGLOBAL g);
70 
71   // Database routines
72   virtual PCOL  MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
73   virtual int   Cardinality(PGLOBAL g);
74   virtual int   GetMaxSize(PGLOBAL g);
75   virtual bool  OpenDB(PGLOBAL g);
76   virtual int   ReadDB(PGLOBAL g);
77   virtual int   WriteDB(PGLOBAL g);
78   virtual int   DeleteDB(PGLOBAL g, int irc);
79   virtual void  CloseDB(PGLOBAL g);
80 
81  protected:
82   // Members
83   PCSZ  Ifile;                               // The INI file
84   char *Seclist;                             // The section list
85   char *Section;                             // The current section
86   int   Seclen;                              // Length of seclist buffer
87   int   N;                                   // The current section index
88   }; // end of class TDBINI
89 
90 /***********************************************************************/
91 /*  Class INICOL: XDB table access method column descriptor.           */
92 /***********************************************************************/
93 class INICOL : public COLBLK {
94  public:
95   // Constructors
96   INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "INI");
97   INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
98 
99   // Implementation
GetAmType(void)100   virtual int  GetAmType(void) {return TYPE_AM_INI;}
SetTo_Val(PVAL valp)101   virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
102 
103   // Methods
104   virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
105   virtual void ReadColumn(PGLOBAL g);
106   virtual void WriteColumn(PGLOBAL g);
107   virtual void AllocBuf(PGLOBAL g);
108 
109  protected:
110   // Default constructor not to be used
INICOL(void)111   INICOL(void) {}
112 
113   // Members
114   char *Valbuf;                   // To the key value buffer
115   int   Flag;                     // Tells what set in value
116   int   Long;                     // Buffer length
117   PVAL  To_Val;                  // To value used for Update/Insert
118   }; // end of class INICOL
119 
120 /* --------------------------- XINI class ---------------------------- */
121 
122 /***********************************************************************/
123 /*  This is the class declaration for the XINI tables.                 */
124 /*  These are tables represented by a INI like file                    */
125 /*  having 3 columns Section, Key, and Value.                          */
126 /***********************************************************************/
127 class TDBXIN : public TDBINI {
128   friend class XINCOL;
129  public:
130   // Constructor
131   TDBXIN(PINIDEF tdp);
132   TDBXIN(PTDBXIN tdbp);
133 
134   // Implementation
GetAmType(void)135   virtual AMT   GetAmType(void) {return TYPE_AM_INI;}
Duplicate(PGLOBAL g)136   virtual PTDB  Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
137 
138   // Methods
139   virtual PTDB  Clone(PTABS t);
140   virtual int   GetRecpos(void);
141   virtual bool  SetRecpos(PGLOBAL g, int recpos);
ResetDB(void)142   virtual void  ResetDB(void)
143                 {Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
144           char *GetKeylist(PGLOBAL g, char *sec);
145 
146   // Database routines
147   virtual PCOL  MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
148   virtual int   Cardinality(PGLOBAL g);
149   virtual bool  OpenDB(PGLOBAL g);
150   virtual int   ReadDB(PGLOBAL g);
151   virtual int   WriteDB(PGLOBAL g);
152   virtual int   DeleteDB(PGLOBAL g, int irc);
153 
154  protected:
155   // Members
156   char *Keylist;                             // The key list
157   char *Keycur;                              // The current key
158   int   Keylen;                               // Length of keylist buffer
159   short Oldsec;                               // Last current section
160   }; // end of class TDBXIN
161 
162 /***********************************************************************/
163 /*  Class XINCOL: XIN table access method column descriptor.           */
164 /***********************************************************************/
165 class XINCOL : public INICOL {
166  public:
167   // Constructors
168   XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "INI");
169   XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
170 
171   // Implementation
172 
173   // Methods
174   virtual void ReadColumn(PGLOBAL g);
175   virtual void WriteColumn(PGLOBAL g);
176 
177  protected:
178   // Default constructor not to be used
XINCOL(void)179   XINCOL(void) {}
180 
181   // Members
182   }; // end of class XINICOL
183