summaryrefslogtreecommitdiffstats
path: root/storage/connect/tabsys.h
blob: 0c6017af177ee0d9d91122d3062b25a9e403e581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*************** TabSys H Declares Source Code File (.H) ***************/
/*  Name: TABSYS.H    Version 2.3                                      */
/*                                                                     */
/*  (C) Copyright to the author Olivier BERTRAND          2004-2014    */
/*                                                                     */
/*  This file contains the XDB system tables classes declares.         */
/***********************************************************************/
typedef class INIDEF *PINIDEF;
typedef class TDBINI *PTDBINI;
typedef class INICOL *PINICOL;
typedef class TDBXIN *PTDBXIN;
typedef class XINCOL *PXINCOL;

/* --------------------------- INI classes --------------------------- */

/***********************************************************************/
/*  INI, XDB and XCL tables.                                           */
/***********************************************************************/
class DllExport INIDEF : public TABDEF {      /* INI table description */
  friend class TDBINI;
  friend class TDBXIN;
  friend class TDBXTB;
  friend class TDBRTB;
  friend class TDBXCL;
 public:
  // Constructor
  INIDEF(void);

  // Implementation
  virtual const char *GetType(void) {return "INI";}

  // Methods
  virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
  virtual PTDB GetTable(PGLOBAL g, MODE m);

 protected:
  // Members
  char   *Fn;                 /* Path/Name of corresponding file       */
  char   *Xname;              /* The eventual table name               */
  char    Layout;             /* R: Row, C: Column                     */
  int     Ln;                 /* Length of section list buffer         */
  }; // end of INIDEF

/***********************************************************************/
/*  This is the class declaration for the INI tables.                  */
/*  These are tables represented by a INI like file.                   */
/***********************************************************************/
class TDBINI : public TDBASE {
  friend class INICOL;
 public:
  // Constructor
  TDBINI(PINIDEF tdp);
  TDBINI(PTDBINI tdbp);

  // Implementation
  virtual AMT   GetAmType(void) {return TYPE_AM_INI;}
  virtual PTDB  Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}

  // Methods
  virtual PTDB  Clone(PTABS t);
  virtual int   GetRecpos(void) {return N;}
  virtual int   GetProgCur(void) {return N;}
//virtual int   GetAffectedRows(void) {return 0;}
  virtual PCSZ  GetFile(PGLOBAL g) {return Ifile;}
  virtual void  SetFile(PGLOBAL g, PCSZ fn) {Ifile = fn;}
  virtual void  ResetDB(void) {Seclist = Section = NULL; N = 0;}
  virtual void  ResetSize(void) {MaxSize = -1; Seclist = NULL;}
  virtual int   RowNumber(PGLOBAL g, bool b = false) {return N;}
          char *GetSeclist(PGLOBAL g);

  // Database routines
  virtual PCOL  MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
  virtual int   Cardinality(PGLOBAL g);
  virtual int   GetMaxSize(PGLOBAL g);
  virtual bool  OpenDB(PGLOBAL g);
  virtual int   ReadDB(PGLOBAL g);
  virtual int   WriteDB(PGLOBAL g);
  virtual int   DeleteDB(PGLOBAL g, int irc);
  virtual void  CloseDB(PGLOBAL g);

 protected:
  // Members
  PCSZ  Ifile;                               // The INI file
  char *Seclist;                             // The section list
  char *Section;                             // The current section
  int   Seclen;                              // Length of seclist buffer
  int   N;                                   // The current section index
  }; // end of class TDBINI

/***********************************************************************/
/*  Class INICOL: XDB table access method column descriptor.           */
/***********************************************************************/
class INICOL : public COLBLK {
 public:
  // Constructors
  INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "INI");
  INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process

  // Implementation
  virtual int  GetAmType(void) {return TYPE_AM_INI;}
  virtual void SetTo_Val(PVAL valp) {To_Val = valp;}

  // Methods
  virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
  virtual void ReadColumn(PGLOBAL g);
  virtual void WriteColumn(PGLOBAL g);
  virtual void AllocBuf(PGLOBAL g);

 protected:
  // Default constructor not to be used
  INICOL(void) {}

  // Members
  char *Valbuf;                   // To the key value buffer
  int   Flag;                     // Tells what set in value
  int   Long;                     // Buffer length
  PVAL  To_Val;                  // To value used for Update/Insert
  }; // end of class INICOL

/* --------------------------- XINI class ---------------------------- */

/***********************************************************************/
/*  This is the class declaration for the XINI tables.                 */
/*  These are tables represented by a INI like file                    */
/*  having 3 columns Section, Key, and Value.                          */
/***********************************************************************/
class TDBXIN : public TDBINI {
  friend class XINCOL;
 public:
  // Constructor
  TDBXIN(PINIDEF tdp);
  TDBXIN(PTDBXIN tdbp);

  // Implementation
  virtual AMT   GetAmType(void) {return TYPE_AM_INI;}
  virtual PTDB  Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}

  // Methods
  virtual PTDB  Clone(PTABS t);
  virtual int   GetRecpos(void);
  virtual bool  SetRecpos(PGLOBAL g, int recpos);
  virtual void  ResetDB(void)
                {Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
          char *GetKeylist(PGLOBAL g, char *sec);

  // Database routines
  virtual PCOL  MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
  virtual int   Cardinality(PGLOBAL g);
  virtual bool  OpenDB(PGLOBAL g);
  virtual int   ReadDB(PGLOBAL g);
  virtual int   WriteDB(PGLOBAL g);
  virtual int   DeleteDB(PGLOBAL g, int irc);

 protected:
  // Members
  char *Keylist;                             // The key list
  char *Keycur;                              // The current key
  int   Keylen;                               // Length of keylist buffer
  short Oldsec;                               // Last current section
  }; // end of class TDBXIN

/***********************************************************************/
/*  Class XINCOL: XIN table access method column descriptor.           */
/***********************************************************************/
class XINCOL : public INICOL {
 public:
  // Constructors
  XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am = "INI");
  XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process

  // Implementation

  // Methods
  virtual void ReadColumn(PGLOBAL g);
  virtual void WriteColumn(PGLOBAL g);

 protected:
  // Default constructor not to be used
  XINCOL(void) {}

  // Members
  }; // end of class XINICOL