summaryrefslogtreecommitdiff
path: root/storage/connect/value.h
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2014-03-20 12:05:47 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2014-03-20 12:05:47 +0100
commit7b400a088d049661b9a4dded385ac78923bb0017 (patch)
treebb3ee7bac4454f66ec6f38cf6683f24bc6c065d4 /storage/connect/value.h
parentd67ad26b33ea16a3b59215ef967bdd9b89345e04 (diff)
parente5729127b8a50a0e553fd8b87b2683e4a684dfcc (diff)
downloadmariadb-git-7b400a088d049661b9a4dded385ac78923bb0017.tar.gz
- MRR + Block Indexing
modified: storage/connect/array.h storage/connect/catalog.h storage/connect/colblk.cpp storage/connect/colblk.h storage/connect/connect.cc storage/connect/connect.h storage/connect/domdoc.h storage/connect/filamap.cpp storage/connect/filamap.h storage/connect/filamdbf.h storage/connect/filamfix.cpp storage/connect/filamfix.h storage/connect/filamtxt.cpp storage/connect/filamtxt.h storage/connect/filamvct.cpp storage/connect/filamvct.h storage/connect/filamzip.cpp storage/connect/filamzip.h storage/connect/filter.cpp storage/connect/filter.h storage/connect/global.h storage/connect/ha_connect.cc storage/connect/ha_connect.h storage/connect/myconn.h storage/connect/plgcnx.h storage/connect/plgdbsem.h storage/connect/plgdbutl.cpp storage/connect/plugutil.c storage/connect/preparse.h storage/connect/reldef.cpp storage/connect/reldef.h storage/connect/tabcol.h storage/connect/tabdos.cpp storage/connect/tabdos.h storage/connect/tabfix.cpp storage/connect/tabfmt.cpp storage/connect/tabfmt.h storage/connect/table.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/taboccur.h storage/connect/tabodbc.h storage/connect/tabsys.h storage/connect/tabtbl.h storage/connect/tabutil.h storage/connect/tabvct.cpp storage/connect/tabvct.h storage/connect/tabwmi.h storage/connect/tabxml.h storage/connect/user_connect.cc storage/connect/user_connect.h storage/connect/valblk.cpp storage/connect/valblk.h storage/connect/value.cpp storage/connect/value.h storage/connect/xindex.cpp storage/connect/xindex.h storage/connect/xobject.cpp storage/connect/xobject.h storage/connect/xtable.h
Diffstat (limited to 'storage/connect/value.h')
-rw-r--r--storage/connect/value.h687
1 files changed, 333 insertions, 354 deletions
diff --git a/storage/connect/value.h b/storage/connect/value.h
index 39fee7f73bb..e9a899302c9 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -1,354 +1,333 @@
-/**************** Value H Declares Source Code File (.H) ***************/
-/* Name: VALUE.H Version 2.0 */
-/* */
-/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
-/* */
-/* This file contains the VALUE and derived classes declares. */
-/***********************************************************************/
-#ifndef __VALUE__H__
-#define __VALUE__H__
-
-/***********************************************************************/
-/* Include required application header files */
-/* assert.h is header required when using the assert function. */
-/* block.h is header containing Block global declarations. */
-/***********************************************************************/
-#include "assert.h"
-#include "block.h"
-
-/***********************************************************************/
-/* Types used in some class definitions. */
-/***********************************************************************/
-enum CONV {CNV_ANY = 0, /* Convert to any type */
- CNV_CHAR = 1, /* Convert to character type */
- CNV_NUM = 2}; /* Convert to numeric type */
-
-/***********************************************************************/
-/* Types used in some class definitions. */
-/***********************************************************************/
-class CONSTANT; // For friend setting
-typedef struct _datpar *PDTP; // For DTVAL
-
-
-/***********************************************************************/
-/* Utilities used to test types and to allocated values. */
-/***********************************************************************/
-PVAL AllocateValue(PGLOBAL, void *, short);
-
-// Exported functions
-DllExport PSZ GetTypeName(int);
-DllExport int GetTypeSize(int, int);
-#ifdef ODBC_SUPPORT
-/* This function is exported for use in EOM table type DLLs */
-DllExport int TranslateSQLType(int stp, int prec, int& len, char& v);
-#endif
-DllExport char *GetFormatType(int);
-DllExport int GetFormatType(char);
-DllExport bool IsTypeChar(int type);
-DllExport bool IsTypeNum(int type);
-#if defined(BLK_INDX)
-DllExport int ConvertType(int, int, CONV, bool match = false);
-DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
-#endif // BLK_INDX
-DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
- bool uns = false, PSZ fmt = NULL);
-DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
- bool *minus = NULL, bool *rc = NULL);
-
-/***********************************************************************/
-/* Class VALUE represents a constant or variable of any valid type. */
-/***********************************************************************/
-class DllExport VALUE : public BLOCK {
- friend class CONSTANT; // The only object allowed to use SetConstFormat
- public:
- // Constructors
-
- // Implementation
- virtual bool IsTypeNum(void) = 0;
- virtual bool IsZero(void) = 0;
- virtual bool IsCi(void) {return false;}
- virtual bool IsUnsigned(void) {return Unsigned;}
- virtual void Reset(void) = 0;
- virtual int GetSize(void) = 0;
- virtual int GetValLen(void) = 0;
- virtual int GetValPrec(void) = 0;
- virtual int GetLength(void) {return 1;}
- virtual PSZ GetCharValue(void) {assert(false); return NULL;}
- virtual char GetTinyValue(void) {assert(false); return 0;}
- virtual uchar GetUTinyValue(void) {assert(false); return 0;}
- virtual short GetShortValue(void) {assert(false); return 0;}
- virtual ushort GetUShortValue(void) {assert(false); return 0;}
- virtual int GetIntValue(void) = 0;
- virtual uint GetUIntValue(void) = 0;
- virtual longlong GetBigintValue(void) = 0;
- virtual ulonglong GetUBigintValue(void) = 0;
- virtual double GetFloatValue(void) = 0;
- virtual void *GetTo_Val(void) = 0;
- virtual void SetPrec(int prec) {Prec = prec;}
- bool IsNull(void) {return Null;}
- void SetNull(bool b) {Null = b;}
- bool GetNullable(void) {return Nullable;}
- void SetNullable(bool b) {Nullable = b;}
- int GetType(void) {return Type;}
- int GetClen(void) {return Clen;}
- void SetGlobal(PGLOBAL g) {Global = g;}
-
- // Methods
- virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
- virtual bool SetValue_char(char *p, int n) = 0;
- virtual void SetValue_psz(PSZ s) = 0;
-#if defined(BLK_INDX)
- virtual void SetValue_bool(bool b) {assert(FALSE);}
- virtual int CompareValue(PVAL vp) = 0;
- virtual BYTE TestValue(PVAL vp);
-#endif // BLK_INDX
- virtual void SetValue(char c) {assert(false);}
- virtual void SetValue(uchar c) {assert(false);}
- virtual void SetValue(short i) {assert(false);}
- virtual void SetValue(ushort i) {assert(false);}
- virtual void SetValue(int n) {assert(false);}
- virtual void SetValue(uint n) {assert(false);}
- virtual void SetValue(longlong n) {assert(false);}
- virtual void SetValue(ulonglong n) {assert(false);}
- virtual void SetValue(double f) {assert(false);}
- virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
- virtual void SetBinValue(void *p) = 0;
- virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
- virtual char *ShowValue(char *buf, int len = 0) = 0;
- virtual char *GetCharString(char *p) = 0;
- virtual bool IsEqual(PVAL vp, bool chktype) = 0;
- virtual bool FormatValue(PVAL vp, char *fmt) = 0;
-
- protected:
- virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
- const char *GetXfmt(void);
-
- // Constructor used by derived classes
- VALUE(int type, bool un = false);
-
- // Members
- PGLOBAL Global; // To reduce arglist
- const char *Fmt;
- const char *Xfmt;
- bool Nullable; // True if value can be null
- bool Null; // True if value is null
- bool Unsigned; // True if unsigned
- int Type; // The value type
- int Clen; // Internal value length
- int Prec;
- }; // end of class VALUE
-
-/***********************************************************************/
-/* Class TYPVAL: represents a typed value. */
-/***********************************************************************/
-template <class TYPE>
-class DllExport TYPVAL : public VALUE {
- public:
- // Constructor
- TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
-
- // Implementation
- virtual bool IsTypeNum(void) {return true;}
- virtual bool IsZero(void) {return Tval == 0;}
- virtual void Reset(void) {Tval = 0;}
- virtual int GetValLen(void);
- virtual int GetValPrec() {return 0;}
- virtual int GetSize(void) {return sizeof(TYPE);}
- virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
- virtual char GetTinyValue(void) {return (char)Tval;}
- virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
- virtual short GetShortValue(void) {return (short)Tval;}
- virtual ushort GetUShortValue(void) {return (ushort)Tval;}
- virtual int GetIntValue(void) {return (int)Tval;}
- virtual uint GetUIntValue(void) {return (uint)Tval;}
- virtual longlong GetBigintValue(void) {return (longlong)Tval;}
- virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
- virtual double GetFloatValue(void) {return (double)Tval;}
- virtual void *GetTo_Val(void) {return &Tval;}
-
- // Methods
- virtual bool SetValue_pval(PVAL valp, bool chktype);
- virtual bool SetValue_char(char *p, int n);
- virtual void SetValue_psz(PSZ s);
-#if defined(BLK_INDX)
- virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
- virtual int CompareValue(PVAL vp);
-#endif // BLK_INDX
- virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
- virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
- virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
- virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;}
- virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;}
- virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;}
- virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;}
- virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;}
- virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;}
- virtual void SetValue_pvblk(PVBLK blk, int n);
- virtual void SetBinValue(void *p);
- virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual char *ShowValue(char *buf, int);
- virtual char *GetCharString(char *p);
- virtual bool IsEqual(PVAL vp, bool chktype);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
- virtual bool FormatValue(PVAL vp, char *fmt);
- virtual void Print(PGLOBAL g, FILE *, uint);
- virtual void Print(PGLOBAL g, char *, uint);
-
- protected:
- // Default constructor not to be used
- TYPVAL(void) : VALUE(TYPE_ERROR) {}
-
- // Specialized functions
- static ulonglong MaxVal(void);
- TYPE GetTypedValue(PVAL vp);
- TYPE GetTypedValue(PVBLK blk, int n);
-// TYPE GetTypedValue(PSZ s);
-
- // Members
- TYPE Tval;
- }; // end of class TYPVAL
-
-/***********************************************************************/
-/* Specific STRING class. */
-/***********************************************************************/
-template <>
-class DllExport TYPVAL<PSZ>: public VALUE {
- public:
- // Constructors
- TYPVAL(PSZ s);
- TYPVAL(PGLOBAL g, PSZ s, int n, int c);
-
- // Implementation
- virtual bool IsTypeNum(void) {return false;}
- virtual bool IsZero(void) {return *Strp == 0;}
- virtual void Reset(void) {*Strp = 0;}
- virtual int GetValLen(void) {return Len;};
- virtual int GetValPrec() {return (Ci) ? 1 : 0;}
- virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
- virtual PSZ GetCharValue(void) {return Strp;}
- virtual char GetTinyValue(void);
- virtual uchar GetUTinyValue(void);
- virtual short GetShortValue(void);
- virtual ushort GetUShortValue(void);
- virtual int GetIntValue(void);
- virtual uint GetUIntValue(void);
- virtual longlong GetBigintValue(void);
- virtual ulonglong GetUBigintValue(void);
- virtual double GetFloatValue(void) {return atof(Strp);}
- virtual void *GetTo_Val(void) {return Strp;}
- virtual void SetPrec(int prec) {Ci = prec != 0;}
-
- // Methods
- virtual bool SetValue_pval(PVAL valp, bool chktype);
- virtual bool SetValue_char(char *p, int n);
- virtual void SetValue_psz(PSZ s);
- virtual void SetValue_pvblk(PVBLK blk, int n);
- virtual void SetValue(char c);
- virtual void SetValue(uchar c);
- virtual void SetValue(short i);
- virtual void SetValue(ushort i);
- virtual void SetValue(int n);
- virtual void SetValue(uint n);
- virtual void SetValue(longlong n);
- virtual void SetValue(ulonglong n);
- virtual void SetValue(double f);
- virtual void SetBinValue(void *p);
-#if defined(BLK_INDX)
- virtual int CompareValue(PVAL vp);
-#endif // BLK_INDX
- virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual char *ShowValue(char *buf, int);
- virtual char *GetCharString(char *p);
- virtual bool IsEqual(PVAL vp, bool chktype);
- virtual bool FormatValue(PVAL vp, char *fmt);
- virtual bool SetConstFormat(PGLOBAL, FORMAT&);
-
- // Members
- PSZ Strp;
- bool Ci; // true if case insensitive
- int Len;
- }; // end of class TYPVAL<PSZ>
-
-/***********************************************************************/
-/* Specific DECIMAL class. */
-/***********************************************************************/
-class DllExport DECVAL: public TYPVAL<PSZ> {
- public:
- // Constructors
- DECVAL(PSZ s);
- DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns);
-
- // Implementation
- virtual bool IsTypeNum(void) {return true;}
- virtual bool IsZero(void);
- virtual void Reset(void);
- virtual int GetValPrec() {return Prec;}
-
- // Methods
-//virtual bool SetValue_pval(PVAL valp, bool chktype);
-//virtual bool SetValue_char(char *p, int n);
-//virtual void SetValue_psz(PSZ s);
-//virtual void SetValue_pvblk(PVBLK blk, int n);
-//virtual void SetBinValue(void *p);
- virtual bool GetBinValue(void *buf, int buflen, bool go);
- virtual char *ShowValue(char *buf, int);
-//virtual char *GetCharString(char *p);
- virtual bool IsEqual(PVAL vp, bool chktype);
-#if defined(BLK_INDX)
- virtual int CompareValue(PVAL vp);
-#endif // BLK_INDX
-//virtual bool FormatValue(PVAL vp, char *fmt);
-//virtual bool SetConstFormat(PGLOBAL, FORMAT&);
-
- // Members
- }; // end of class DECVAL
-
-/***********************************************************************/
-/* Class DTVAL: represents a time stamp value. */
-/***********************************************************************/
-class DllExport DTVAL : public TYPVAL<int> {
- public:
- // Constructors
- DTVAL(PGLOBAL g, int n, int p, PSZ fmt);
- DTVAL(PGLOBAL g, PSZ s, int n);
- DTVAL(PGLOBAL g, short i);
- DTVAL(PGLOBAL g, int n);
- DTVAL(PGLOBAL g, longlong n);
- DTVAL(PGLOBAL g, double f);
-
- // Implementation
- virtual bool SetValue_pval(PVAL valp, bool chktype);
- virtual bool SetValue_char(char *p, int n);
- virtual void SetValue_psz(PSZ s);
- virtual void SetValue_pvblk(PVBLK blk, int n);
- virtual char *GetCharString(char *p);
- virtual char *ShowValue(char *buf, int);
- virtual bool FormatValue(PVAL vp, char *fmt);
- bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
- bool SetFormat(PGLOBAL g, PVAL valp);
- bool IsFormatted(void) {return Pdtp != NULL;}
-// bool GetTmMember(OPVAL op, int& mval);
-// bool DateDiff(DTVAL *dtp, OPVAL op, int& tdif);
- bool MakeTime(struct tm *ptm);
- static void SetTimeShift(void);
- static int GetShift(void) {return Shift;}
-
- // Methods
- bool MakeDate(PGLOBAL g, int *val, int nval);
-// bool WeekNum(PGLOBAL g, int& nval);
-
- struct tm *GetGmTime(struct tm *);
-
- protected:
- // Default constructor not to be used
- DTVAL(void) : TYPVAL<int>() {}
-
- // Members
- static int Shift; // Time zone shift in seconds
- PDTP Pdtp; // To the DATPAR structure
- char *Sdate; // Utility char buffer
- int DefYear; // Used by ExtractDate
- int Len; // Used by CHAR scalar function
- }; // end of class DTVAL
-
-#endif // __VALUE__H__
+/**************** Value H Declares Source Code File (.H) ***************/
+/* Name: VALUE.H Version 2.0 */
+/* */
+/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
+/* */
+/* This file contains the VALUE and derived classes declares. */
+/***********************************************************************/
+#ifndef __VALUE__H__
+#define __VALUE__H__
+
+/***********************************************************************/
+/* Include required application header files */
+/* assert.h is header required when using the assert function. */
+/* block.h is header containing Block global declarations. */
+/***********************************************************************/
+#include "assert.h"
+#include "block.h"
+
+/***********************************************************************/
+/* Types used in some class definitions. */
+/***********************************************************************/
+enum CONV {CNV_ANY = 0, /* Convert to any type */
+ CNV_CHAR = 1, /* Convert to character type */
+ CNV_NUM = 2}; /* Convert to numeric type */
+
+/***********************************************************************/
+/* Types used in some class definitions. */
+/***********************************************************************/
+class CONSTANT; // For friend setting
+typedef struct _datpar *PDTP; // For DTVAL
+
+
+/***********************************************************************/
+/* Utilities used to test types and to allocated values. */
+/***********************************************************************/
+PVAL AllocateValue(PGLOBAL, void *, short);
+
+// Exported functions
+DllExport PSZ GetTypeName(int);
+DllExport int GetTypeSize(int, int);
+#ifdef ODBC_SUPPORT
+/* This function is exported for use in EOM table type DLLs */
+DllExport int TranslateSQLType(int stp, int prec, int& len, char& v);
+#endif
+DllExport char *GetFormatType(int);
+DllExport int GetFormatType(char);
+DllExport bool IsTypeChar(int type);
+DllExport bool IsTypeNum(int type);
+DllExport int ConvertType(int, int, CONV, bool match = false);
+DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
+DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
+ bool uns = false, PSZ fmt = NULL);
+DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
+ bool *minus = NULL, bool *rc = NULL);
+
+/***********************************************************************/
+/* Class VALUE represents a constant or variable of any valid type. */
+/***********************************************************************/
+class DllExport VALUE : public BLOCK {
+ friend class CONSTANT; // The only object allowed to use SetConstFormat
+ public:
+ // Constructors
+
+ // Implementation
+ virtual bool IsTypeNum(void) = 0;
+ virtual bool IsZero(void) = 0;
+ virtual bool IsCi(void) {return false;}
+ virtual bool IsUnsigned(void) {return Unsigned;}
+ virtual void Reset(void) = 0;
+ virtual int GetSize(void) = 0;
+ virtual int GetValLen(void) = 0;
+ virtual int GetValPrec(void) = 0;
+ virtual int GetLength(void) {return 1;}
+ virtual PSZ GetCharValue(void) {assert(false); return NULL;}
+ virtual char GetTinyValue(void) {assert(false); return 0;}
+ virtual uchar GetUTinyValue(void) {assert(false); return 0;}
+ virtual short GetShortValue(void) {assert(false); return 0;}
+ virtual ushort GetUShortValue(void) {assert(false); return 0;}
+ virtual int GetIntValue(void) = 0;
+ virtual uint GetUIntValue(void) = 0;
+ virtual longlong GetBigintValue(void) = 0;
+ virtual ulonglong GetUBigintValue(void) = 0;
+ virtual double GetFloatValue(void) = 0;
+ virtual void *GetTo_Val(void) = 0;
+ virtual void SetPrec(int prec) {Prec = prec;}
+ bool IsNull(void) {return Null;}
+ void SetNull(bool b) {Null = b;}
+ bool GetNullable(void) {return Nullable;}
+ void SetNullable(bool b) {Nullable = b;}
+ int GetType(void) {return Type;}
+ int GetClen(void) {return Clen;}
+ void SetGlobal(PGLOBAL g) {Global = g;}
+
+ // Methods
+ virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
+ virtual bool SetValue_char(char *p, int n) = 0;
+ virtual void SetValue_psz(PSZ s) = 0;
+ virtual void SetValue_bool(bool b) {assert(FALSE);}
+ virtual int CompareValue(PVAL vp) = 0;
+ virtual BYTE TestValue(PVAL vp);
+ virtual void SetValue(char c) {assert(false);}
+ virtual void SetValue(uchar c) {assert(false);}
+ virtual void SetValue(short i) {assert(false);}
+ virtual void SetValue(ushort i) {assert(false);}
+ virtual void SetValue(int n) {assert(false);}
+ virtual void SetValue(uint n) {assert(false);}
+ virtual void SetValue(longlong n) {assert(false);}
+ virtual void SetValue(ulonglong n) {assert(false);}
+ virtual void SetValue(double f) {assert(false);}
+ virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
+ virtual void SetBinValue(void *p) = 0;
+ virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
+ virtual char *ShowValue(char *buf, int len = 0) = 0;
+ virtual char *GetCharString(char *p) = 0;
+ virtual bool IsEqual(PVAL vp, bool chktype) = 0;
+ virtual bool FormatValue(PVAL vp, char *fmt) = 0;
+
+ protected:
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
+ const char *GetXfmt(void);
+
+ // Constructor used by derived classes
+ VALUE(int type, bool un = false);
+
+ // Members
+ PGLOBAL Global; // To reduce arglist
+ const char *Fmt;
+ const char *Xfmt;
+ bool Nullable; // True if value can be null
+ bool Null; // True if value is null
+ bool Unsigned; // True if unsigned
+ int Type; // The value type
+ int Clen; // Internal value length
+ int Prec;
+ }; // end of class VALUE
+
+/***********************************************************************/
+/* Class TYPVAL: represents a typed value. */
+/***********************************************************************/
+template <class TYPE>
+class DllExport TYPVAL : public VALUE {
+ public:
+ // Constructor
+ TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
+
+ // Implementation
+ virtual bool IsTypeNum(void) {return true;}
+ virtual bool IsZero(void) {return Tval == 0;}
+ virtual void Reset(void) {Tval = 0;}
+ virtual int GetValLen(void);
+ virtual int GetValPrec() {return 0;}
+ virtual int GetSize(void) {return sizeof(TYPE);}
+ virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
+ virtual char GetTinyValue(void) {return (char)Tval;}
+ virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
+ virtual short GetShortValue(void) {return (short)Tval;}
+ virtual ushort GetUShortValue(void) {return (ushort)Tval;}
+ virtual int GetIntValue(void) {return (int)Tval;}
+ virtual uint GetUIntValue(void) {return (uint)Tval;}
+ virtual longlong GetBigintValue(void) {return (longlong)Tval;}
+ virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
+ virtual double GetFloatValue(void) {return (double)Tval;}
+ virtual void *GetTo_Val(void) {return &Tval;}
+
+ // Methods
+ virtual bool SetValue_pval(PVAL valp, bool chktype);
+ virtual bool SetValue_char(char *p, int n);
+ virtual void SetValue_psz(PSZ s);
+ virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
+ virtual int CompareValue(PVAL vp);
+ virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
+ virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
+ virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
+ virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;}
+ virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;}
+ virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;}
+ virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;}
+ virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;}
+ virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;}
+ virtual void SetValue_pvblk(PVBLK blk, int n);
+ virtual void SetBinValue(void *p);
+ virtual bool GetBinValue(void *buf, int buflen, bool go);
+ virtual char *ShowValue(char *buf, int);
+ virtual char *GetCharString(char *p);
+ virtual bool IsEqual(PVAL vp, bool chktype);
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
+ virtual bool FormatValue(PVAL vp, char *fmt);
+ virtual void Print(PGLOBAL g, FILE *, uint);
+ virtual void Print(PGLOBAL g, char *, uint);
+
+ protected:
+ // Default constructor not to be used
+ TYPVAL(void) : VALUE(TYPE_ERROR) {}
+
+ // Specialized functions
+ static ulonglong MaxVal(void);
+ TYPE GetTypedValue(PVAL vp);
+ TYPE GetTypedValue(PVBLK blk, int n);
+// TYPE GetTypedValue(PSZ s);
+
+ // Members
+ TYPE Tval;
+ }; // end of class TYPVAL
+
+/***********************************************************************/
+/* Specific STRING class. */
+/***********************************************************************/
+template <>
+class DllExport TYPVAL<PSZ>: public VALUE {
+ public:
+ // Constructors
+ TYPVAL(PSZ s);
+ TYPVAL(PGLOBAL g, PSZ s, int n, int c);
+
+ // Implementation
+ virtual bool IsTypeNum(void) {return false;}
+ virtual bool IsZero(void) {return *Strp == 0;}
+ virtual void Reset(void) {*Strp = 0;}
+ virtual int GetValLen(void) {return Len;};
+ virtual int GetValPrec() {return (Ci) ? 1 : 0;}
+ virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
+ virtual PSZ GetCharValue(void) {return Strp;}
+ virtual char GetTinyValue(void);
+ virtual uchar GetUTinyValue(void);
+ virtual short GetShortValue(void);
+ virtual ushort GetUShortValue(void);
+ virtual int GetIntValue(void);
+ virtual uint GetUIntValue(void);
+ virtual longlong GetBigintValue(void);
+ virtual ulonglong GetUBigintValue(void);
+ virtual double GetFloatValue(void) {return atof(Strp);}
+ virtual void *GetTo_Val(void) {return Strp;}
+ virtual void SetPrec(int prec) {Ci = prec != 0;}
+
+ // Methods
+ virtual bool SetValue_pval(PVAL valp, bool chktype);
+ virtual bool SetValue_char(char *p, int n);
+ virtual void SetValue_psz(PSZ s);
+ virtual void SetValue_pvblk(PVBLK blk, int n);
+ virtual void SetValue(char c);
+ virtual void SetValue(uchar c);
+ virtual void SetValue(short i);
+ virtual void SetValue(ushort i);
+ virtual void SetValue(int n);
+ virtual void SetValue(uint n);
+ virtual void SetValue(longlong n);
+ virtual void SetValue(ulonglong n);
+ virtual void SetValue(double f);
+ virtual void SetBinValue(void *p);
+ virtual int CompareValue(PVAL vp);
+ virtual bool GetBinValue(void *buf, int buflen, bool go);
+ virtual char *ShowValue(char *buf, int);
+ virtual char *GetCharString(char *p);
+ virtual bool IsEqual(PVAL vp, bool chktype);
+ virtual bool FormatValue(PVAL vp, char *fmt);
+ virtual bool SetConstFormat(PGLOBAL, FORMAT&);
+
+ // Members
+ PSZ Strp;
+ bool Ci; // true if case insensitive
+ int Len;
+ }; // end of class TYPVAL<PSZ>
+
+/***********************************************************************/
+/* Specific DECIMAL class. */
+/***********************************************************************/
+class DllExport DECVAL: public TYPVAL<PSZ> {
+ public:
+ // Constructors
+ DECVAL(PSZ s);
+ DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns);
+
+ // Implementation
+ virtual bool IsTypeNum(void) {return true;}
+ virtual bool IsZero(void);
+ virtual void Reset(void);
+ virtual int GetValPrec() {return Prec;}
+
+ // Methods
+ virtual bool GetBinValue(void *buf, int buflen, bool go);
+ virtual char *ShowValue(char *buf, int);
+ virtual bool IsEqual(PVAL vp, bool chktype);
+ virtual int CompareValue(PVAL vp);
+
+ // Members
+ }; // end of class DECVAL
+
+/***********************************************************************/
+/* Class DTVAL: represents a time stamp value. */
+/***********************************************************************/
+class DllExport DTVAL : public TYPVAL<int> {
+ public:
+ // Constructors
+ DTVAL(PGLOBAL g, int n, int p, PSZ fmt);
+ DTVAL(PGLOBAL g, PSZ s, int n);
+ DTVAL(PGLOBAL g, short i);
+ DTVAL(PGLOBAL g, int n);
+ DTVAL(PGLOBAL g, longlong n);
+ DTVAL(PGLOBAL g, double f);
+
+ // Implementation
+ virtual bool SetValue_pval(PVAL valp, bool chktype);
+ virtual bool SetValue_char(char *p, int n);
+ virtual void SetValue_psz(PSZ s);
+ virtual void SetValue_pvblk(PVBLK blk, int n);
+ virtual char *GetCharString(char *p);
+ virtual char *ShowValue(char *buf, int);
+ virtual bool FormatValue(PVAL vp, char *fmt);
+ bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
+ bool SetFormat(PGLOBAL g, PVAL valp);
+ bool IsFormatted(void) {return Pdtp != NULL;}
+ bool MakeTime(struct tm *ptm);
+ static void SetTimeShift(void);
+ static int GetShift(void) {return Shift;}
+
+ // Methods
+ bool MakeDate(PGLOBAL g, int *val, int nval);
+
+ struct tm *GetGmTime(struct tm *);
+
+ protected:
+ // Default constructor not to be used
+ DTVAL(void) : TYPVAL<int>() {}
+
+ // Members
+ static int Shift; // Time zone shift in seconds
+ PDTP Pdtp; // To the DATPAR structure
+ char *Sdate; // Utility char buffer
+ int DefYear; // Used by ExtractDate
+ int Len; // Used by CHAR scalar function
+ }; // end of class DTVAL
+
+#endif // __VALUE__H__