Commit 385dbaea authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix gcc compilation warnings

modified:
  storage/connect/odbconn.cpp

- Prepare Value and Valblk to support unsigned data types
  (not operational yet)

modified:
  storage/connect/colblk.cpp
  storage/connect/filamvct.cpp
  storage/connect/myconn.cpp
  storage/connect/plgdbutl.cpp
  storage/connect/tabdos.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabvct.cpp
  storage/connect/valblk.cpp
  storage/connect/valblk.h
  storage/connect/value.cpp
  storage/connect/value.h
  storage/connect/xindex.cpp
parent aaa982e7
...@@ -164,8 +164,7 @@ bool COLBLK::CheckSort(PTDB tdbp) ...@@ -164,8 +164,7 @@ bool COLBLK::CheckSort(PTDB tdbp)
/* Now we use Format.Length for the len parameter to avoid strings */ /* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */ /* to be truncated when converting from string to coded string. */
/* Added in version 1.5 is the arguments GetPrecision() and Domain */ /* Added in version 1.5 is the arguments GetPrecision() and Domain */
/* in calling AllocateValue. Domain is used for TYPE_TOKEN only, */ /* in calling AllocateValue. Domain is used for TYPE_DATE only. */
/* but why was GetPrecision() not specified ? To be checked. */
/***********************************************************************/ /***********************************************************************/
bool COLBLK::InitValue(PGLOBAL g) bool COLBLK::InitValue(PGLOBAL g)
{ {
...@@ -174,8 +173,7 @@ bool COLBLK::InitValue(PGLOBAL g) ...@@ -174,8 +173,7 @@ bool COLBLK::InitValue(PGLOBAL g)
// Allocate a Value object // Allocate a Value object
if (!(Value = AllocateValue(g, Buf_Type, Format.Length, if (!(Value = AllocateValue(g, Buf_Type, Format.Length,
GetPrecision(), GetDomain(), GetPrecision(), GetDomain())))
(To_Tdb) ? To_Tdb->GetCat() : NULL)))
return true; return true;
AddStatus(BUF_READY); AddStatus(BUF_READY);
......
...@@ -91,7 +91,7 @@ typedef struct _vecheader { ...@@ -91,7 +91,7 @@ typedef struct _vecheader {
/* Conversion of block values allowed conditionally for insert only. */ /* Conversion of block values allowed conditionally for insert only. */
/***********************************************************************/ /***********************************************************************/
PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
bool check = true, bool blank = true); bool check = true, bool blank = true, bool un = false);
/* -------------------------- Class VCTFAM --------------------------- */ /* -------------------------- Class VCTFAM --------------------------- */
......
...@@ -709,7 +709,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) ...@@ -709,7 +709,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Clen = GetTypeSize(crp->Type, crp->Length); crp->Clen = GetTypeSize(crp->Type, crp->Length);
if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows, if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,
crp->Clen, 0, FALSE, TRUE))) { crp->Clen, 0, FALSE, TRUE, FALSE))) {
sprintf(g->Message, MSG(INV_RESULT_TYPE), sprintf(g->Message, MSG(INV_RESULT_TYPE),
GetFormatType(crp->Type)); GetFormatType(crp->Type));
return NULL; return NULL;
......
...@@ -1118,7 +1118,7 @@ bool ODBConn::Connect(DWORD Options) ...@@ -1118,7 +1118,7 @@ bool ODBConn::Connect(DWORD Options)
if (hWnd == NULL) if (hWnd == NULL)
hWnd = GetDesktopWindow(); hWnd = GetDesktopWindow();
#else // !WIN32 #else // !WIN32
HWND hWnd = 1; HWND hWnd = (HWND)1;
#endif // !WIN32 #endif // !WIN32
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
...@@ -1240,8 +1240,8 @@ void ODBConn::GetConnectInfo() ...@@ -1240,8 +1240,8 @@ void ODBConn::GetConnectInfo()
m_IDQuoteChar, sizeof(m_IDQuoteChar), &nResult); m_IDQuoteChar, sizeof(m_IDQuoteChar), &nResult);
if (trace) if (trace)
htrc("DBMS: %s, Version: %s\n", htrc("DBMS: %s, Version: %s, rc=%d\n",
GetStringInfo(SQL_DBMS_NAME), GetStringInfo(SQL_DBMS_VER)); GetStringInfo(SQL_DBMS_NAME), GetStringInfo(SQL_DBMS_VER), rc);
} // end of GetConnectInfo } // end of GetConnectInfo
......
...@@ -330,7 +330,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, ...@@ -330,7 +330,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
// Allocate the Value Block that will contain data // Allocate the Value Block that will contain data
if (crp->Length || nonull) if (crp->Length || nonull)
crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres, crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres,
crp->Length, 0, true, blank); crp->Length, 0, true, blank, false);
else else
crp->Kdata = NULL; crp->Kdata = NULL;
......
...@@ -77,7 +77,7 @@ extern "C" int trace; ...@@ -77,7 +77,7 @@ extern "C" int trace;
/* No conversion of block values (check = true). */ /* No conversion of block values (check = true). */
/***********************************************************************/ /***********************************************************************/
PVBLK AllocValBlock(PGLOBAL, void *, int, int, int len = 0, int prec = 0, PVBLK AllocValBlock(PGLOBAL, void *, int, int, int len = 0, int prec = 0,
bool check = true, bool blank = false); bool check = true, bool blank = false, bool un = false);
/* --------------------------- Class DOSDEF -------------------------- */ /* --------------------------- Class DOSDEF -------------------------- */
......
...@@ -1078,7 +1078,7 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows) ...@@ -1078,7 +1078,7 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows)
if (Buf_Type == TYPE_DATE) if (Buf_Type == TYPE_DATE)
Bufp = PlugSubAlloc(g, NULL, rows * sizeof(TIMESTAMP_STRUCT)); Bufp = PlugSubAlloc(g, NULL, rows * sizeof(TIMESTAMP_STRUCT));
else { else {
Blkp = AllocValBlock(g, NULL, Buf_Type, rows, Long+1, 0, true, false); Blkp = AllocValBlock(g, NULL, Buf_Type, rows, Long+1, 0, true, false, false);
Bufp = Blkp->GetValPointer(); Bufp = Blkp->GetValPointer();
} // endelse } // endelse
......
...@@ -81,7 +81,7 @@ char *strerror(int num); ...@@ -81,7 +81,7 @@ char *strerror(int num);
/* Conversion of block values allowed conditionally for insert only. */ /* Conversion of block values allowed conditionally for insert only. */
/***********************************************************************/ /***********************************************************************/
PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
bool check = true, bool blank = true); bool check = true, bool blank = true, bool un = false);
/* --------------------------- Class VCTDEF -------------------------- */ /* --------------------------- Class VCTDEF -------------------------- */
......
/************ Valblk C++ Functions Source Code File (.CPP) *************/ /************ Valblk C++ Functions Source Code File (.CPP) *************/
/* Name: VALBLK.CPP Version 1.7 */ /* Name: VALBLK.CPP Version 2.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */ /* */
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/* types of objects, we shall have more classes to update. */ /* types of objects, we shall have more classes to update. */
/* This is why we are now using a template class for many types. */ /* This is why we are now using a template class for many types. */
/* Currently the only implemented types are PSZ, chars, int, short, */ /* Currently the only implemented types are PSZ, chars, int, short, */
/* DATE, longlong, and double. Shortly we should add more types. */ /* DATE, longlong, double and tiny. Fix numeric ones can be unsigned. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
/* AllocValBlock: allocate a VALBLK according to type. */ /* AllocValBlock: allocate a VALBLK according to type. */
/***********************************************************************/ /***********************************************************************/
PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
int prec, bool check, bool blank) int prec, bool check, bool blank, bool un)
{ {
PVBLK blkp; PVBLK blkp;
...@@ -64,22 +64,38 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, ...@@ -64,22 +64,38 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
break; break;
case TYPE_SHORT: case TYPE_SHORT:
if (un)
blkp = new(g) TYPBLK<ushort>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<short>(mp, nval, type); blkp = new(g) TYPBLK<short>(mp, nval, type);
break; break;
case TYPE_INT: case TYPE_INT:
if (un)
blkp = new(g) TYPBLK<uint>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<int>(mp, nval, type); blkp = new(g) TYPBLK<int>(mp, nval, type);
break; break;
case TYPE_DATE: // ????? case TYPE_DATE: // ?????
blkp = new(g) DATBLK(mp, nval); blkp = new(g) DATBLK(mp, nval);
break; break;
case TYPE_BIGINT: case TYPE_BIGINT:
if (un)
blkp = new(g) TYPBLK<ulonglong>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<longlong>(mp, nval, type); blkp = new(g) TYPBLK<longlong>(mp, nval, type);
break; break;
case TYPE_FLOAT: case TYPE_FLOAT:
blkp = new(g) TYPBLK<double>(mp, nval, prec, type); blkp = new(g) TYPBLK<double>(mp, nval, type, prec);
break; break;
case TYPE_TINY: case TYPE_TINY:
if (un)
blkp = new(g) TYPBLK<uchar>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<char>(mp, nval, type); blkp = new(g) TYPBLK<char>(mp, nval, type);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type); sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type);
...@@ -95,12 +111,13 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len, ...@@ -95,12 +111,13 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
/***********************************************************************/ /***********************************************************************/
/* Constructor. */ /* Constructor. */
/***********************************************************************/ /***********************************************************************/
VALBLK::VALBLK(void *mp, int type, int nval) VALBLK::VALBLK(void *mp, int type, int nval, bool un)
{ {
Blkp = mp; Blkp = mp;
To_Nulls = NULL; To_Nulls = NULL;
Check = true; Check = true;
Nullable = false; Nullable = false;
Unsigned = un;
Type = type; Type = type;
Nval = nval; Nval = nval;
Prec = 0; Prec = 0;
...@@ -195,23 +212,15 @@ void VALBLK::ChkTyp(PVBLK vb) ...@@ -195,23 +212,15 @@ void VALBLK::ChkTyp(PVBLK vb)
/* -------------------------- Class TYPBLK --------------------------- */ /* -------------------------- Class TYPBLK --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* Constructors. */ /* Constructor. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type) TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type, int prec, bool un)
: VALBLK(mp, type, nval), Typp((TYPE*&)Blkp) : VALBLK(mp, type, nval, un), Typp((TYPE*&)Blkp)
{
Fmt = GetFmt(Type);
} // end of TYPBLK constructor
template <class TYPE>
TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int prec, int type)
: VALBLK(mp, type, nval), Typp((TYPE*&)Blkp)
{ {
DBUG_ASSERT(Type == TYPE_FLOAT);
Prec = prec; Prec = prec;
Fmt = GetFmt(Type); Fmt = GetFmt(Type);
} // end of DBLBLK constructor } // end of TYPBLK constructor
/***********************************************************************/ /***********************************************************************/
/* Initialization routine. */ /* Initialization routine. */
...@@ -249,14 +258,25 @@ template <> ...@@ -249,14 +258,25 @@ template <>
int TYPBLK<int>::GetTypedValue(PVAL valp) int TYPBLK<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();} {return valp->GetIntValue();}
uint TYPBLK<uint>::GetTypedValue(PVAL valp)
{return valp->GetUIntValue();}
template <> template <>
short TYPBLK<short>::GetTypedValue(PVAL valp) short TYPBLK<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();} {return valp->GetShortValue();}
template <>
ushort TYPBLK<ushort>::GetTypedValue(PVAL valp)
{return valp->GetUShortValue();}
template <> template <>
longlong TYPBLK<longlong>::GetTypedValue(PVAL valp) longlong TYPBLK<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();} {return valp->GetBigintValue();}
template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PVAL valp)
{return valp->GetUBigintValue();}
template <> template <>
double TYPBLK<double>::GetTypedValue(PVAL valp) double TYPBLK<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();} {return valp->GetFloatValue();}
...@@ -265,6 +285,10 @@ template <> ...@@ -265,6 +285,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVAL valp) char TYPBLK<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();} {return valp->GetTinyValue();}
template <>
uchar TYPBLK<uchar>::GetTypedValue(PVAL valp)
{return valp->GetUTinyValue();}
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from a zero terminated string. */ /* Set one value in a block from a zero terminated string. */
/***********************************************************************/ /***********************************************************************/
...@@ -286,13 +310,21 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n) ...@@ -286,13 +310,21 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
template <> template <>
int TYPBLK<int>::GetTypedValue(PSZ p) {return atol(p);} int TYPBLK<int>::GetTypedValue(PSZ p) {return atol(p);}
template <> template <>
uint TYPBLK<uint>::GetTypedValue(PSZ p) {return (unsigned)atol(p);}
template <>
short TYPBLK<short>::GetTypedValue(PSZ p) {return (short)atoi(p);} short TYPBLK<short>::GetTypedValue(PSZ p) {return (short)atoi(p);}
template <> template <>
ushort TYPBLK<ushort>::GetTypedValue(PSZ p) {return (ushort)atoi(p);}
template <>
longlong TYPBLK<longlong>::GetTypedValue(PSZ p) {return atoll(p);} longlong TYPBLK<longlong>::GetTypedValue(PSZ p) {return atoll(p);}
template <> template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PSZ p) {return (unsigned)atoll(p);}
template <>
double TYPBLK<double>::GetTypedValue(PSZ p) {return atof(p);} double TYPBLK<double>::GetTypedValue(PSZ p) {return atof(p);}
template <> template <>
char TYPBLK<char>::GetTypedValue(PSZ p) {return (char)atoi(p);} char TYPBLK<char>::GetTypedValue(PSZ p) {return (char)atoi(p);}
template <>
uchar TYPBLK<uchar>::GetTypedValue(PSZ p) {return (uchar)atoi(p);}
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block from an array of characters. */ /* Set one value in a block from an array of characters. */
...@@ -333,14 +365,26 @@ template <> ...@@ -333,14 +365,26 @@ template <>
int TYPBLK<int>::GetTypedValue(PVBLK blk, int n) int TYPBLK<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);} {return blk->GetIntValue(n);}
template <>
uint TYPBLK<uint>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUIntValue(n);}
template <> template <>
short TYPBLK<short>::GetTypedValue(PVBLK blk, int n) short TYPBLK<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);} {return blk->GetShortValue(n);}
template <>
ushort TYPBLK<ushort>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUShortValue(n);}
template <> template <>
longlong TYPBLK<longlong>::GetTypedValue(PVBLK blk, int n) longlong TYPBLK<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);} {return blk->GetBigintValue(n);}
template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUBigintValue(n);}
template <> template <>
double TYPBLK<double>::GetTypedValue(PVBLK blk, int n) double TYPBLK<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);} {return blk->GetFloatValue(n);}
...@@ -349,6 +393,10 @@ template <> ...@@ -349,6 +393,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVBLK blk, int n) char TYPBLK<char>::GetTypedValue(PVBLK blk, int n)
{return blk->GetTinyValue(n);} {return blk->GetTinyValue(n);}
template <>
uchar TYPBLK<uchar>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUTinyValue(n);}
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
/* Set many values in a block from values in another block. */ /* Set many values in a block from values in another block. */
...@@ -516,6 +564,14 @@ short CHRBLK::GetShortValue(int n) ...@@ -516,6 +564,14 @@ short CHRBLK::GetShortValue(int n)
return (short)atoi((char *)GetValPtrEx(n)); return (short)atoi((char *)GetValPtrEx(n));
} // end of GetShortValue } // end of GetShortValue
/***********************************************************************/
/* Return the value of the nth element converted to ushort. */
/***********************************************************************/
ushort CHRBLK::GetUShortValue(int n)
{
return (ushort)atoi((char *)GetValPtrEx(n));
} // end of GetShortValue
/***********************************************************************/ /***********************************************************************/
/* Return the value of the nth element converted to int. */ /* Return the value of the nth element converted to int. */
/***********************************************************************/ /***********************************************************************/
...@@ -524,6 +580,14 @@ int CHRBLK::GetIntValue(int n) ...@@ -524,6 +580,14 @@ int CHRBLK::GetIntValue(int n)
return atol((char *)GetValPtrEx(n)); return atol((char *)GetValPtrEx(n));
} // end of GetIntValue } // end of GetIntValue
/***********************************************************************/
/* Return the value of the nth element converted to uint. */
/***********************************************************************/
uint CHRBLK::GetUIntValue(int n)
{
return (unsigned)atol((char *)GetValPtrEx(n));
} // end of GetIntValue
/***********************************************************************/ /***********************************************************************/
/* Return the value of the nth element converted to big int. */ /* Return the value of the nth element converted to big int. */
/***********************************************************************/ /***********************************************************************/
...@@ -532,6 +596,14 @@ longlong CHRBLK::GetBigintValue(int n) ...@@ -532,6 +596,14 @@ longlong CHRBLK::GetBigintValue(int n)
return atoll((char *)GetValPtrEx(n)); return atoll((char *)GetValPtrEx(n));
} // end of GetBigintValue } // end of GetBigintValue
/***********************************************************************/
/* Return the value of the nth element converted to unsigned big int. */
/***********************************************************************/
ulonglong CHRBLK::GetUBigintValue(int n)
{
return (unsigned)atoll((char *)GetValPtrEx(n));
} // end of GetBigintValue
/***********************************************************************/ /***********************************************************************/
/* Return the value of the nth element converted to double. */ /* Return the value of the nth element converted to double. */
/***********************************************************************/ /***********************************************************************/
...@@ -548,6 +620,14 @@ char CHRBLK::GetTinyValue(int n) ...@@ -548,6 +620,14 @@ char CHRBLK::GetTinyValue(int n)
return (char)atoi((char *)GetValPtrEx(n)); return (char)atoi((char *)GetValPtrEx(n));
} // end of GetTinyValue } // end of GetTinyValue
/***********************************************************************/
/* Return the value of the nth element converted to unsigned tiny int.*/
/***********************************************************************/
uchar CHRBLK::GetUTinyValue(int n)
{
return (uchar)atoi((char *)GetValPtrEx(n));
} // end of GetTinyValue
/***********************************************************************/ /***********************************************************************/
/* Set one value in a block. */ /* Set one value in a block. */
/***********************************************************************/ /***********************************************************************/
......
/*************** Valblk H Declares Source Code File (.H) ***************/ /*************** Valblk H Declares Source Code File (.H) ***************/
/* Name: VALBLK.H Version 1.9 */ /* Name: VALBLK.H Version 2.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
/* */ /* */
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
/***********************************************************************/ /***********************************************************************/
/* Utility used to allocate value blocks. */ /* Utility used to allocate value blocks. */
/***********************************************************************/ /***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool); DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int,
const char *GetFmt(int type); bool, bool, bool);
const char *GetFmt(int type, bool un = false);
/***********************************************************************/ /***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */ /* Class VALBLK represent a base class for variable blocks. */
...@@ -28,7 +29,7 @@ class VALBLK : public BLOCK { ...@@ -28,7 +29,7 @@ class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp); //friend void SemColData(PGLOBAL g, PSEM semp);
public: public:
// Constructors // Constructors
VALBLK(void *mp, int type, int nval); VALBLK(void *mp, int type, int nval, bool un = false);
// Implementation // Implementation
int GetNval(void) {return Nval;} int GetNval(void) {return Nval;}
...@@ -48,10 +49,14 @@ class VALBLK : public BLOCK { ...@@ -48,10 +49,14 @@ class VALBLK : public BLOCK {
virtual int GetVlen(void) = 0; virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n); virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) = 0; virtual short GetShortValue(int n) = 0;
virtual ushort GetUShortValue(int n) = 0;
virtual int GetIntValue(int n) = 0; virtual int GetIntValue(int n) = 0;
virtual uint GetUIntValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0; virtual longlong GetBigintValue(int n) = 0;
virtual ulonglong GetUBigintValue(int n) = 0;
virtual double GetFloatValue(int n) = 0; virtual double GetFloatValue(int n) = 0;
virtual char GetTinyValue(int n) = 0; virtual char GetTinyValue(int n) = 0;
virtual uchar GetUTinyValue(int n) = 0;
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;}
virtual void Reset(int n) = 0; virtual void Reset(int n) = 0;
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
...@@ -60,10 +65,14 @@ class VALBLK : public BLOCK { ...@@ -60,10 +65,14 @@ class VALBLK : public BLOCK {
// Methods // Methods
virtual void SetValue(short sval, int n) {assert(false);} virtual void SetValue(short sval, int n) {assert(false);}
virtual void SetValue(ushort sval, int n) {assert(false);}
virtual void SetValue(int lval, int n) {assert(false);} virtual void SetValue(int lval, int n) {assert(false);}
virtual void SetValue(uint lval, int n) {assert(false);}
virtual void SetValue(longlong lval, int n) {assert(false);} virtual void SetValue(longlong lval, int n) {assert(false);}
virtual void SetValue(ulonglong lval, int n) {assert(false);}
virtual void SetValue(double fval, int n) {assert(false);} virtual void SetValue(double fval, int n) {assert(false);}
virtual void SetValue(char cval, int n) {assert(false);} virtual void SetValue(char cval, int n) {assert(false);}
virtual void SetValue(uchar cval, int n) {assert(false);}
virtual void SetValue(PSZ sp, int n) {assert(false);} virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(char *sp, uint len, int n) {assert(false);} virtual void SetValue(char *sp, uint len, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVAL valp, int n) = 0;
...@@ -94,6 +103,7 @@ class VALBLK : public BLOCK { ...@@ -94,6 +103,7 @@ class VALBLK : public BLOCK {
void *Blkp; // To value block void *Blkp; // To value block
bool Check; // If true SetValue types must match bool Check; // If true SetValue types must match
bool Nullable; // True if values can be null bool Nullable; // True if values can be null
bool Unsigned; // True if values are unsigned
int Type; // Type of individual values int Type; // Type of individual values
int Nval; // Max number of values in block int Nval; // Max number of values in block
int Prec; // Precision of float values int Prec; // Precision of float values
...@@ -106,18 +116,22 @@ template <class TYPE> ...@@ -106,18 +116,22 @@ template <class TYPE>
class TYPBLK : public VALBLK { class TYPBLK : public VALBLK {
public: public:
// Constructors // Constructors
TYPBLK(void *mp, int size, int type); TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false);
TYPBLK(void *mp, int size, int prec, int type); //TYPBLK(void *mp, int size, int prec, int type);
// Implementation // Implementation
virtual void Init(PGLOBAL g, bool check); virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(TYPE);} virtual int GetVlen(void) {return sizeof(TYPE);}
//virtual PSZ GetCharValue(int n); //virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) {return (short)Typp[n];} virtual short GetShortValue(int n) {return (short)Typp[n];}
virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];}
virtual int GetIntValue(int n) {return (int)Typp[n];} virtual int GetIntValue(int n) {return (int)Typp[n];}
virtual uint GetUIntValue(int n) {return (uint)Typp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];} virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];}
virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];}
virtual double GetFloatValue(int n) {return (double)Typp[n];} virtual double GetFloatValue(int n) {return (double)Typp[n];}
virtual char GetTinyValue(int n) {return (char)Typp[n];} virtual char GetTinyValue(int n) {return (char)Typp[n];}
virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];}
virtual void Reset(int n) {Typp[n] = 0;} virtual void Reset(int n) {Typp[n] = 0;}
// Methods // Methods
...@@ -125,14 +139,22 @@ class TYPBLK : public VALBLK { ...@@ -125,14 +139,22 @@ class TYPBLK : public VALBLK {
virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(char *sp, uint len, int n);
virtual void SetValue(short sval, int n) virtual void SetValue(short sval, int n)
{Typp[n] = (TYPE)sval; SetNull(n, false);} {Typp[n] = (TYPE)sval; SetNull(n, false);}
virtual void SetValue(ushort sval, int n)
{Typp[n] = (TYPE)sval; SetNull(n, false);}
virtual void SetValue(int lval, int n) virtual void SetValue(int lval, int n)
{Typp[n] = (TYPE)lval; SetNull(n, false);} {Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void SetValue(uint lval, int n)
{Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void SetValue(longlong lval, int n) virtual void SetValue(longlong lval, int n)
{Typp[n] = (TYPE)lval; SetNull(n, false);} {Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void SetValue(ulonglong lval, int n)
{Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void SetValue(double fval, int n) virtual void SetValue(double fval, int n)
{Typp[n] = (TYPE)fval; SetNull(n, false);} {Typp[n] = (TYPE)fval; SetNull(n, false);}
virtual void SetValue(char cval, int n) virtual void SetValue(char cval, int n)
{Typp[n] = (TYPE)cval; SetNull(n, false);} {Typp[n] = (TYPE)cval; SetNull(n, false);}
virtual void SetValue(uchar cval, int n)
{Typp[n] = (TYPE)cval; SetNull(n, false);}
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
//virtual void SetValues(PVBLK pv, int k, int n); //virtual void SetValues(PVBLK pv, int k, int n);
...@@ -168,10 +190,14 @@ class CHRBLK : public VALBLK { ...@@ -168,10 +190,14 @@ class CHRBLK : public VALBLK {
virtual int GetVlen(void) {return Long;} virtual int GetVlen(void) {return Long;}
virtual PSZ GetCharValue(int n); virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n); virtual short GetShortValue(int n);
virtual ushort GetUShortValue(int n);
virtual int GetIntValue(int n); virtual int GetIntValue(int n);
virtual uint GetUIntValue(int n);
virtual longlong GetBigintValue(int n); virtual longlong GetBigintValue(int n);
virtual ulonglong GetUBigintValue(int n);
virtual double GetFloatValue(int n); virtual double GetFloatValue(int n);
virtual char GetTinyValue(int n); virtual char GetTinyValue(int n);
virtual uchar GetUTinyValue(int n);
virtual void Reset(int n); virtual void Reset(int n);
virtual void SetPrec(int p) {Ci = (p != 0);} virtual void SetPrec(int p) {Ci = (p != 0);}
virtual bool IsCi(void) {return Ci;} virtual bool IsCi(void) {return Ci;}
...@@ -217,10 +243,14 @@ class STRBLK : public VALBLK { ...@@ -217,10 +243,14 @@ class STRBLK : public VALBLK {
virtual int GetVlen(void) {return sizeof(PSZ);} virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];} virtual PSZ GetCharValue(int n) {return Strp[n];}
virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);} virtual short GetShortValue(int n) {return (short)atoi(Strp[n]);}
virtual ushort GetUShortValue(int n) {return (ushort)atoi(Strp[n]);}
virtual int GetIntValue(int n) {return atol(Strp[n]);} virtual int GetIntValue(int n) {return atol(Strp[n]);}
virtual uint GetUIntValue(int n) {return (unsigned)atol(Strp[n]);}
virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);} virtual longlong GetBigintValue(int n) {return atoll(Strp[n]);}
virtual ulonglong GetUBigintValue(int n) {return (unsigned)atoll(Strp[n]);}
virtual double GetFloatValue(int n) {return atof(Strp[n]);} virtual double GetFloatValue(int n) {return atof(Strp[n]);}
virtual char GetTinyValue(int n) {return (char)atoi(Strp[n]);} virtual char GetTinyValue(int n) {return (char)atoi(Strp[n]);}
virtual uchar GetUTinyValue(int n) {return (uchar)atoi(Strp[n]);}
virtual void Reset(int n) {Strp[n] = NULL;} virtual void Reset(int n) {Strp[n] = NULL;}
// Methods // Methods
......
/************* Value C++ Functions Source Code File (.CPP) *************/ /************* Value C++ Functions Source Code File (.CPP) *************/
/* Name: VALUE.CPP Version 2.2 */ /* Name: VALUE.CPP Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
/* */ /* */
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
/* functions used on one family only. The drawback is that for new */ /* functions used on one family only. The drawback is that for new */
/* types of objects, we shall have more classes to update. */ /* types of objects, we shall have more classes to update. */
/* Currently the only implemented types are STRING, INT, SHORT, TINY, */ /* Currently the only implemented types are STRING, INT, SHORT, TINY, */
/* DATE and LONGLONG. Shortly we should add at least UNSIGNED types. */ /* DATE and LONGLONG. Recently we added some UNSIGNED types. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
...@@ -92,40 +92,12 @@ PSZ strlwr(PSZ s); ...@@ -92,40 +92,12 @@ PSZ strlwr(PSZ s);
} }
#endif // !WIN32 #endif // !WIN32
#ifdef NOT_USED
/***********************************************************************/
/* Returns the bitmap representing the conditions that must not be */
/* met when returning from TestValue for a given operator. */
/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */
/***********************************************************************/
static BYTE OpBmp(PGLOBAL g, OPVAL opc)
{
BYTE bt;
switch (opc) {
case OP_IN:
case OP_EQ: bt = 0x06; break;
case OP_NE: bt = 0x01; break;
case OP_GT: bt = 0x03; break;
case OP_GE: bt = 0x02; break;
case OP_LT: bt = 0x05; break;
case OP_LE: bt = 0x04; break;
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
longjmp(g->jumper[g->jump_level], 777);
} // endswitch opc
return bt;
} // end of OpBmp
#endif
/***********************************************************************/ /***********************************************************************/
/* GetTypeName: returns the PlugDB internal type name. */ /* GetTypeName: returns the PlugDB internal type name. */
/***********************************************************************/ /***********************************************************************/
PSZ GetTypeName(int type) PSZ GetTypeName(int type)
{ {
PSZ name = "UNKNOWN"; PSZ name;
switch (type) { switch (type) {
case TYPE_STRING: name = "CHAR"; break; case TYPE_STRING: name = "CHAR"; break;
...@@ -135,6 +107,7 @@ PSZ GetTypeName(int type) ...@@ -135,6 +107,7 @@ PSZ GetTypeName(int type)
case TYPE_DATE: name = "DATE"; break; case TYPE_DATE: name = "DATE"; break;
case TYPE_FLOAT: name = "FLOAT"; break; case TYPE_FLOAT: name = "FLOAT"; break;
case TYPE_TINY: name = "TINY"; break; case TYPE_TINY: name = "TINY"; break;
default: name = "UNKNOWN"; break;
} // endswitch type } // endswitch type
return name; return name;
...@@ -153,7 +126,6 @@ int GetTypeSize(int type, int len) ...@@ -153,7 +126,6 @@ int GetTypeSize(int type, int len)
case TYPE_DATE: len = sizeof(int); break; case TYPE_DATE: len = sizeof(int); break;
case TYPE_FLOAT: len = sizeof(double); break; case TYPE_FLOAT: len = sizeof(double); break;
case TYPE_TINY: len = sizeof(char); break; case TYPE_TINY: len = sizeof(char); break;
break;
default: len = 0; default: len = 0;
} // endswitch type } // endswitch type
...@@ -236,21 +208,22 @@ bool IsTypeNum(int type) ...@@ -236,21 +208,22 @@ bool IsTypeNum(int type)
/***********************************************************************/ /***********************************************************************/
/* GetFmt: returns the format to use with a typed value. */ /* GetFmt: returns the format to use with a typed value. */
/***********************************************************************/ /***********************************************************************/
const char *GetFmt(int type) const char *GetFmt(int type, bool un)
{ {
const char *fmt; const char *fmt;
switch (type) { switch (type) {
case TYPE_STRING: fmt = "%s"; break; case TYPE_STRING: fmt = "%s"; break;
case TYPE_SHORT: fmt = "%hd"; break; case TYPE_SHORT: fmt = (un) ? "%hu" : "%hd"; break;
case TYPE_BIGINT: fmt = "%lld"; break; case TYPE_BIGINT: fmt = (un) ? "%llu" : "%lld"; break;
case TYPE_FLOAT: fmt = "%.*lf"; break; case TYPE_FLOAT: fmt = "%.*lf"; break;
default: fmt = "%d"; break; default: fmt = (un) ? "%u" : "%d"; break;
} // endswitch Type } // endswitch Type
return fmt; return fmt;
} // end of GetFmt } // end of GetFmt
#if 0
/***********************************************************************/ /***********************************************************************/
/* ConvertType: what this function does is to determine the type to */ /* ConvertType: what this function does is to determine the type to */
/* which should be converted a value so no precision would be lost. */ /* which should be converted a value so no precision would be lost. */
...@@ -297,6 +270,7 @@ int ConvertType(int target, int type, CONV kind, bool match) ...@@ -297,6 +270,7 @@ int ConvertType(int target, int type, CONV kind, bool match)
} // endswitch kind } // endswitch kind
} // end of ConvertType } // end of ConvertType
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* AllocateConstant: allocates a constant Value. */ /* AllocateConstant: allocates a constant Value. */
...@@ -339,8 +313,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type) ...@@ -339,8 +313,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type)
/***********************************************************************/ /***********************************************************************/
/* Allocate a variable Value according to type, length and precision. */ /* Allocate a variable Value according to type, length and precision. */
/***********************************************************************/ /***********************************************************************/
PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, PSZ fmt)
PSZ dom, PCATLG cat)
{ {
PVAL valp; PVAL valp;
...@@ -349,22 +322,38 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, ...@@ -349,22 +322,38 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
valp = new(g) TYPVAL<PSZ>(g, (PSZ)NULL, len, prec); valp = new(g) TYPVAL<PSZ>(g, (PSZ)NULL, len, prec);
break; break;
case TYPE_DATE: case TYPE_DATE:
valp = new(g) DTVAL(g, len, prec, dom); valp = new(g) DTVAL(g, len, prec, fmt);
break; break;
case TYPE_INT: case TYPE_INT:
if (prec)
valp = new(g) TYPVAL<uint>((uint)0, TYPE_INT, true);
else
valp = new(g) TYPVAL<int>((int)0, TYPE_INT); valp = new(g) TYPVAL<int>((int)0, TYPE_INT);
break; break;
case TYPE_BIGINT: case TYPE_BIGINT:
if (prec)
valp = new(g) TYPVAL<ulonglong>((ulonglong)0, TYPE_BIGINT, true);
else
valp = new(g) TYPVAL<longlong>((longlong)0, TYPE_BIGINT); valp = new(g) TYPVAL<longlong>((longlong)0, TYPE_BIGINT);
break; break;
case TYPE_SHORT: case TYPE_SHORT:
if (prec)
valp = new(g) TYPVAL<ushort>((ushort)0, TYPE_SHORT, true);
else
valp = new(g) TYPVAL<short>((short)0, TYPE_SHORT); valp = new(g) TYPVAL<short>((short)0, TYPE_SHORT);
break; break;
case TYPE_FLOAT: case TYPE_FLOAT:
valp = new(g) TYPVAL<double>(0.0, prec, TYPE_FLOAT); valp = new(g) TYPVAL<double>(0.0, prec, TYPE_FLOAT);
break; break;
case TYPE_TINY: case TYPE_TINY:
if (prec)
valp = new(g) TYPVAL<uchar>((uchar)0, TYPE_TINY, true);
else
valp = new(g) TYPVAL<char>((char)0, TYPE_TINY); valp = new(g) TYPVAL<char>((char)0, TYPE_TINY);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), type); sprintf(g->Message, MSG(BAD_VALUE_TYPE), type);
...@@ -379,9 +368,10 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, ...@@ -379,9 +368,10 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
/* Allocate a constant Value converted to newtype. */ /* Allocate a constant Value converted to newtype. */
/* Can also be used to copy a Value eventually converted. */ /* Can also be used to copy a Value eventually converted. */
/***********************************************************************/ /***********************************************************************/
PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype) PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
{ {
PSZ p, sp; PSZ p, sp;
bool un = (uns < 0) ? false : (uns > 0) ? true : valp->IsUnsigned();
if (newtype == TYPE_VOID) // Means allocate a value of the same type if (newtype == TYPE_VOID) // Means allocate a value of the same type
newtype = valp->GetType(); newtype = valp->GetType();
...@@ -396,13 +386,25 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype) ...@@ -396,13 +386,25 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
valp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec()); valp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
break; break;
case TYPE_SHORT: case TYPE_SHORT:
if (un)
valp = new(g) TYPVAL<ushort>(valp->GetUShortValue(), TYPE_SHORT, true);
else
valp = new(g) TYPVAL<short>(valp->GetShortValue(), TYPE_SHORT); valp = new(g) TYPVAL<short>(valp->GetShortValue(), TYPE_SHORT);
break; break;
case TYPE_INT: case TYPE_INT:
if (un)
valp = new(g) TYPVAL<uint>(valp->GetUIntValue(), TYPE_INT, true);
else
valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT); valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
break; break;
case TYPE_BIGINT: case TYPE_BIGINT:
if (un)
valp = new(g) TYPVAL<ulonglong>(valp->GetUBigintValue(), TYPE_BIGINT, true);
else
valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT); valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
break; break;
case TYPE_DATE: case TYPE_DATE:
valp = new(g) DTVAL(g, valp->GetIntValue()); valp = new(g) DTVAL(g, valp->GetIntValue());
...@@ -411,7 +413,11 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype) ...@@ -411,7 +413,11 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_FLOAT); valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_FLOAT);
break; break;
case TYPE_TINY: case TYPE_TINY:
if (un)
valp = new(g) TYPVAL<uchar>(valp->GetUTinyValue(), TYPE_TINY, true);
else
valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY); valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
break; break;
default: default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype); sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype);
...@@ -428,14 +434,15 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype) ...@@ -428,14 +434,15 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
/***********************************************************************/ /***********************************************************************/
/* Class VALUE protected constructor. */ /* Class VALUE protected constructor. */
/***********************************************************************/ /***********************************************************************/
VALUE::VALUE(int type) : Type(type) VALUE::VALUE(int type, bool un) : Type(type)
{ {
Fmt = GetFmt(Type);
Xfmt = GetXfmt();
Null = false; Null = false;
Nullable = false; Nullable = false;
Unsigned = un;
Clen = 0; Clen = 0;
Prec = 0; Prec = 0;
Fmt = GetFmt(Type, Unsigned);
Xfmt = GetXfmt();
} // end of VALUE constructor } // end of VALUE constructor
/***********************************************************************/ /***********************************************************************/
...@@ -447,10 +454,10 @@ const char *VALUE::GetXfmt(void) ...@@ -447,10 +454,10 @@ const char *VALUE::GetXfmt(void)
switch (Type) { switch (Type) {
case TYPE_STRING: fmt = "%*s"; break; case TYPE_STRING: fmt = "%*s"; break;
case TYPE_SHORT: fmt = "%*hd"; break; case TYPE_SHORT: fmt = (Unsigned) ? "%*hu" : "%*hd"; break;
case TYPE_BIGINT: fmt = "%*lld"; break; case TYPE_BIGINT: fmt = (Unsigned) ? "%*llu" : "%*lld"; break;
case TYPE_FLOAT: fmt = "%*.*lf"; break; case TYPE_FLOAT: fmt = "%*.*lf"; break;
default: fmt = "%*d"; break; default: fmt = (Unsigned) ? "%*u" : "%*d"; break;
} // endswitch Type } // endswitch Type
return fmt; return fmt;
...@@ -462,22 +469,11 @@ const char *VALUE::GetXfmt(void) ...@@ -462,22 +469,11 @@ const char *VALUE::GetXfmt(void)
/* TYPVAL public constructor from a constant typed value. */ /* TYPVAL public constructor from a constant typed value. */
/***********************************************************************/ /***********************************************************************/
template <class TYPE> template <class TYPE>
TYPVAL<TYPE>::TYPVAL(TYPE n, int type) : VALUE(type) TYPVAL<TYPE>::TYPVAL(TYPE n, int type, int prec, bool un)
: VALUE(type, un)
{ {
Tval = n; Tval = n;
Clen = sizeof(TYPE); Clen = sizeof(TYPE);
Prec = (Type == TYPE_FLOAT) ? 2 : 0;
} // end of TYPVAL constructor
/***********************************************************************/
/* TYPVAL public constructor from typed value. */
/***********************************************************************/
template <class TYPE>
TYPVAL<TYPE>::TYPVAL(TYPE n, int prec, int type) : VALUE(type)
{
assert(Type == TYPE_FLOAT);
Tval = n;
Clen = sizeof(TYPE);
Prec = prec; Prec = prec;
} // end of TYPVAL constructor } // end of TYPVAL constructor
...@@ -522,14 +518,26 @@ template <> ...@@ -522,14 +518,26 @@ template <>
short TYPVAL<short>::GetTypedValue(PVAL valp) short TYPVAL<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();} {return valp->GetShortValue();}
template <>
ushort TYPVAL<ushort>::GetTypedValue(PVAL valp)
{return valp->GetUShortValue();}
template <> template <>
int TYPVAL<int>::GetTypedValue(PVAL valp) int TYPVAL<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();} {return valp->GetIntValue();}
template <>
uint TYPVAL<uint>::GetTypedValue(PVAL valp)
{return valp->GetUIntValue();}
template <> template <>
longlong TYPVAL<longlong>::GetTypedValue(PVAL valp) longlong TYPVAL<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();} {return valp->GetBigintValue();}
template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PVAL valp)
{return valp->GetUBigintValue();}
template <> template <>
double TYPVAL<double>::GetTypedValue(PVAL valp) double TYPVAL<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();} {return valp->GetFloatValue();}
...@@ -538,6 +546,10 @@ template <> ...@@ -538,6 +546,10 @@ template <>
char TYPVAL<char>::GetTypedValue(PVAL valp) char TYPVAL<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();} {return valp->GetTinyValue();}
template <>
uchar TYPVAL<uchar>::GetTypedValue(PVAL valp)
{return valp->GetUTinyValue();}
/***********************************************************************/ /***********************************************************************/
/* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/ /* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/
/***********************************************************************/ /***********************************************************************/
...@@ -545,7 +557,7 @@ template <class TYPE> ...@@ -545,7 +557,7 @@ template <class TYPE>
void TYPVAL<TYPE>::SetValue_char(char *p, int n) void TYPVAL<TYPE>::SetValue_char(char *p, int n)
{ {
char *p2, buf[32]; char *p2, buf[32];
bool minus; bool minus = false;
for (p2 = p + n; p < p2 && *p == ' '; p++) ; for (p2 = p + n; p < p2 && *p == ' '; p++) ;
...@@ -570,7 +582,7 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n) ...@@ -570,7 +582,7 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n)
} // endswitch *p } // endswitch *p
if (minus && Tval) if (minus && Tval)
Tval = - Tval; Tval = - (signed)Tval;
if (trace > 1) if (trace > 1)
htrc(strcat(strcat(strcpy(buf, " setting %s to: "), Fmt), "\n"), htrc(strcat(strcat(strcpy(buf, " setting %s to: "), Fmt), "\n"),
...@@ -622,13 +634,21 @@ void TYPVAL<TYPE>::SetValue_psz(PSZ s) ...@@ -622,13 +634,21 @@ void TYPVAL<TYPE>::SetValue_psz(PSZ s)
template <> template <>
int TYPVAL<int>::GetTypedValue(PSZ s) {return atol(s);} int TYPVAL<int>::GetTypedValue(PSZ s) {return atol(s);}
template <> template <>
uint TYPVAL<uint>::GetTypedValue(PSZ s) {return (unsigned)atol(s);}
template <>
short TYPVAL<short>::GetTypedValue(PSZ s) {return (short)atoi(s);} short TYPVAL<short>::GetTypedValue(PSZ s) {return (short)atoi(s);}
template <> template <>
ushort TYPVAL<ushort>::GetTypedValue(PSZ s) {return (ushort)atoi(s);}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);} longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);}
template <> template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PSZ s) {return (unsigned)atoll(s);}
template <>
double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);} double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);}
template <> template <>
char TYPVAL<char>::GetTypedValue(PSZ s) {return (char)atoi(s);} char TYPVAL<char>::GetTypedValue(PSZ s) {return (char)atoi(s);}
template <>
uchar TYPVAL<uchar>::GetTypedValue(PSZ s) {return (uchar)atoi(s);}
/***********************************************************************/ /***********************************************************************/
/* TYPVAL SetValue: set value with a TYPE extracted from a block. */ /* TYPVAL SetValue: set value with a TYPE extracted from a block. */
...@@ -644,14 +664,26 @@ template <> ...@@ -644,14 +664,26 @@ template <>
int TYPVAL<int>::GetTypedValue(PVBLK blk, int n) int TYPVAL<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);} {return blk->GetIntValue(n);}
template <>
uint TYPVAL<uint>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetIntValue(n);}
template <> template <>
short TYPVAL<short>::GetTypedValue(PVBLK blk, int n) short TYPVAL<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);} {return blk->GetShortValue(n);}
template <>
ushort TYPVAL<ushort>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetShortValue(n);}
template <> template <>
longlong TYPVAL<longlong>::GetTypedValue(PVBLK blk, int n) longlong TYPVAL<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);} {return blk->GetBigintValue(n);}
template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetBigintValue(n);}
template <> template <>
double TYPVAL<double>::GetTypedValue(PVBLK blk, int n) double TYPVAL<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);} {return blk->GetFloatValue(n);}
...@@ -660,6 +692,10 @@ template <> ...@@ -660,6 +692,10 @@ template <>
char TYPVAL<char>::GetTypedValue(PVBLK blk, int n) char TYPVAL<char>::GetTypedValue(PVBLK blk, int n)
{return blk->GetTinyValue(n);} {return blk->GetTinyValue(n);}
template <>
uchar TYPVAL<uchar>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetTinyValue(n);}
/***********************************************************************/ /***********************************************************************/
/* TYPVAL SetBinValue: with bytes extracted from a line. */ /* TYPVAL SetBinValue: with bytes extracted from a line. */
/***********************************************************************/ /***********************************************************************/
...@@ -684,7 +720,7 @@ bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go) ...@@ -684,7 +720,7 @@ bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go)
// be different from the variable length because no conversion is done. // be different from the variable length because no conversion is done.
// Therefore this test is useless anyway. // Therefore this test is useless anyway.
//#if defined(_DEBUG) //#if defined(_DEBUG)
// if (sizeof(int) > buflen) // if (sizeof(TYPE) > buflen)
// return true; // return true;
//#endif //#endif
...@@ -730,6 +766,7 @@ char *TYPVAL<double>::GetCharString(char *p) ...@@ -730,6 +766,7 @@ char *TYPVAL<double>::GetCharString(char *p)
return p; return p;
} // end of GetCharString } // end of GetCharString
#if 0
/***********************************************************************/ /***********************************************************************/
/* TYPVAL GetShortString: get short representation of a typed value. */ /* TYPVAL GetShortString: get short representation of a typed value. */
/***********************************************************************/ /***********************************************************************/
...@@ -779,6 +816,7 @@ char *TYPVAL<TYPE>::GetTinyString(char *p, int n) ...@@ -779,6 +816,7 @@ char *TYPVAL<TYPE>::GetTinyString(char *p, int n)
sprintf(p, "%*d", n, (int)(char)Tval); sprintf(p, "%*d", n, (int)(char)Tval);
return p; return p;
} // end of GetIntString } // end of GetIntString
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* TYPVAL compare value with another Value. */ /* TYPVAL compare value with another Value. */
...@@ -875,7 +913,6 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING) ...@@ -875,7 +913,6 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING)
TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c) TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c)
: VALUE(TYPE_STRING) : VALUE(TYPE_STRING)
{ {
assert(Type == TYPE_STRING);
Len = (g) ? n : strlen(s); Len = (g) ? n : strlen(s);
if (!s) { if (!s) {
...@@ -981,6 +1018,24 @@ void TYPVAL<PSZ>::SetValue(int n) ...@@ -981,6 +1018,24 @@ void TYPVAL<PSZ>::SetValue(int n)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* STRING SetValue: get the character representation of an uint. */
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(uint n)
{
char buf[16];
PGLOBAL& g = Global;
int k = sprintf(buf, "%u", n);
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
longjmp(g->jumper[g->jump_level], 138);
} else
SetValue_psz(buf);
Null = false;
} // end of SetValue
/***********************************************************************/ /***********************************************************************/
/* STRING SetValue: get the character representation of a short int. */ /* STRING SetValue: get the character representation of a short int. */
/***********************************************************************/ /***********************************************************************/
...@@ -990,6 +1045,15 @@ void TYPVAL<PSZ>::SetValue(short i) ...@@ -990,6 +1045,15 @@ void TYPVAL<PSZ>::SetValue(short i)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* STRING SetValue: get the character representation of a ushort int. */
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(ushort i)
{
SetValue((uint)i);
Null = false;
} // end of SetValue
/***********************************************************************/ /***********************************************************************/
/* STRING SetValue: get the character representation of a big integer.*/ /* STRING SetValue: get the character representation of a big integer.*/
/***********************************************************************/ /***********************************************************************/
...@@ -1008,6 +1072,24 @@ void TYPVAL<PSZ>::SetValue(longlong n) ...@@ -1008,6 +1072,24 @@ void TYPVAL<PSZ>::SetValue(longlong n)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* STRING SetValue: get the character representation of a big integer.*/
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(ulonglong n)
{
char buf[24];
PGLOBAL& g = Global;
int k = sprintf(buf, "%llu", n);
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
longjmp(g->jumper[g->jump_level], 138);
} else
SetValue_psz(buf);
Null = false;
} // end of SetValue
/***********************************************************************/ /***********************************************************************/
/* STRING SetValue: get the character representation of a double. */ /* STRING SetValue: get the character representation of a double. */
/***********************************************************************/ /***********************************************************************/
...@@ -1042,6 +1124,15 @@ void TYPVAL<PSZ>::SetValue(char c) ...@@ -1042,6 +1124,15 @@ void TYPVAL<PSZ>::SetValue(char c)
Null = false; Null = false;
} // end of SetValue } // end of SetValue
/***********************************************************************/
/* STRING SetValue: get the character representation of a tiny int. */
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(uchar c)
{
SetValue((uint)c);
Null = false;
} // end of SetValue
/***********************************************************************/ /***********************************************************************/
/* STRING SetBinValue: fill string with chars extracted from a line. */ /* STRING SetBinValue: fill string with chars extracted from a line. */
/***********************************************************************/ /***********************************************************************/
...@@ -1086,6 +1177,7 @@ char *TYPVAL<PSZ>::GetCharString(char *p) ...@@ -1086,6 +1177,7 @@ char *TYPVAL<PSZ>::GetCharString(char *p)
return Strp; return Strp;
} // end of GetCharString } // end of GetCharString
#if 0
/***********************************************************************/ /***********************************************************************/
/* STRING GetShortString: get short representation of a char value. */ /* STRING GetShortString: get short representation of a char value. */
/***********************************************************************/ /***********************************************************************/
...@@ -1130,6 +1222,7 @@ char *TYPVAL<PSZ>::GetTinyString(char *p, int n) ...@@ -1130,6 +1222,7 @@ char *TYPVAL<PSZ>::GetTinyString(char *p, int n)
sprintf(p, "%*d", n, (Null) ? 0 : (char)atoi(Strp)); sprintf(p, "%*d", n, (Null) ? 0 : (char)atoi(Strp));
return p; return p;
} // end of GetIntString } // end of GetIntString
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* STRING compare value with another Value. */ /* STRING compare value with another Value. */
......
/**************** Value H Declares Source Code File (.H) ***************/ /**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 1.9 */ /* Name: VALUE.H Version 2.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
/* */ /* */
...@@ -51,10 +51,10 @@ DllExport char *GetFormatType(int); ...@@ -51,10 +51,10 @@ DllExport char *GetFormatType(int);
DllExport int GetFormatType(char); DllExport int GetFormatType(char);
DllExport bool IsTypeChar(int type); DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type); DllExport bool IsTypeNum(int type);
DllExport int ConvertType(int, int, CONV, bool match = false); //lExport int ConvertType(int, int, CONV, bool match = false);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID); DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 2, DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
PSZ dom = NULL, PCATLG cat = NULL); PSZ fmt = NULL);
/***********************************************************************/ /***********************************************************************/
/* Class VALUE represents a constant or variable of any valid type. */ /* Class VALUE represents a constant or variable of any valid type. */
...@@ -68,6 +68,7 @@ class DllExport VALUE : public BLOCK { ...@@ -68,6 +68,7 @@ class DllExport VALUE : public BLOCK {
virtual bool IsTypeNum(void) = 0; virtual bool IsTypeNum(void) = 0;
virtual bool IsZero(void) = 0; virtual bool IsZero(void) = 0;
virtual bool IsCi(void) {return false;} virtual bool IsCi(void) {return false;}
virtual bool IsUnsigned(void) {return Unsigned;}
virtual void Reset(void) = 0; virtual void Reset(void) = 0;
virtual int GetSize(void) = 0; virtual int GetSize(void) = 0;
virtual int GetValLen(void) = 0; virtual int GetValLen(void) = 0;
...@@ -75,9 +76,13 @@ class DllExport VALUE : public BLOCK { ...@@ -75,9 +76,13 @@ class DllExport VALUE : public BLOCK {
virtual int GetLength(void) {return 1;} virtual int GetLength(void) {return 1;}
virtual PSZ GetCharValue(void) {assert(false); return NULL;} virtual PSZ GetCharValue(void) {assert(false); return NULL;}
virtual char GetTinyValue(void) {assert(false); return 0;} 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 short GetShortValue(void) {assert(false); return 0;}
virtual ushort GetUShortValue(void) {assert(false); return 0;}
virtual int GetIntValue(void) = 0; virtual int GetIntValue(void) = 0;
virtual uint GetUIntValue(void) = 0;
virtual longlong GetBigintValue(void) = 0; virtual longlong GetBigintValue(void) = 0;
virtual ulonglong GetUBigintValue(void) = 0;
virtual double GetFloatValue(void) = 0; virtual double GetFloatValue(void) = 0;
virtual void *GetTo_Val(void) = 0; virtual void *GetTo_Val(void) = 0;
virtual void SetPrec(int prec) {Prec = prec;} virtual void SetPrec(int prec) {Prec = prec;}
...@@ -94,20 +99,24 @@ class DllExport VALUE : public BLOCK { ...@@ -94,20 +99,24 @@ class DllExport VALUE : public BLOCK {
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(char c) {assert(false);} virtual void SetValue(char c) {assert(false);}
virtual void SetValue(uchar c) {assert(false);}
virtual void SetValue(short i) {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(int n) {assert(false);}
virtual void SetValue(uint n) {assert(false);}
virtual void SetValue(longlong 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(double f) {assert(false);}
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 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 "#####";}
virtual char *GetIntString(char *p, int n) = 0; //virtual char *GetIntString(char *p, int n) = 0;
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 char *GetTinyString(char *p, int n) {return "?";} //virtual char *GetTinyString(char *p, int n) {return "?";}
virtual bool IsEqual(PVAL vp, bool chktype) = 0; virtual bool IsEqual(PVAL vp, bool chktype) = 0;
virtual bool FormatValue(PVAL vp, char *fmt) = 0; virtual bool FormatValue(PVAL vp, char *fmt) = 0;
...@@ -116,7 +125,7 @@ class DllExport VALUE : public BLOCK { ...@@ -116,7 +125,7 @@ class DllExport VALUE : public BLOCK {
const char *GetXfmt(void); const char *GetXfmt(void);
// Constructor used by derived classes // Constructor used by derived classes
VALUE(int type); VALUE(int type, bool un = false);
// Members // Members
PGLOBAL Global; // To reduce arglist PGLOBAL Global; // To reduce arglist
...@@ -124,6 +133,7 @@ class DllExport VALUE : public BLOCK { ...@@ -124,6 +133,7 @@ class DllExport VALUE : public BLOCK {
const char *Xfmt; const char *Xfmt;
bool Nullable; // True if value can be null bool Nullable; // True if value can be null
bool Null; // True if value is null bool Null; // True if value is null
bool Unsigned; // True if unsigned
int Type; // The value type int Type; // The value type
int Clen; // Internal value length int Clen; // Internal value length
int Prec; int Prec;
...@@ -135,9 +145,8 @@ class DllExport VALUE : public BLOCK { ...@@ -135,9 +145,8 @@ class DllExport VALUE : public BLOCK {
template <class TYPE> template <class TYPE>
class DllExport TYPVAL : public VALUE { class DllExport TYPVAL : public VALUE {
public: public:
// Constructors // Constructor
TYPVAL(TYPE n, int type); TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
TYPVAL(TYPE n, int prec, int type);
// Implementation // Implementation
virtual bool IsTypeNum(void) {return true;} virtual bool IsTypeNum(void) {return true;}
...@@ -148,9 +157,13 @@ class DllExport TYPVAL : public VALUE { ...@@ -148,9 +157,13 @@ class DllExport TYPVAL : public VALUE {
virtual int GetSize(void) {return sizeof(TYPE);} virtual int GetSize(void) {return sizeof(TYPE);}
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();} virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual char GetTinyValue(void) {return (char)Tval;} virtual char GetTinyValue(void) {return (char)Tval;}
virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
virtual short GetShortValue(void) {return (short)Tval;} virtual short GetShortValue(void) {return (short)Tval;}
virtual ushort GetUShortValue(void) {return (ushort)Tval;}
virtual int GetIntValue(void) {return (int)Tval;} virtual int GetIntValue(void) {return (int)Tval;}
virtual uint GetUIntValue(void) {return (uint)Tval;}
virtual longlong GetBigintValue(void) {return (longlong)Tval;} virtual longlong GetBigintValue(void) {return (longlong)Tval;}
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
virtual double GetFloatValue(void) {return (double)Tval;} virtual double GetFloatValue(void) {return (double)Tval;}
virtual void *GetTo_Val(void) {return &Tval;} virtual void *GetTo_Val(void) {return &Tval;}
...@@ -159,20 +172,24 @@ class DllExport TYPVAL : public VALUE { ...@@ -159,20 +172,24 @@ class DllExport TYPVAL : public VALUE {
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(char c) {Tval = (TYPE)c; Null = false;} 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(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(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(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(double f) {Tval = (TYPE)f; Null = false;}
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 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);
virtual char *GetIntString(char *p, int n); //virtual char *GetIntString(char *p, int n);
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 char *GetTinyString(char *p, int n); //virtual char *GetTinyString(char *p, int n);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, char *fmt);
...@@ -211,9 +228,13 @@ class DllExport TYPVAL<PSZ>: public VALUE { ...@@ -211,9 +228,13 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
virtual PSZ GetCharValue(void) {return Strp;} virtual PSZ GetCharValue(void) {return Strp;}
virtual char GetTinyValue(void) {return (char)atoi(Strp);} virtual char GetTinyValue(void) {return (char)atoi(Strp);}
virtual uchar GetUTinyValue(void) {return (uchar)atoi(Strp);}
virtual short GetShortValue(void) {return (short)atoi(Strp);} virtual short GetShortValue(void) {return (short)atoi(Strp);}
virtual ushort GetUShortValue(void) {return (ushort)atoi(Strp);}
virtual int GetIntValue(void) {return atol(Strp);} virtual int GetIntValue(void) {return atol(Strp);}
virtual uint GetUIntValue(void) {return (uint)atol(Strp);}
virtual longlong GetBigintValue(void) {return atoll(Strp);} virtual longlong GetBigintValue(void) {return atoll(Strp);}
virtual ulonglong GetUBigintValue(void) {return (ulonglong)atoll(Strp);}
virtual double GetFloatValue(void) {return atof(Strp);} virtual double GetFloatValue(void) {return atof(Strp);}
virtual void *GetTo_Val(void) {return Strp;} virtual void *GetTo_Val(void) {return Strp;}
virtual void SetPrec(int prec) {Ci = prec != 0;} virtual void SetPrec(int prec) {Ci = prec != 0;}
...@@ -224,30 +245,34 @@ class DllExport TYPVAL<PSZ>: public VALUE { ...@@ -224,30 +245,34 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c); virtual void SetValue(char c);
virtual void SetValue(uchar c);
virtual void SetValue(short i); virtual void SetValue(short i);
virtual void SetValue(ushort i);
virtual void SetValue(int n); virtual void SetValue(int n);
virtual void SetValue(uint n);
virtual void SetValue(longlong n); virtual void SetValue(longlong n);
virtual void SetValue(ulonglong n);
virtual void SetValue(double f); virtual void SetValue(double f);
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 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);
virtual char *GetIntString(char *p, int n); //virtual char *GetIntString(char *p, int n);
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 char *GetTinyString(char *p, int n); //virtual char *GetTinyString(char *p, int n);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool FormatValue(PVAL vp, char *fmt); virtual bool FormatValue(PVAL vp, char *fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
// Specialized functions // Specialized functions
template <class T> //template <class T>
T GetValue_as(T type) {return Strp;} //T GetValue_as(T type) {return Strp;}
int GetValue_as(int type) {return atol(Strp);} //int GetValue_as(int type) {return atol(Strp);}
short GetValue_as(short type) {return (short)atoi(Strp);} //short GetValue_as(short type) {return (short)atoi(Strp);}
longlong GetValue_as(longlong type) {return atoll(Strp);} //longlong GetValue_as(longlong type) {return atoll(Strp);}
double GetValue_as(double type) {return atof(Strp);} //double GetValue_as(double type) {return atof(Strp);}
// Members // Members
PSZ Strp; PSZ Strp;
......
...@@ -66,7 +66,7 @@ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */ ...@@ -66,7 +66,7 @@ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/* to have rows filled by blanks to be compatible with QRY blocks. */ /* to have rows filled by blanks to be compatible with QRY blocks. */
/***********************************************************************/ /***********************************************************************/
PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int,
bool check = true, bool blank = true); bool check = true, bool blank = true, bool un = false);
/***********************************************************************/ /***********************************************************************/
/* Check whether we have to create/update permanent indexes. */ /* Check whether we have to create/update permanent indexes. */
...@@ -2919,7 +2919,7 @@ void KXYCOL::SetValue(PCOL colp, int i) ...@@ -2919,7 +2919,7 @@ void KXYCOL::SetValue(PCOL colp, int i)
assert (Kblp != NULL); assert (Kblp != NULL);
#endif #endif
Kblp->SetValue(colp->GetValue(), (int)i); Kblp->SetValue(colp->GetValue(), i);
} // end of SetValue } // end of SetValue
/***********************************************************************/ /***********************************************************************/
...@@ -2970,7 +2970,7 @@ void KXYCOL::FillValue(PVAL valp) ...@@ -2970,7 +2970,7 @@ void KXYCOL::FillValue(PVAL valp)
int KXYCOL::Compare(int i1, int i2) int KXYCOL::Compare(int i1, int i2)
{ {
// Do the actual comparison between values. // Do the actual comparison between values.
register int k = (int)Kblp->CompVal((int)i1, (int)i2); register int k = Kblp->CompVal(i1, i2);
#ifdef DEBUG2 #ifdef DEBUG2
htrc("Compare done result=%d\n", k); htrc("Compare done result=%d\n", k);
...@@ -2991,7 +2991,7 @@ int KXYCOL::CompVal(int i) ...@@ -2991,7 +2991,7 @@ int KXYCOL::CompVal(int i)
htrc("Compare done result=%d\n", k); htrc("Compare done result=%d\n", k);
return k; return k;
#endif #endif
return (int)Kblp->CompVal(Valp, (int)i); return Kblp->CompVal(Valp, i);
} // end of CompVal } // end of CompVal
/***********************************************************************/ /***********************************************************************/
...@@ -3000,7 +3000,7 @@ int KXYCOL::CompVal(int i) ...@@ -3000,7 +3000,7 @@ int KXYCOL::CompVal(int i)
int KXYCOL::CompBval(int i) int KXYCOL::CompBval(int i)
{ {
// Do the actual comparison between key values. // Do the actual comparison between key values.
return (int)Blkp->CompVal(Valp, (int)i); return Blkp->CompVal(Valp, i);
} // end of CompBval } // end of CompBval
/***********************************************************************/ /***********************************************************************/
......
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