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