2013-02-07 10:34:27 +01:00
|
|
|
/**************** Value H Declares Source Code File (.H) ***************/
|
2019-03-23 17:51:40 +01:00
|
|
|
/* Name: VALUE.H Version 2.4 */
|
2013-02-07 10:34:27 +01:00
|
|
|
/* */
|
2019-03-23 17:51:40 +01:00
|
|
|
/* (C) Copyright to the author Olivier BERTRAND 2001-2019 */
|
2013-02-07 10:34:27 +01:00
|
|
|
/* */
|
|
|
|
/* This file contains the VALUE and derived classes declares. */
|
|
|
|
/***********************************************************************/
|
2013-02-27 16:42:59 +01:00
|
|
|
#ifndef __VALUE__H__
|
|
|
|
#define __VALUE__H__
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* 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"
|
|
|
|
|
2016-12-02 23:03:43 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This should list the processors accepting unaligned numeral values.*/
|
|
|
|
/***********************************************************************/
|
|
|
|
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64)
|
|
|
|
#define UNALIGNED_OK
|
|
|
|
#endif
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/***********************************************************************/
|
|
|
|
// Exported functions
|
2017-05-23 19:35:50 +02:00
|
|
|
DllExport PCSZ GetTypeName(int);
|
2013-02-07 10:34:27 +01:00
|
|
|
DllExport int GetTypeSize(int, int);
|
|
|
|
#ifdef ODBC_SUPPORT
|
2015-05-30 10:59:34 +02:00
|
|
|
/* This function is exported for use in OEM table type DLLs */
|
|
|
|
DllExport int TranslateSQLType(int stp, int prec,
|
|
|
|
int& len, char& v, bool& w);
|
2013-02-07 10:34:27 +01:00
|
|
|
#endif
|
2017-05-23 19:35:50 +02:00
|
|
|
DllExport const char *GetFormatType(int);
|
2013-02-07 10:34:27 +01:00
|
|
|
DllExport int GetFormatType(char);
|
|
|
|
DllExport bool IsTypeChar(int type);
|
|
|
|
DllExport bool IsTypeNum(int type);
|
2014-04-19 11:11:30 +02:00
|
|
|
DllExport int ConvertType(int, int, CONV, bool match = false);
|
2015-01-06 10:18:04 +01:00
|
|
|
DllExport PVAL AllocateValue(PGLOBAL, void *, short, short = 2);
|
2014-04-19 11:11:30 +02:00
|
|
|
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
|
2013-11-26 11:47:48 +01:00
|
|
|
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
|
2017-05-23 19:35:50 +02:00
|
|
|
bool uns = false, PCSZ fmt = NULL);
|
|
|
|
DllExport ulonglong CharToNumber(PCSZ, int, ulonglong, bool,
|
2013-12-03 22:59:40 +01:00
|
|
|
bool *minus = NULL, bool *rc = NULL);
|
2014-09-12 16:44:27 +02:00
|
|
|
DllExport BYTE OpBmp(PGLOBAL g, OPVAL opc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* 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
|
2020-11-03 18:40:28 +01:00
|
|
|
friend class SWAP; // The only class allowed to access protected
|
|
|
|
public:
|
2013-02-07 10:34:27 +01:00
|
|
|
// Constructors
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
virtual bool IsTypeNum(void) = 0;
|
|
|
|
virtual bool IsZero(void) = 0;
|
|
|
|
virtual bool IsCi(void) {return false;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual bool IsUnsigned(void) {return Unsigned;}
|
2013-02-07 10:34:27 +01:00
|
|
|
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;}
|
2013-03-11 16:52:59 +01:00
|
|
|
virtual char GetTinyValue(void) {assert(false); return 0;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual uchar GetUTinyValue(void) {assert(false); return 0;}
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual short GetShortValue(void) {assert(false); return 0;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual ushort GetUShortValue(void) {assert(false); return 0;}
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual int GetIntValue(void) = 0;
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual uint GetUIntValue(void) = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual longlong GetBigintValue(void) = 0;
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual ulonglong GetUBigintValue(void) = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual double GetFloatValue(void) = 0;
|
|
|
|
virtual void *GetTo_Val(void) = 0;
|
2013-05-10 20:22:21 +02:00
|
|
|
virtual void SetPrec(int prec) {Prec = prec;}
|
2017-05-23 19:35:50 +02:00
|
|
|
bool IsNull(void) {return (Nullable && Null);}
|
|
|
|
void SetNull(bool b) {Null = (Nullable ? b : false);}
|
2013-08-09 18:02:47 +02:00
|
|
|
bool GetNullable(void) {return Nullable;}
|
2013-02-24 01:23:18 +01:00
|
|
|
void SetNullable(bool b) {Nullable = b;}
|
2013-02-07 10:34:27 +01:00
|
|
|
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;
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool SetValue_char(const char *p, int n) = 0;
|
|
|
|
virtual void SetValue_psz(PCSZ s) = 0;
|
2017-10-15 16:13:23 +02:00
|
|
|
virtual void SetValue_bool(bool) {assert(false);}
|
2014-04-19 11:11:30 +02:00
|
|
|
virtual int CompareValue(PVAL vp) = 0;
|
|
|
|
virtual BYTE TestValue(PVAL vp);
|
2015-05-09 17:30:20 +02:00
|
|
|
virtual void SetValue(char) {assert(false);}
|
|
|
|
virtual void SetValue(uchar) {assert(false);}
|
|
|
|
virtual void SetValue(short) {assert(false);}
|
|
|
|
virtual void SetValue(ushort) {assert(false);}
|
|
|
|
virtual void SetValue(int) {assert(false);}
|
|
|
|
virtual void SetValue(uint) {assert(false);}
|
|
|
|
virtual void SetValue(longlong) {assert(false);}
|
|
|
|
virtual void SetValue(ulonglong) {assert(false);}
|
|
|
|
virtual void SetValue(double) {assert(false);}
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
|
2020-10-05 12:29:51 +02:00
|
|
|
virtual void SetBinValue(void* p) = 0;
|
|
|
|
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len) = 0;
|
2013-02-24 01:23:18 +01:00
|
|
|
virtual char *GetCharString(char *p) = 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual bool IsEqual(PVAL vp, bool chktype) = 0;
|
2015-01-06 10:18:04 +01:00
|
|
|
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool FormatValue(PVAL vp, PCSZ fmt) = 0;
|
|
|
|
virtual void Printf(PGLOBAL g, FILE *, uint);
|
|
|
|
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
2013-02-24 01:23:18 +01:00
|
|
|
|
2016-12-02 23:03:43 +01:00
|
|
|
/**
|
|
|
|
Set value from a non-aligned in-memory value in the machine byte order.
|
|
|
|
TYPE can be either of:
|
|
|
|
- int, short, longlong
|
|
|
|
- uint, ushort, ulonglong
|
|
|
|
- float, double
|
|
|
|
@param - a pointer to a non-aligned value of type TYPE.
|
|
|
|
*/
|
|
|
|
template<typename TYPE>
|
|
|
|
void SetValueNonAligned(const char *p)
|
|
|
|
{
|
|
|
|
#if defined(UNALIGNED_OK)
|
|
|
|
SetValue(*((TYPE*)p)); // x86 can cast non-aligned memory directly
|
|
|
|
#else
|
|
|
|
TYPE tmp; // a slower version for non-x86 platforms
|
|
|
|
memcpy(&tmp, p, sizeof(tmp));
|
|
|
|
SetValue(tmp);
|
|
|
|
#endif
|
|
|
|
} // end of SetValueNonAligned
|
|
|
|
|
|
|
|
/**
|
|
|
|
Get value from a non-aligned in-memory value in the machine byte order.
|
|
|
|
TYPE can be either of:
|
|
|
|
- int, short, longlong
|
|
|
|
- uint, ushort, ulonglong
|
|
|
|
- float, double
|
|
|
|
@params - a pointer to a non-aligned value of type TYPE, the TYPE value.
|
|
|
|
*/
|
|
|
|
template<typename TYPE>
|
|
|
|
void GetValueNonAligned(char *p, TYPE n)
|
|
|
|
{
|
|
|
|
#if defined(UNALIGNED_OK)
|
|
|
|
*(TYPE *)p = n; // x86 can cast non-aligned memory directly
|
2015-10-24 18:16:06 +02:00
|
|
|
#else
|
2016-12-02 23:03:43 +01:00
|
|
|
TYPE tmp = n; // a slower version for non-x86 platforms
|
|
|
|
memcpy(p, &tmp, sizeof(tmp));
|
2015-10-24 18:16:06 +02:00
|
|
|
#endif
|
2016-12-02 23:03:43 +01:00
|
|
|
} // end of SetValueNonAligned
|
2015-10-24 18:16:06 +02:00
|
|
|
|
2016-12-02 23:03:43 +01:00
|
|
|
protected:
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
|
2013-02-27 16:42:59 +01:00
|
|
|
const char *GetXfmt(void);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Constructor used by derived classes
|
2013-11-26 11:47:48 +01:00
|
|
|
VALUE(int type, bool un = false);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Members
|
2013-02-27 16:42:59 +01:00
|
|
|
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
|
2013-11-26 11:47:48 +01:00
|
|
|
bool Unsigned; // True if unsigned
|
2013-02-27 16:42:59 +01:00
|
|
|
int Type; // The value type
|
|
|
|
int Clen; // Internal value length
|
|
|
|
int Prec;
|
2013-02-07 10:34:27 +01:00
|
|
|
}; // end of class VALUE
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2013-02-27 16:42:59 +01:00
|
|
|
/* Class TYPVAL: represents a typed value. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
2013-02-27 16:42:59 +01:00
|
|
|
template <class TYPE>
|
|
|
|
class DllExport TYPVAL : public VALUE {
|
2013-02-07 10:34:27 +01:00
|
|
|
public:
|
2013-11-26 11:47:48 +01:00
|
|
|
// Constructor
|
|
|
|
TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Implementation
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual bool IsTypeNum(void) {return true;}
|
|
|
|
virtual bool IsZero(void) {return Tval == 0;}
|
|
|
|
virtual void Reset(void) {Tval = 0;}
|
|
|
|
virtual int GetValLen(void);
|
2015-01-06 10:18:04 +01:00
|
|
|
virtual int GetValPrec() {return Prec;}
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual int GetSize(void) {return sizeof(TYPE);}
|
2015-01-06 10:18:04 +01:00
|
|
|
//virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
|
2013-03-11 16:52:59 +01:00
|
|
|
virtual char GetTinyValue(void) {return (char)Tval;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual short GetShortValue(void) {return (short)Tval;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual ushort GetUShortValue(void) {return (ushort)Tval;}
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual int GetIntValue(void) {return (int)Tval;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual uint GetUIntValue(void) {return (uint)Tval;}
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual longlong GetBigintValue(void) {return (longlong)Tval;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
|
2013-02-27 16:42:59 +01:00
|
|
|
virtual double GetFloatValue(void) {return (double)Tval;}
|
|
|
|
virtual void *GetTo_Val(void) {return &Tval;}
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Methods
|
|
|
|
virtual bool SetValue_pval(PVAL valp, bool chktype);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool SetValue_char(const char *p, int n);
|
|
|
|
virtual void SetValue_psz(PCSZ s);
|
2014-04-19 11:11:30 +02:00
|
|
|
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
|
|
|
|
virtual int CompareValue(PVAL vp);
|
2013-03-11 16:52:59 +01:00
|
|
|
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;}
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;}
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;}
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;}
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;}
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual void SetValue_pvblk(PVBLK blk, int n);
|
|
|
|
virtual void SetBinValue(void *p);
|
|
|
|
virtual bool GetBinValue(void *buf, int buflen, bool go);
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len);
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual char *GetCharString(char *p);
|
|
|
|
virtual bool IsEqual(PVAL vp, bool chktype);
|
2015-01-06 10:18:04 +01:00
|
|
|
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
2013-02-24 01:23:18 +01:00
|
|
|
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool FormatValue(PVAL vp, PCSZ fmt);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
protected:
|
2015-01-19 18:55:25 +01:00
|
|
|
static TYPE MinMaxVal(bool b);
|
|
|
|
TYPE SafeAdd(TYPE n1, TYPE n2);
|
|
|
|
TYPE SafeMult(TYPE n1, TYPE n2);
|
2015-01-06 10:18:04 +01:00
|
|
|
bool Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// Default constructor not to be used
|
2013-02-27 16:42:59 +01:00
|
|
|
TYPVAL(void) : VALUE(TYPE_ERROR) {}
|
|
|
|
|
|
|
|
// Specialized functions
|
2013-12-03 22:59:40 +01:00
|
|
|
static ulonglong MaxVal(void);
|
|
|
|
TYPE GetTypedValue(PVAL vp);
|
|
|
|
TYPE GetTypedValue(PVBLK blk, int n);
|
|
|
|
// TYPE GetTypedValue(PSZ s);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Members
|
2013-02-27 16:42:59 +01:00
|
|
|
TYPE Tval;
|
|
|
|
}; // end of class TYPVAL
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
2013-02-28 22:50:26 +01:00
|
|
|
/* Specific STRING class. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
2013-02-28 22:50:26 +01:00
|
|
|
template <>
|
2014-04-19 11:11:30 +02:00
|
|
|
class DllExport TYPVAL<PSZ>: public VALUE {
|
2020-11-03 18:40:28 +01:00
|
|
|
friend class SWAP; // The only class allowed to offsets Strg
|
|
|
|
public:
|
2013-02-28 22:50:26 +01:00
|
|
|
// Constructors
|
2015-12-04 22:38:16 +01:00
|
|
|
TYPVAL(PSZ s, short c = 0);
|
2013-02-28 22:50:26 +01:00
|
|
|
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;}
|
2017-03-02 12:12:53 +01:00
|
|
|
virtual int GetSize(void) {return (Strp) ? (int)strlen(Strp) : 0;}
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual PSZ GetCharValue(void) {return Strp;}
|
2013-12-03 22:59:40 +01:00
|
|
|
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);
|
2013-02-28 22:50:26 +01:00
|
|
|
virtual double GetFloatValue(void) {return atof(Strp);}
|
|
|
|
virtual void *GetTo_Val(void) {return Strp;}
|
2013-05-10 20:22:21 +02:00
|
|
|
virtual void SetPrec(int prec) {Ci = prec != 0;}
|
2013-02-28 22:50:26 +01:00
|
|
|
|
|
|
|
// Methods
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual bool SetValue_pval(PVAL valp, bool chktype);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool SetValue_char(const char *p, int n);
|
|
|
|
virtual void SetValue_psz(PCSZ s);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual void SetValue_pvblk(PVBLK blk, int n);
|
2013-03-11 16:52:59 +01:00
|
|
|
virtual void SetValue(char c);
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(uchar c);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual void SetValue(short i);
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(ushort i);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual void SetValue(int n);
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(uint n);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual void SetValue(longlong n);
|
2013-11-26 11:47:48 +01:00
|
|
|
virtual void SetValue(ulonglong n);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual void SetValue(double f);
|
|
|
|
virtual void SetBinValue(void *p);
|
2014-04-19 11:11:30 +02:00
|
|
|
virtual int CompareValue(PVAL vp);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual bool GetBinValue(void *buf, int buflen, bool go);
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual char *GetCharString(char *p);
|
|
|
|
virtual bool IsEqual(PVAL vp, bool chktype);
|
2015-01-06 10:18:04 +01:00
|
|
|
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool FormatValue(PVAL vp, PCSZ fmt);
|
2013-03-02 22:30:40 +01:00
|
|
|
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual void Prints(PGLOBAL g, char *ps, uint z);
|
2013-02-28 22:50:26 +01:00
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
protected:
|
2013-02-28 22:50:26 +01:00
|
|
|
// Members
|
|
|
|
PSZ Strp;
|
|
|
|
bool Ci; // true if case insensitive
|
|
|
|
int Len;
|
|
|
|
}; // end of class TYPVAL<PSZ>
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-28 15:46:49 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Specific DECIMAL class. */
|
|
|
|
/***********************************************************************/
|
2014-04-19 11:11:30 +02:00
|
|
|
class DllExport DECVAL: public TYPVAL<PSZ> {
|
2013-12-28 15:46:49 +01:00
|
|
|
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);
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len);
|
2013-12-28 15:46:49 +01:00
|
|
|
virtual bool IsEqual(PVAL vp, bool chktype);
|
2014-04-19 11:11:30 +02:00
|
|
|
virtual int CompareValue(PVAL vp);
|
2013-12-28 15:46:49 +01:00
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
protected:
|
2013-12-28 15:46:49 +01:00
|
|
|
// Members
|
|
|
|
}; // end of class DECVAL
|
|
|
|
|
2014-04-01 18:14:57 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Specific BINARY class. */
|
|
|
|
/***********************************************************************/
|
2014-04-19 11:11:30 +02:00
|
|
|
class DllExport BINVAL: public VALUE {
|
2020-11-03 18:40:28 +01:00
|
|
|
friend class SWAP; // The only class allowed to offsets pointers
|
|
|
|
public:
|
2014-04-01 18:14:57 +02:00
|
|
|
// Constructors
|
|
|
|
//BINVAL(void *p);
|
|
|
|
BINVAL(PGLOBAL g, void *p, int cl, int n);
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
virtual bool IsTypeNum(void) {return false;}
|
|
|
|
virtual bool IsZero(void);
|
|
|
|
virtual void Reset(void);
|
|
|
|
virtual int GetValLen(void) {return Clen;};
|
|
|
|
virtual int GetValPrec() {return 0;}
|
|
|
|
virtual int GetSize(void) {return Len;}
|
|
|
|
virtual PSZ GetCharValue(void) {return (PSZ)Binp;}
|
|
|
|
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);
|
|
|
|
virtual void *GetTo_Val(void) {return Binp;}
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
virtual bool SetValue_pval(PVAL valp, bool chktype);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool SetValue_char(const char *p, int n);
|
|
|
|
virtual void SetValue_psz(PCSZ s);
|
2014-04-01 18:14:57 +02:00
|
|
|
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);
|
2020-10-05 12:29:51 +02:00
|
|
|
virtual void SetBinValue(void* p, ulong len);
|
|
|
|
virtual bool GetBinValue(void *buf, int buflen, bool go);
|
2015-05-09 17:30:20 +02:00
|
|
|
virtual int CompareValue(PVAL) {assert(false); return 0;}
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len);
|
2014-04-01 18:14:57 +02:00
|
|
|
virtual char *GetCharString(char *p);
|
|
|
|
virtual bool IsEqual(PVAL vp, bool chktype);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool FormatValue(PVAL vp, PCSZ fmt);
|
2014-04-01 18:14:57 +02:00
|
|
|
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
protected:
|
2014-04-01 18:14:57 +02:00
|
|
|
// Members
|
|
|
|
void *Binp;
|
|
|
|
char *Chrp;
|
|
|
|
int Len;
|
|
|
|
}; // end of class BINVAL
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Class DTVAL: represents a time stamp value. */
|
|
|
|
/***********************************************************************/
|
2013-02-27 16:42:59 +01:00
|
|
|
class DllExport DTVAL : public TYPVAL<int> {
|
2013-02-07 10:34:27 +01:00
|
|
|
public:
|
|
|
|
// Constructors
|
2017-05-23 19:35:50 +02:00
|
|
|
DTVAL(PGLOBAL g, int n, int p, PCSZ fmt);
|
2015-05-09 17:30:20 +02:00
|
|
|
DTVAL(int n);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Implementation
|
|
|
|
virtual bool SetValue_pval(PVAL valp, bool chktype);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool SetValue_char(const char *p, int n);
|
|
|
|
virtual void SetValue_psz(PCSZ s);
|
2013-02-07 10:34:27 +01:00
|
|
|
virtual void SetValue_pvblk(PVBLK blk, int n);
|
|
|
|
virtual char *GetCharString(char *p);
|
2019-03-23 17:51:40 +01:00
|
|
|
virtual int ShowValue(char *buf, int len);
|
2017-05-23 19:35:50 +02:00
|
|
|
virtual bool FormatValue(PVAL vp, PCSZ fmt);
|
|
|
|
bool SetFormat(PGLOBAL g, PCSZ fmt, int len, int year = 0);
|
2013-02-07 10:34:27 +01:00
|
|
|
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);
|
|
|
|
|
2013-05-23 10:04:52 +02:00
|
|
|
struct tm *GetGmTime(struct tm *);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Default constructor not to be used
|
2013-02-27 16:42:59 +01:00
|
|
|
DTVAL(void) : TYPVAL<int>() {}
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// 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
|
2013-03-02 22:30:40 +01:00
|
|
|
int Len; // Used by CHAR scalar function
|
2013-02-07 10:34:27 +01:00
|
|
|
}; // end of class DTVAL
|
|
|
|
|
2013-02-27 16:42:59 +01:00
|
|
|
#endif // __VALUE__H__
|