Commit fa4aa616 authored by Olivier Bertrand's avatar Olivier Bertrand

- Rewriting the VALUE classes as template classes

modified:
  storage/connect/tabdos.cpp
  storage/connect/tabdos.h
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabsys.cpp
  storage/connect/tabxml.cpp
  storage/connect/value.cpp
  storage/connect/value.h
  storage/connect/xobject.h
parent f2b8155a
...@@ -991,7 +991,7 @@ bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) ...@@ -991,7 +991,7 @@ bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else if (Buf_Type == TYPE_FLOAT) } else if (Buf_Type == TYPE_FLOAT)
// Float values must be written with the correct (column) precision // Float values must be written with the correct (column) precision
// Note: maybe this should be forced by ShowValue instead of this ? // Note: maybe this should be forced by ShowValue instead of this ?
((DFVAL *)value)->SetPrec(GetPrecision()); value->SetPrec(GetPrecision());
Value = value; // Directly access the external value Value = value; // Directly access the external value
} else { } else {
...@@ -1031,7 +1031,8 @@ void DOSCOL::ReadColumn(PGLOBAL g) ...@@ -1031,7 +1031,8 @@ void DOSCOL::ReadColumn(PGLOBAL g)
{ {
char *p; char *p;
int i, rc; int i, rc;
int field; int field;
double dval;
PTDBDOS tdbp = (PTDBDOS)To_Tdb; PTDBDOS tdbp = (PTDBDOS)To_Tdb;
if (trace > 1) if (trace > 1)
...@@ -1066,14 +1067,17 @@ void DOSCOL::ReadColumn(PGLOBAL g) ...@@ -1066,14 +1067,17 @@ void DOSCOL::ReadColumn(PGLOBAL g)
if (Nod) switch (Buf_Type) { if (Nod) switch (Buf_Type) {
case TYPE_INT: case TYPE_INT:
case TYPE_SHORT: case TYPE_SHORT:
case TYPE_BIGINT:
Value->SetValue_char(p, field - Dcm); Value->SetValue_char(p, field - Dcm);
break; break;
case TYPE_FLOAT: case TYPE_FLOAT:
Value->SetValue_char(p, field); Value->SetValue_char(p, field);
dval = Value->GetFloatValue();
for (i = 0; i < Dcm; i++) for (i = 0; i < Dcm; i++)
((DFVAL*)Value)->Divide(10.0); dval /= 10.0;
Value->SetValue(dval);
break; break;
default: default:
Value->SetValue_char(p, field); Value->SetValue_char(p, field);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "colblk.h" // Column base class declares #include "colblk.h" // Column base class declares
#include "xindex.h" #include "xindex.h"
typedef struct _tabdesc *PTABD; // For friend setting //pedef struct _tabdesc *PTABD; // For friend setting
typedef class TXTFAM *PTXF; typedef class TXTFAM *PTXF;
/***********************************************************************/ /***********************************************************************/
......
...@@ -960,7 +960,7 @@ bool MYSQLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) ...@@ -960,7 +960,7 @@ bool MYSQLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else if (Buf_Type == TYPE_FLOAT) } else if (Buf_Type == TYPE_FLOAT)
// Float values must be written with the correct (column) precision // Float values must be written with the correct (column) precision
// Note: maybe this should be forced by ShowValue instead of this ? // Note: maybe this should be forced by ShowValue instead of this ?
((DFVAL *)value)->SetPrec(GetPrecision()); value->SetPrec(GetPrecision());
Value = value; // Directly access the external value Value = value; // Directly access the external value
} else { } else {
......
...@@ -757,7 +757,7 @@ bool ODBCCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) ...@@ -757,7 +757,7 @@ bool ODBCCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else if (Buf_Type == TYPE_FLOAT) } else if (Buf_Type == TYPE_FLOAT)
// Float values must be written with the correct (column) precision // Float values must be written with the correct (column) precision
// Note: maybe this should be forced by ShowValue instead of this ? // Note: maybe this should be forced by ShowValue instead of this ?
((DFVAL *)value)->SetPrec(GetPrecision()); value->SetPrec(GetPrecision());
Value = value; // Directly access the external value Value = value; // Directly access the external value
} else { } else {
......
...@@ -455,7 +455,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) ...@@ -455,7 +455,7 @@ bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else if (Buf_Type == TYPE_FLOAT) } else if (Buf_Type == TYPE_FLOAT)
// Float values must be written with the correct (column) precision // Float values must be written with the correct (column) precision
// Note: maybe this should be forced by ShowValue instead of this ? // Note: maybe this should be forced by ShowValue instead of this ?
((DFVAL *)value)->SetPrec(GetPrecision()); value->SetPrec(GetPrecision());
Value = value; // Directly access the external value Value = value; // Directly access the external value
} else { } else {
......
...@@ -1148,7 +1148,7 @@ bool XMLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) ...@@ -1148,7 +1148,7 @@ bool XMLCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
} else if (Buf_Type == TYPE_FLOAT) } else if (Buf_Type == TYPE_FLOAT)
// Float values must be written with the correct (column) precision // Float values must be written with the correct (column) precision
// Note: maybe this should be forced by ShowValue instead of this ? // Note: maybe this should be forced by ShowValue instead of this ?
((DFVAL *)value)->SetPrec(GetPrecision()); value->SetPrec(GetPrecision());
Value = value; // Directly access the external value Value = value; // Directly access the external value
} else { } else {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**************** Value H Declares Source Code File (.H) ***************/ /**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 1.7 */ /* Name: VALUE.H Version 1.8 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
/* */ /* */
/* This file contains the VALUE and derived classes declares. */ /* This file contains the VALUE and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALUE__H__
#define __VALUE__H__
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* assert.h is header required when using the assert function. */ /* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALUE__H__
#define __VALUE__H__
#include "assert.h" #include "assert.h"
#include "block.h" #include "block.h"
...@@ -86,13 +86,13 @@ class DllExport VALUE : public BLOCK { ...@@ -86,13 +86,13 @@ class DllExport VALUE : public BLOCK {
void SetNullable(bool b) {Nullable = b;} void SetNullable(bool b) {Nullable = b;}
int GetType(void) {return Type;} int GetType(void) {return Type;}
int GetClen(void) {return Clen;} int GetClen(void) {return Clen;}
void SetPrec(int prec) {Prec = prec;}
void SetGlobal(PGLOBAL g) {Global = g;} void SetGlobal(PGLOBAL g) {Global = g;}
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
virtual void SetValue_char(char *p, int n) = 0; virtual void SetValue_char(char *p, int n) = 0;
virtual void SetValue_psz(PSZ s) = 0; virtual void SetValue_psz(PSZ s) = 0;
virtual void SetValue_bool(bool b) {assert(false);}
virtual void SetValue(short i) {assert(false);} virtual void SetValue(short i) {assert(false);}
virtual void SetValue(int n) {assert(false);} virtual void SetValue(int n) {assert(false);}
virtual void SetValue(longlong n) {assert(false);} virtual void SetValue(longlong n) {assert(false);}
...@@ -100,7 +100,6 @@ class DllExport VALUE : public BLOCK { ...@@ -100,7 +100,6 @@ class DllExport VALUE : public BLOCK {
virtual void SetValue_pvblk(PVBLK blk, int n) = 0; virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
virtual void SetBinValue(void *p) = 0; virtual void SetBinValue(void *p) = 0;
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
//virtual void GetBinValue(void *buf, int len) = 0;
virtual char *ShowValue(char *buf, int len = 0) = 0; virtual char *ShowValue(char *buf, int len = 0) = 0;
virtual char *GetCharString(char *p) = 0; virtual char *GetCharString(char *p) = 0;
virtual char *GetShortString(char *p, int n) {return "#####";} virtual char *GetShortString(char *p, int n) {return "#####";}
...@@ -108,165 +107,65 @@ class DllExport VALUE : public BLOCK { ...@@ -108,165 +107,65 @@ class DllExport VALUE : public BLOCK {
virtual char *GetBigintString(char *p, int n) = 0; virtual char *GetBigintString(char *p, int n) = 0;
virtual char *GetFloatString(char *p, int n, int prec) = 0; virtual char *GetFloatString(char *p, int n, int prec) = 0;
virtual bool IsEqual(PVAL vp, bool chktype) = 0; virtual bool IsEqual(PVAL vp, bool chktype) = 0;
#if 0
virtual int CompareValue(PVAL vp) = 0;
virtual BYTE TestValue(PVAL vp);
virtual void StdVar(PVAL vp, int cnt, bool b) {assert(false);}
virtual void Add(int lv) {assert(false);}
virtual void Add(PVAL vp) {assert(false);}
virtual void Add(PVBLK vbp, int i) {assert(false);}
virtual void Add(PVBLK vbp, int j, int k) {assert(false);}
virtual void Add(PVBLK vbp, int *x, int j, int k) {assert(false);}
virtual void AddSquare(PVAL vp) {assert(false);}
virtual void AddSquare(PVBLK vbp, int i) {assert(false);}
virtual void AddSquare(PVBLK vbp, int j, int k) {assert(false);}
virtual void Times(PVAL vp) {assert(false);}
virtual void Divide(int cnt) {assert(false);}
virtual void SetMin(PVAL vp) = 0;
virtual void SetMin(PVBLK vbp, int i) = 0;
virtual void SetMin(PVBLK vbp, int j, int k) = 0;
virtual void SetMin(PVBLK vbp, int *x, int j, int k) = 0;
virtual void SetMax(PVAL vp) = 0;
virtual void SetMax(PVBLK vbp, int i) = 0;
virtual void SetMax(PVBLK vbp, int j, int k) = 0;
virtual void SetMax(PVBLK vbp, int *x, int j, int k) = 0;
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op) = 0;
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) = 0;
#endif // 0
virtual bool FormatValue(PVAL vp, char *fmt) = 0; virtual bool FormatValue(PVAL vp, char *fmt) = 0;
// char *ShowTypedValue(PGLOBAL g, char *buf, int typ, int n, int p);
protected: protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0; virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
const char *GetFmt(void);
const char *GetXfmt(void);
// Constructor used by derived classes // Constructor used by derived classes
VALUE(int type) : Type(type) {Null=Nullable=false; Clen=0;} VALUE(int type);
// Members // Members
PGLOBAL Global; // To reduce arglist PGLOBAL Global; // To reduce arglist
//const int Type; // The value type const char *Fmt;
bool Nullable; // True if value can be null const char *Xfmt;
bool Null; // True if value is null bool Nullable; // True if value can be null
int Type; // The value type bool Null; // True if value is null
int Clen; // Internal value length bool Ci; // true if case insensitive
int Type; // The value type
int Clen; // Internal value length
int Len;
int Prec;
}; // end of class VALUE }; // end of class VALUE
/***********************************************************************/ /***********************************************************************/
/* Class STRING: represents zero terminated strings. */ /* Class TYPVAL: represents a typed value. */
/***********************************************************************/ /***********************************************************************/
class STRING : public VALUE { template <class TYPE>
friend class SFROW; class DllExport TYPVAL : public VALUE {
public: public:
// Constructors // Constructors
STRING(PSZ s); TYPVAL(TYPE n, int type);
STRING(PGLOBAL g, PSZ s, int n, int c = 0); TYPVAL(TYPE n, int prec, int type);
STRING(PGLOBAL g, short i); TYPVAL(PGLOBAL g, PSZ s, int n, int c, int type);
STRING(PGLOBAL g, int n);
STRING(PGLOBAL g, longlong n);
STRING(PGLOBAL g, double f);
// Implementation // Implementation
virtual bool IsTypeNum(void) {return false;} virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return (Strp) ? strlen(Strp) == 0 : true;} virtual bool IsZero(void) {return Tval == 0;}
virtual bool IsCi(void) {return Ci;} virtual void Reset(void) {Tval = 0;}
virtual void Reset(void) {*Strp = '\0';} virtual int GetValLen(void);
virtual int GetValLen(void) {return Len;} virtual int GetValPrec() {return 0;}
virtual int GetValPrec() {return (Ci) ? 1 : 0;} virtual int GetSize(void) {return sizeof(TYPE);}
virtual int GetLength(void) {return Len;} virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} virtual short GetShortValue(void) {return (short)Tval;}
virtual PSZ GetCharValue(void) {return Strp;} virtual int GetIntValue(void) {return (int)Tval;}
virtual short GetShortValue(void) {return (short)atoi(Strp);} virtual longlong GetBigintValue(void) {return (longlong)Tval;}
virtual int GetIntValue(void) {return atol(Strp);} virtual double GetFloatValue(void) {return (double)Tval;}
virtual longlong GetBigintValue(void) {return atoll(Strp);} virtual void *GetTo_Val(void) {return &Tval;}
virtual double GetFloatValue(void) {return atof(Strp);}
virtual void *GetTo_Val(void) {return Strp;}
// Methods // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n); virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(short i); virtual void SetValue(short i);
virtual void SetValue(int n); virtual void SetValue(int n);
virtual void SetValue(longlong n); virtual void SetValue(longlong n);
virtual void SetValue(double f); virtual void SetValue(double f);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
virtual char *GetIntString(char *p, int n);
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
#if 0
virtual int CompareValue(PVAL vp);
virtual BYTE TestValue(PVAL vp);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
virtual void SetMin(PVBLK vbp, int *x, int j, int k);
virtual void SetMax(PVAL vp);
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
#endif // 0
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
STRING(void) : VALUE(TYPE_ERROR) {}
// Members
PSZ Strp;
int Len;
bool Ci; // true if case insensitive
}; // end of class STRING
/***********************************************************************/
/* Class SHVAL: represents short integer values. */
/***********************************************************************/
class SHVAL : public VALUE {
public:
// Constructors
SHVAL(PSZ s);
SHVAL(short n);
SHVAL(int n);
SHVAL(longlong n);
SHVAL(double f);
// Implementation
virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return Sval == 0;}
virtual void Reset(void) {Sval = 0;}
virtual int GetValLen(void);
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(short);}
//virtual PSZ GetCharValue(void) {}
virtual short GetShortValue(void) {return Sval;}
virtual int GetIntValue(void) {return (int)Sval;}
virtual longlong GetBigintValue(void) {return (longlong)Sval;}
virtual double GetFloatValue(void) {return (double)Sval;}
virtual void *GetTo_Val(void) {return &Sval;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue_bool(bool b) {Sval = (b) ? 1 : 0;}
virtual void SetValue(short i) {Sval = i;}
virtual void SetValue(int n) {Sval = (short)n;}
virtual void SetValue(longlong n) {Sval = (short)n;}
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p); virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go); virtual bool GetBinValue(void *buf, int buflen, bool go);
//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n); virtual char *GetShortString(char *p, int n);
...@@ -274,134 +173,66 @@ class SHVAL : public VALUE { ...@@ -274,134 +173,66 @@ class SHVAL : public VALUE {
virtual char *GetBigintString(char *p, int n); virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1); virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
#if 0
virtual int CompareValue(PVAL vp);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Sval += (short)lv;}
virtual void Add(PVAL vp);
virtual void Add(PVBLK vbp, int i);
virtual void Add(PVBLK vbp, int j, int k);
virtual void Add(PVBLK vbp, int *x, int j, int k);
virtual void AddSquare(PVAL vp);
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
virtual void SetMin(PVBLK vbp, int *x, int j, int k);
virtual void SetMax(PVAL vp);
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) {return 0;}
#endif // 0
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, char *fmt);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); virtual void Print(PGLOBAL g, char *, uint);
protected: protected:
// short SafeAdd(short n1, short n2);
// short SafeMult(short n1, short n2);
// Default constructor not to be used // Default constructor not to be used
SHVAL(void) : VALUE(TYPE_ERROR) {} TYPVAL(void) : VALUE(TYPE_ERROR) {}
// Specialized functions
template <class TYPE>
TYPE GetTypedValue(PVAL vp, TYPE t) {return vp->GetIntValue();}
PSZ GetTypedValue(PVAL vp, PSZ t)
{char buf[32]; return strncpy(Tval, vp->GetCharString(buf), Len);}
short GetTypedValue(PVAL vp, short t) {return vp->GetShortValue();}
longlong GetTypedValue(PVAL vp, longlong t) {return vp->GetBigintValue();}
double GetTypedValue(PVAL vp, double t) {return vp->GetFloatValue();}
template <class TYPE>
TYPE GetTypedValue(PVBLK blk, int n, TYPE t)
{return blk->GetIntValue(n);}
PSZ GetTypedValue(PVBLK blk, int n, PSZ t)
{return strncpy(Tval, blk->GetCharValue(n), Len);}
short GetTypedValue(PVBLK blk, int n, short t)
{return blk->GetShortValue(n);}
longlong GetTypedValue(PVBLK blk, int n, longlong t)
{return blk->GetBigintValue(n);}
double GetTypedValue(PVBLK blk, int n, double t)
{return blk->GetFloatValue(n);}
template <class TYPE>
TYPE GetTypedValue(PSZ s, TYPE n) {return atol(s);}
PSZ GetTypedValue(PSZ s, PSZ n) {return strncpy(Tval, s, Len);}
short GetTypedValue(PSZ s, short n) {return atoi(s);}
longlong GetTypedValue(PSZ s, longlong n) {return atoll(s);}
double GetTypedValue(PSZ s, double n) {return atof(s);}
// Members // Members
short Sval; TYPE Tval;
}; // end of class SHVAL }; // end of class TYPVAL
/***********************************************************************/ /***********************************************************************/
/* Class INTVAL: represents int integer values. */ /* Specific STRING functions. */
/***********************************************************************/ /***********************************************************************/
class DllExport INTVAL : public VALUE { bool TYPVAL<PSZ>::IsTypeNum(void) {return false;}
public: bool TYPVAL<PSZ>::IsZero(void) {return *Tval == 0;}
// Constructors void TYPVAL<PSZ>::Reset(void) {*Tval = 0;}
INTVAL(PSZ s); int TYPVAL<PSZ>::GetValPrec() {return (Ci) ? 1 : 0;}
INTVAL(short i); int TYPVAL<PSZ>::GetSize(void) {return (Tval) ? strlen(Tval) : 0;}
INTVAL(int n); PSZ TYPVAL<PSZ>::GetCharValue(void) {return Tval;}
INTVAL(longlong n); short TYPVAL<PSZ>::GetShortValue(void) {return (short)atoi(Tval);}
INTVAL(double f); int TYPVAL<PSZ>::GetIntValue(void) {return atol(Tval);}
longlong TYPVAL<PSZ>::GetBigintValue(void) {return atoll(Tval);}
// Implementation double TYPVAL<PSZ>::GetFloatValue(void) {return atof(Tval);}
virtual bool IsTypeNum(void) {return true;} void *TYPVAL<PSZ>::GetTo_Val(void) {return Tval;}
virtual bool IsZero(void) {return Ival == 0;}
virtual void Reset(void) {Ival = 0;}
virtual int GetValLen(void);
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(int);}
//virtual PSZ GetCharValue(void) {}
virtual short GetShortValue(void) {return (short)Ival;}
virtual int GetIntValue(void) {return Ival;}
virtual longlong GetBigintValue(void) {return (longlong)Ival;}
virtual double GetFloatValue(void) {return (double)Ival;}
virtual void *GetTo_Val(void) {return &Ival;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue_bool(bool b) {Ival = (b) ? 1 : 0;}
virtual void SetValue(short i) {Ival = (int)i;}
virtual void SetValue(int n) {Ival = n;}
virtual void SetValue(longlong n) {Ival = (int)n;}
virtual void SetValue(double f) {Ival = (int)f;}
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
virtual char *GetIntString(char *p, int n);
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
#if 0
virtual int CompareValue(PVAL vp);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Ival += lv;}
virtual void Add(PVAL vp);
virtual void Add(PVBLK vbp, int i);
virtual void Add(PVBLK vbp, int j, int k);
virtual void Add(PVBLK vbp, int *x, int j, int k);
virtual void AddSquare(PVAL vp);
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
virtual void SetMin(PVBLK vbp, int *x, int j, int k);
virtual void SetMax(PVAL vp);
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
#endif // 0
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:
// int SafeAdd(int n1, int n2);
// int SafeMult(int n1, int n2);
// Default constructor not to be used
INTVAL(void) : VALUE(TYPE_ERROR) {}
// Members
int Ival;
}; // end of class INTVAL
/***********************************************************************/ /***********************************************************************/
/* Class DTVAL: represents a time stamp value. */ /* Class DTVAL: represents a time stamp value. */
/***********************************************************************/ /***********************************************************************/
class DllExport DTVAL : public INTVAL { class DllExport DTVAL : public TYPVAL<int> {
public: public:
// Constructors // Constructors
DTVAL(PGLOBAL g, int n, int p, PSZ fmt); DTVAL(PGLOBAL g, int n, int p, PSZ fmt);
...@@ -418,8 +249,6 @@ class DllExport DTVAL : public INTVAL { ...@@ -418,8 +249,6 @@ class DllExport DTVAL : public INTVAL {
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
//virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
//virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, char *fmt);
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
bool SetFormat(PGLOBAL g, PVAL valp); bool SetFormat(PGLOBAL g, PVAL valp);
...@@ -438,186 +267,13 @@ class DllExport DTVAL : public INTVAL { ...@@ -438,186 +267,13 @@ class DllExport DTVAL : public INTVAL {
protected: protected:
// Default constructor not to be used // Default constructor not to be used
DTVAL(void) : INTVAL() {} DTVAL(void) : TYPVAL<int>() {}
// Members // Members
static int Shift; // Time zone shift in seconds static int Shift; // Time zone shift in seconds
PDTP Pdtp; // To the DATPAR structure PDTP Pdtp; // To the DATPAR structure
char *Sdate; // Utility char buffer char *Sdate; // Utility char buffer
//struct tm *DateTime; // Utility (not used yet)
int DefYear; // Used by ExtractDate int DefYear; // Used by ExtractDate
int Len; // Used by CHAR scalar function
}; // end of class DTVAL }; // end of class DTVAL
/***********************************************************************/ #endif // __VALUE__H__
/* Class BIGVAL: represents bigint integer values. */
/***********************************************************************/
class DllExport BIGVAL : public VALUE {
public:
// Constructors
BIGVAL(PSZ s);
BIGVAL(short i);
BIGVAL(int n);
BIGVAL(longlong n);
BIGVAL(double f);
// Implementation
virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return Lval == 0LL;}
virtual void Reset(void) {Lval = 0LL;}
virtual int GetValLen(void);
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(longlong);}
//virtual PSZ GetCharValue(void) {}
virtual short GetShortValue(void) {return (short)Lval;}
virtual int GetIntValue(void) {return (int)Lval;}
virtual longlong GetBigintValue(void) {return Lval;}
virtual double GetFloatValue(void) {return (double)Lval;}
virtual void *GetTo_Val(void) {return &Lval;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue_bool(bool b) {Lval = (b) ? 1LL : 0LL;}
virtual void SetValue(short i) {Lval = (longlong)i;}
virtual void SetValue(int n) {Lval = (longlong)n;}
virtual void SetValue(longlong n) {Lval = n;}
virtual void SetValue(double f) {Lval = (longlong)f;}
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
virtual char *GetIntString(char *p, int n);
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
#if 0
virtual int CompareValue(PVAL vp);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(int lv) {Lval += (longlong)lv;}
virtual void Add(PVAL vp);
virtual void Add(PVBLK vbp, int i);
virtual void Add(PVBLK vbp, int j, int k);
virtual void Add(PVBLK vbp, int *x, int j, int k);
virtual void AddSquare(PVAL vp);
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
virtual void Divide(int cnt);
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
virtual void SetMin(PVBLK vbp, int *x, int j, int k);
virtual void SetMax(PVAL vp);
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np) {return 0;}
#endif // 0
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:
// longlong SafeAdd(longlong n1, longlong n2);
// longlong SafeMult(longlong n1, longlong n2);
// Default constructor not to be used
BIGVAL(void) : VALUE(TYPE_ERROR) {}
// Members
longlong Lval;
}; // end of class BIGVAL
/***********************************************************************/
/* Class DFVAL: represents double float values. */
/***********************************************************************/
class DFVAL : public VALUE {
public:
// Constructors
DFVAL(PSZ s, int prec = 2);
DFVAL(short i, int prec = 2);
DFVAL(int n, int prec = 2);
DFVAL(longlong n, int prec = 2);
DFVAL(double f, int prec = 2);
// Implementation
virtual bool IsTypeNum(void) {return true;}
virtual bool IsZero(void) {return Fval == 0.0;}
virtual void Reset(void) {Fval = 0.0;}
virtual int GetValLen(void);
virtual int GetValPrec() {return Prec;}
virtual int GetSize(void) {return sizeof(double);}
//virtual PSZ GetCharValue(void) {}
virtual short GetShortValue(void) {return (short)Fval;}
virtual int GetIntValue(void) {return (int)Fval;}
virtual longlong GetBigintValue(void) {return (longlong)Fval;}
virtual double GetFloatValue(void) {return Fval;}
virtual void *GetTo_Val(void) {return &Fval;}
void SetPrec(int prec) {Prec = prec;}
// Methods
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue(short i) {Fval = (double)i;}
virtual void SetValue(int n) {Fval = (double)n;}
virtual void SetValue(longlong n) {Fval = (double)n;}
virtual void SetValue(double f) {Fval = f;}
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
//virtual void GetBinValue(void *buf, int len);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual char *GetShortString(char *p, int n);
virtual char *GetIntString(char *p, int n);
virtual char *GetBigintString(char *p, int n);
virtual char *GetFloatString(char *p, int n, int prec = -1);
virtual bool IsEqual(PVAL vp, bool chktype);
#if 0
virtual int CompareValue(PVAL vp);
virtual void StdVar(PVAL vp, int cnt, bool b);
virtual void Add(PVAL vp);
virtual void Add(PVBLK vbp, int i);
virtual void Add(PVBLK vbp, int j, int k);
virtual void Add(PVBLK vbp, int *x, int j, int k);
virtual void AddSquare(PVAL vp);
virtual void AddSquare(PVBLK vbp, int i);
virtual void AddSquare(PVBLK vbp, int j, int k);
virtual void Times(PVAL vp);
virtual void Divide(int cnt)
virtual void SetMin(PVAL vp);
virtual void SetMin(PVBLK vbp, int i);
virtual void SetMin(PVBLK vbp, int j, int k);
virtual void SetMin(PVBLK vbp, int *x, int j, int k);
virtual void SetMax(PVAL vp);
virtual void SetMax(PVBLK vbp, int i);
virtual void SetMax(PVBLK vbp, int j, int k);
virtual void SetMax(PVBLK vbp, int *x, int j, int k);
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual int GetTime(PGLOBAL g, PVAL *vp, int np);
#endif // 0
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);
// Specific function
void Divide(double d) {Fval /= d;}
protected:
// Default constructor not to be used
DFVAL(void) : VALUE(TYPE_ERROR) {}
// Members
double Fval;
int Prec;
}; // end of class DFVAL
#endif
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
/***********************************************************************/ /***********************************************************************/
/* Types used in some class definitions. */ /* Types used in some class definitions. */
/***********************************************************************/ /***********************************************************************/
typedef struct _tabdesc *PTABD; // For friend setting //typedef struct _tabdesc *PTABD; // For friend setting
/***********************************************************************/ /***********************************************************************/
/* The pointer to the one and only needed void object. */ /* The pointer to the one and only needed void object. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment