| 1 | /*************** Colblk H Declares Source Code File (.H) ***************/ |
| 2 | /* Name: COLBLK.H Version 1.7 */ |
| 3 | /* */ |
| 4 | /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ |
| 5 | /* */ |
| 6 | /* This file contains the COLBLK and derived classes declares. */ |
| 7 | /***********************************************************************/ |
| 8 | #ifndef __COLBLK__H |
| 9 | #define __COLBLK__H |
| 10 | |
| 11 | /***********************************************************************/ |
| 12 | /* Include required application header files */ |
| 13 | /***********************************************************************/ |
| 14 | #include "xobject.h" |
| 15 | #include "reldef.h" |
| 16 | |
| 17 | /***********************************************************************/ |
| 18 | /* Class COLBLK: Base class for table column descriptors. */ |
| 19 | /***********************************************************************/ |
| 20 | class DllExport COLBLK : public XOBJECT { |
| 21 | friend class TDBPIVOT; |
| 22 | protected: |
| 23 | // Default constructors used by derived classes |
| 24 | COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); |
| 25 | COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process |
| 26 | COLBLK(int) {} // Used when changing a column class in TDBXML |
| 27 | |
| 28 | public: |
| 29 | // Implementation |
| 30 | virtual int GetType(void) {return TYPE_COLBLK;} |
| 31 | virtual int GetResultType(void) {return Buf_Type;} |
| 32 | virtual int GetScale(void) {return Format.Prec;} |
| 33 | virtual int GetPrecision(void) {return Precision;} |
| 34 | virtual int GetLength(void) {return Long;} |
| 35 | virtual int GetLengthEx(void); |
| 36 | virtual int GetAmType() {return TYPE_AM_ERROR;} |
| 37 | virtual void SetOk(void) {Status |= BUF_EMPTY;} |
| 38 | virtual PTDB GetTo_Tdb(void) {return To_Tdb;} |
| 39 | virtual int GetClustered(void) {return 0;} |
| 40 | virtual int IsClustered(void) {return FALSE;} |
| 41 | virtual PSZ GetJpath(PGLOBAL g, bool proj) {return NULL;} |
| 42 | PCOL GetNext(void) {return Next;} |
| 43 | PSZ GetName(void) {return Name;} |
| 44 | int GetIndex(void) {return Index;} |
| 45 | ushort GetColUse(void) {return ColUse;} |
| 46 | int GetOpt(void) {return Opt;} |
| 47 | ushort GetColUse(ushort u) {return (ColUse & u);} |
| 48 | ushort GetStatus(void) {return Status;} |
| 49 | ushort GetStatus(ushort u) {return (Status & u);} |
| 50 | void SetColUse(ushort u) {ColUse = u;} |
| 51 | void SetStatus(ushort u) {Status = u;} |
| 52 | void AddColUse(ushort u) {ColUse |= u;} |
| 53 | void AddStatus(ushort u) {Status |= u;} |
| 54 | void SetNext(PCOL cp) {Next = cp;} |
| 55 | PXCOL GetKcol(void) {return To_Kcol;} |
| 56 | void SetKcol(PXCOL kcp) {To_Kcol = kcp;} |
| 57 | PCOLDEF GetCdp(void) {return Cdp;} |
| 58 | PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;} |
| 59 | PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;} |
| 60 | PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;} |
| 61 | bool IsUnsigned(void) {return Unsigned;} |
| 62 | bool IsVirtual(void) {return Cdp->IsVirtual();} |
| 63 | bool IsNullable(void) {return Nullable;} |
| 64 | void SetNullable(bool b) {Nullable = b;} |
| 65 | |
| 66 | // Methods |
| 67 | virtual void Reset(void); |
| 68 | virtual bool Compare(PXOB xp); |
| 69 | virtual bool SetFormat(PGLOBAL, FORMAT&); |
| 70 | virtual bool IsSpecial(void) {return false;} |
| 71 | virtual bool Eval(PGLOBAL g); |
| 72 | virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
| 73 | virtual void SetTo_Val(PVAL) {} |
| 74 | virtual void ReadColumn(PGLOBAL g); |
| 75 | virtual void WriteColumn(PGLOBAL g); |
| 76 | virtual void Printf(PGLOBAL g, FILE *, uint); |
| 77 | virtual void Prints(PGLOBAL g, char *, uint); |
| 78 | virtual bool VarSize(void) {return false;} |
| 79 | bool InitValue(PGLOBAL g); |
| 80 | |
| 81 | protected: |
| 82 | // Members |
| 83 | PCOL Next; // Next column in table |
| 84 | PSZ Name; // Column name |
| 85 | PCOLDEF Cdp; // To column definition block |
| 86 | PTDB To_Tdb; // Points to Table Descriptor Block |
| 87 | PXCOL To_Kcol; // Points to Xindex matching column |
| 88 | bool Nullable; // True if nullable |
| 89 | bool Unsigned; // True if unsigned |
| 90 | int Index; // Column number in table |
| 91 | int Opt; // Cluster/sort information |
| 92 | int Buf_Type; // Data type |
| 93 | int Long; // Internal length in table |
| 94 | int Precision; // Column length (as for ODBC) |
| 95 | int Freq; // Evaluated ceiling of distinct values |
| 96 | FORMAT Format; // Output format |
| 97 | ushort ColUse; // Column usage |
| 98 | ushort Status; // Column read status |
| 99 | }; // end of class COLBLK |
| 100 | |
| 101 | /***********************************************************************/ |
| 102 | /* Class SPCBLK: Base class for special column descriptors. */ |
| 103 | /***********************************************************************/ |
| 104 | class DllExport SPCBLK : public COLBLK { |
| 105 | public: |
| 106 | // Constructor |
| 107 | SPCBLK(PCOLUMN cp); |
| 108 | |
| 109 | // Implementation |
| 110 | virtual int GetAmType(void) = 0; |
| 111 | virtual bool GetRnm(void) {return false;} |
| 112 | |
| 113 | // Methods |
| 114 | virtual bool IsSpecial(void) {return true;} |
| 115 | virtual void ReadColumn(PGLOBAL g) = 0; |
| 116 | virtual void WriteColumn(PGLOBAL g); |
| 117 | |
| 118 | protected: |
| 119 | // Default constructor not to be used |
| 120 | SPCBLK(void) : COLBLK(1) {} |
| 121 | }; // end of class SPCBLK |
| 122 | |
| 123 | /***********************************************************************/ |
| 124 | /* Class RIDBLK: ROWID special column descriptor. */ |
| 125 | /***********************************************************************/ |
| 126 | class DllExport RIDBLK : public SPCBLK { |
| 127 | public: |
| 128 | // Constructor |
| 129 | RIDBLK(PCOLUMN cp, bool rnm); |
| 130 | |
| 131 | // Implementation |
| 132 | virtual int GetAmType(void) {return TYPE_AM_ROWID;} |
| 133 | virtual bool GetRnm(void) {return Rnm;} |
| 134 | |
| 135 | // Methods |
| 136 | virtual void ReadColumn(PGLOBAL g); |
| 137 | |
| 138 | protected: |
| 139 | bool Rnm; // False for RowID, True for RowNum |
| 140 | }; // end of class RIDBLK |
| 141 | |
| 142 | /***********************************************************************/ |
| 143 | /* Class FIDBLK: FILEID special column descriptor. */ |
| 144 | /***********************************************************************/ |
| 145 | class DllExport FIDBLK : public SPCBLK { |
| 146 | public: |
| 147 | // Constructor |
| 148 | FIDBLK(PCOLUMN cp, OPVAL op); |
| 149 | |
| 150 | // Implementation |
| 151 | virtual int GetAmType(void) {return TYPE_AM_FILID;} |
| 152 | |
| 153 | // Methods |
| 154 | virtual void Reset(void) {} // This is a pseudo constant column |
| 155 | virtual void ReadColumn(PGLOBAL g); |
| 156 | |
| 157 | protected: |
| 158 | PCSZ Fn; // The current To_File of the table |
| 159 | OPVAL Op; // The file part operator |
| 160 | }; // end of class FIDBLK |
| 161 | |
| 162 | /***********************************************************************/ |
| 163 | /* Class TIDBLK: TABID special column descriptor. */ |
| 164 | /***********************************************************************/ |
| 165 | class DllExport TIDBLK : public SPCBLK { |
| 166 | public: |
| 167 | // Constructor |
| 168 | TIDBLK(PCOLUMN cp); |
| 169 | |
| 170 | // Implementation |
| 171 | virtual int GetAmType(void) {return TYPE_AM_TABID;} |
| 172 | |
| 173 | // Methods |
| 174 | virtual void Reset(void) {} // This is a pseudo constant column |
| 175 | virtual void ReadColumn(PGLOBAL g); |
| 176 | |
| 177 | protected: |
| 178 | // Default constructor not to be used |
| 179 | TIDBLK(void) {} |
| 180 | |
| 181 | // Members |
| 182 | PCSZ Tname; // The current table name |
| 183 | }; // end of class TIDBLK |
| 184 | |
| 185 | /***********************************************************************/ |
| 186 | /* Class PRTBLK: PARTID special column descriptor. */ |
| 187 | /***********************************************************************/ |
| 188 | class DllExport PRTBLK : public SPCBLK { |
| 189 | public: |
| 190 | // Constructor |
| 191 | PRTBLK(PCOLUMN cp); |
| 192 | |
| 193 | // Implementation |
| 194 | virtual int GetAmType(void) {return TYPE_AM_PRTID;} |
| 195 | |
| 196 | // Methods |
| 197 | virtual void Reset(void) {} // This is a pseudo constant column |
| 198 | virtual void ReadColumn(PGLOBAL g); |
| 199 | |
| 200 | protected: |
| 201 | // Default constructor not to be used |
| 202 | PRTBLK(void) {} |
| 203 | |
| 204 | // Members |
| 205 | PCSZ Pname; // The current partition name |
| 206 | }; // end of class PRTBLK |
| 207 | |
| 208 | /***********************************************************************/ |
| 209 | /* Class SIDBLK: SERVID special column descriptor. */ |
| 210 | /***********************************************************************/ |
| 211 | class DllExport SIDBLK : public SPCBLK { |
| 212 | public: |
| 213 | // Constructor |
| 214 | SIDBLK(PCOLUMN cp); |
| 215 | |
| 216 | // Implementation |
| 217 | virtual int GetAmType(void) {return TYPE_AM_SRVID;} |
| 218 | |
| 219 | // Methods |
| 220 | virtual void Reset(void) {} // This is a pseudo constant column |
| 221 | virtual void ReadColumn(PGLOBAL g); |
| 222 | |
| 223 | protected: |
| 224 | // Default constructor not to be used |
| 225 | SIDBLK(void) {} |
| 226 | |
| 227 | // Members |
| 228 | PCSZ Sname; // The current server name |
| 229 | }; // end of class SIDBLK |
| 230 | |
| 231 | #endif // __COLBLK__H |
| 232 | |