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)
/* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */
/* Added in version 1.5 is the arguments GetPrecision() and Domain */
/* in calling AllocateValue. Domain is used for TYPE_TOKEN only, */
/* but why was GetPrecision() not specified ? To be checked. */
/* in calling AllocateValue. Domain is used for TYPE_DATE only. */
/***********************************************************************/
bool COLBLK::InitValue(PGLOBAL g)
{
......@@ -174,8 +173,7 @@ bool COLBLK::InitValue(PGLOBAL g)
// Allocate a Value object
if (!(Value = AllocateValue(g, Buf_Type, Format.Length,
GetPrecision(), GetDomain(),
(To_Tdb) ? To_Tdb->GetCat() : NULL)))
GetPrecision(), GetDomain())))
return true;
AddStatus(BUF_READY);
......
......@@ -91,7 +91,7 @@ typedef struct _vecheader {
/* Conversion of block values allowed conditionally for insert only. */
/***********************************************************************/
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 --------------------------- */
......
......@@ -709,7 +709,7 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Clen = GetTypeSize(crp->Type, crp->Length);
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),
GetFormatType(crp->Type));
return NULL;
......
......@@ -1118,7 +1118,7 @@ bool ODBConn::Connect(DWORD Options)
if (hWnd == NULL)
hWnd = GetDesktopWindow();
#else // !WIN32
HWND hWnd = 1;
HWND hWnd = (HWND)1;
#endif // !WIN32
PGLOBAL& g = m_G;
PDBUSER dup = PlgGetUser(g);
......@@ -1240,8 +1240,8 @@ void ODBConn::GetConnectInfo()
m_IDQuoteChar, sizeof(m_IDQuoteChar), &nResult);
if (trace)
htrc("DBMS: %s, Version: %s\n",
GetStringInfo(SQL_DBMS_NAME), GetStringInfo(SQL_DBMS_VER));
htrc("DBMS: %s, Version: %s, rc=%d\n",
GetStringInfo(SQL_DBMS_NAME), GetStringInfo(SQL_DBMS_VER), rc);
} // end of GetConnectInfo
......
......@@ -330,7 +330,7 @@ PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids,
// Allocate the Value Block that will contain data
if (crp->Length || nonull)
crp->Kdata = AllocValBlock(g, NULL, crp->Type, maxres,
crp->Length, 0, true, blank);
crp->Length, 0, true, blank, false);
else
crp->Kdata = NULL;
......
......@@ -77,7 +77,7 @@ extern "C" int trace;
/* No conversion of block values (check = true). */
/***********************************************************************/
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 -------------------------- */
......
......@@ -1078,7 +1078,7 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows)
if (Buf_Type == TYPE_DATE)
Bufp = PlugSubAlloc(g, NULL, rows * sizeof(TIMESTAMP_STRUCT));
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();
} // endelse
......
......@@ -81,7 +81,7 @@ char *strerror(int num);
/* Conversion of block values allowed conditionally for insert only. */
/***********************************************************************/
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 -------------------------- */
......
/************ 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 */
/* */
......@@ -16,7 +16,7 @@
/* types of objects, we shall have more classes to update. */
/* This is why we are now using a template class for many types. */
/* 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 @@
/* AllocValBlock: allocate a VALBLK according to type. */
/***********************************************************************/
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;
......@@ -64,22 +64,38 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
break;
case TYPE_SHORT:
blkp = new(g) TYPBLK<short>(mp, nval, type);
if (un)
blkp = new(g) TYPBLK<ushort>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<short>(mp, nval, type);
break;
case TYPE_INT:
blkp = new(g) TYPBLK<int>(mp, nval, type);
if (un)
blkp = new(g) TYPBLK<uint>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<int>(mp, nval, type);
break;
case TYPE_DATE: // ?????
blkp = new(g) DATBLK(mp, nval);
break;
case TYPE_BIGINT:
blkp = new(g) TYPBLK<longlong>(mp, nval, type);
if (un)
blkp = new(g) TYPBLK<ulonglong>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<longlong>(mp, nval, type);
break;
case TYPE_FLOAT:
blkp = new(g) TYPBLK<double>(mp, nval, prec, type);
blkp = new(g) TYPBLK<double>(mp, nval, type, prec);
break;
case TYPE_TINY:
blkp = new(g) TYPBLK<char>(mp, nval, type);
if (un)
blkp = new(g) TYPBLK<uchar>(mp, nval, type, 0, true);
else
blkp = new(g) TYPBLK<char>(mp, nval, type);
break;
default:
sprintf(g->Message, MSG(BAD_VALBLK_TYPE), type);
......@@ -95,12 +111,13 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
/***********************************************************************/
/* Constructor. */
/***********************************************************************/
VALBLK::VALBLK(void *mp, int type, int nval)
VALBLK::VALBLK(void *mp, int type, int nval, bool un)
{
Blkp = mp;
To_Nulls = NULL;
Check = true;
Nullable = false;
Unsigned = un;
Type = type;
Nval = nval;
Prec = 0;
......@@ -195,23 +212,15 @@ void VALBLK::ChkTyp(PVBLK vb)
/* -------------------------- Class TYPBLK --------------------------- */
/***********************************************************************/
/* Constructors. */
/* Constructor. */
/***********************************************************************/
template <class TYPE>
TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type)
: VALBLK(mp, type, nval), 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)
TYPBLK<TYPE>::TYPBLK(void *mp, int nval, int type, int prec, bool un)
: VALBLK(mp, type, nval, un), Typp((TYPE*&)Blkp)
{
DBUG_ASSERT(Type == TYPE_FLOAT);
Prec = prec;
Fmt = GetFmt(Type);
} // end of DBLBLK constructor
} // end of TYPBLK constructor
/***********************************************************************/
/* Initialization routine. */
......@@ -249,14 +258,25 @@ template <>
int TYPBLK<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();}
uint TYPBLK<uint>::GetTypedValue(PVAL valp)
{return valp->GetUIntValue();}
template <>
short TYPBLK<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();}
template <>
ushort TYPBLK<ushort>::GetTypedValue(PVAL valp)
{return valp->GetUShortValue();}
template <>
longlong TYPBLK<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();}
template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PVAL valp)
{return valp->GetUBigintValue();}
template <>
double TYPBLK<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();}
......@@ -265,6 +285,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();}
template <>
uchar TYPBLK<uchar>::GetTypedValue(PVAL valp)
{return valp->GetUTinyValue();}
/***********************************************************************/
/* Set one value in a block from a zero terminated string. */
/***********************************************************************/
......@@ -286,13 +310,21 @@ void TYPBLK<TYPE>::SetValue(PSZ p, int n)
template <>
int TYPBLK<int>::GetTypedValue(PSZ p) {return atol(p);}
template <>
uint TYPBLK<uint>::GetTypedValue(PSZ p) {return (unsigned)atol(p);}
template <>
short TYPBLK<short>::GetTypedValue(PSZ p) {return (short)atoi(p);}
template <>
ushort TYPBLK<ushort>::GetTypedValue(PSZ p) {return (ushort)atoi(p);}
template <>
longlong TYPBLK<longlong>::GetTypedValue(PSZ p) {return atoll(p);}
template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PSZ p) {return (unsigned)atoll(p);}
template <>
double TYPBLK<double>::GetTypedValue(PSZ p) {return atof(p);}
template <>
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. */
......@@ -333,14 +365,26 @@ template <>
int TYPBLK<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);}
template <>
uint TYPBLK<uint>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUIntValue(n);}
template <>
short TYPBLK<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);}
template <>
ushort TYPBLK<ushort>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUShortValue(n);}
template <>
longlong TYPBLK<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);}
template <>
ulonglong TYPBLK<ulonglong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUBigintValue(n);}
template <>
double TYPBLK<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);}
......@@ -349,6 +393,10 @@ template <>
char TYPBLK<char>::GetTypedValue(PVBLK blk, int n)
{return blk->GetTinyValue(n);}
template <>
uchar TYPBLK<uchar>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUTinyValue(n);}
#if 0
/***********************************************************************/
/* Set many values in a block from values in another block. */
......@@ -516,6 +564,14 @@ short CHRBLK::GetShortValue(int n)
return (short)atoi((char *)GetValPtrEx(n));
} // 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. */
/***********************************************************************/
......@@ -524,6 +580,14 @@ int CHRBLK::GetIntValue(int n)
return atol((char *)GetValPtrEx(n));
} // 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. */
/***********************************************************************/
......@@ -532,6 +596,14 @@ longlong CHRBLK::GetBigintValue(int n)
return atoll((char *)GetValPtrEx(n));
} // 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. */
/***********************************************************************/
......@@ -548,6 +620,14 @@ char CHRBLK::GetTinyValue(int n)
return (char)atoi((char *)GetValPtrEx(n));
} // 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. */
/***********************************************************************/
......
/*************** 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 */
/* */
......@@ -18,8 +18,9 @@
/***********************************************************************/
/* Utility used to allocate value blocks. */
/***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool);
const char *GetFmt(int type);
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int,
bool, bool, bool);
const char *GetFmt(int type, bool un = false);
/***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */
......@@ -28,7 +29,7 @@ class VALBLK : public BLOCK {
//friend void SemColData(PGLOBAL g, PSEM semp);
public:
// Constructors
VALBLK(void *mp, int type, int nval);
VALBLK(void *mp, int type, int nval, bool un = false);
// Implementation
int GetNval(void) {return Nval;}
......@@ -48,10 +49,14 @@ class VALBLK : public BLOCK {
virtual int GetVlen(void) = 0;
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n) = 0;
virtual ushort GetUShortValue(int n) = 0;
virtual int GetIntValue(int n) = 0;
virtual uint GetUIntValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0;
virtual ulonglong GetUBigintValue(int n) = 0;
virtual double GetFloatValue(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 Reset(int n) = 0;
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
......@@ -60,10 +65,14 @@ class VALBLK : public BLOCK {
// Methods
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(uint 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(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(char *sp, uint len, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
......@@ -94,6 +103,7 @@ class VALBLK : public BLOCK {
void *Blkp; // To value block
bool Check; // If true SetValue types must match
bool Nullable; // True if values can be null
bool Unsigned; // True if values are unsigned
int Type; // Type of individual values
int Nval; // Max number of values in block
int Prec; // Precision of float values
......@@ -106,18 +116,22 @@ template <class TYPE>
class TYPBLK : public VALBLK {
public:
// Constructors
TYPBLK(void *mp, int size, int type);
TYPBLK(void *mp, int size, int prec, int type);
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false);
//TYPBLK(void *mp, int size, int prec, int type);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(TYPE);}
//virtual PSZ GetCharValue(int 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 uint GetUIntValue(int n) {return (uint)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 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;}
// Methods
......@@ -125,14 +139,22 @@ class TYPBLK : public VALBLK {
virtual void SetValue(char *sp, uint len, int n);
virtual void SetValue(short sval, int n)
{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)
{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)
{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)
{Typp[n] = (TYPE)fval; SetNull(n, false);}
virtual void SetValue(char cval, int n)
{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(PVBLK pv, int n1, int n2);
//virtual void SetValues(PVBLK pv, int k, int n);
......@@ -168,10 +190,14 @@ class CHRBLK : public VALBLK {
virtual int GetVlen(void) {return Long;}
virtual PSZ GetCharValue(int n);
virtual short GetShortValue(int n);
virtual ushort GetUShortValue(int n);
virtual int GetIntValue(int n);
virtual uint GetUIntValue(int n);
virtual longlong GetBigintValue(int n);
virtual ulonglong GetUBigintValue(int n);
virtual double GetFloatValue(int n);
virtual char GetTinyValue(int n);
virtual uchar GetUTinyValue(int n);
virtual void Reset(int n);
virtual void SetPrec(int p) {Ci = (p != 0);}
virtual bool IsCi(void) {return Ci;}
......@@ -217,10 +243,14 @@ class STRBLK : public VALBLK {
virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return 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 uint GetUIntValue(int n) {return (unsigned)atol(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 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;}
// Methods
......
/************* 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 */
/* */
......@@ -20,7 +20,7 @@
/* functions used on one family only. The drawback is that for new */
/* types of objects, we shall have more classes to update. */
/* 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);
}
#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. */
/***********************************************************************/
PSZ GetTypeName(int type)
{
PSZ name = "UNKNOWN";
PSZ name;
switch (type) {
case TYPE_STRING: name = "CHAR"; break;
......@@ -135,6 +107,7 @@ PSZ GetTypeName(int type)
case TYPE_DATE: name = "DATE"; break;
case TYPE_FLOAT: name = "FLOAT"; break;
case TYPE_TINY: name = "TINY"; break;
default: name = "UNKNOWN"; break;
} // endswitch type
return name;
......@@ -153,7 +126,6 @@ int GetTypeSize(int type, int len)
case TYPE_DATE: len = sizeof(int); break;
case TYPE_FLOAT: len = sizeof(double); break;
case TYPE_TINY: len = sizeof(char); break;
break;
default: len = 0;
} // endswitch type
......@@ -236,21 +208,22 @@ bool IsTypeNum(int type)
/***********************************************************************/
/* 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;
switch (type) {
case TYPE_STRING: fmt = "%s"; break;
case TYPE_SHORT: fmt = "%hd"; break;
case TYPE_BIGINT: fmt = "%lld"; break;
case TYPE_FLOAT: fmt = "%.*lf"; break;
default: fmt = "%d"; break;
case TYPE_STRING: fmt = "%s"; break;
case TYPE_SHORT: fmt = (un) ? "%hu" : "%hd"; break;
case TYPE_BIGINT: fmt = (un) ? "%llu" : "%lld"; break;
case TYPE_FLOAT: fmt = "%.*lf"; break;
default: fmt = (un) ? "%u" : "%d"; break;
} // endswitch Type
return fmt;
} // end of GetFmt
#if 0
/***********************************************************************/
/* ConvertType: what this function does is to determine the type to */
/* 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)
} // endswitch kind
} // end of ConvertType
#endif // 0
/***********************************************************************/
/* AllocateConstant: allocates a constant Value. */
......@@ -339,8 +313,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type)
/***********************************************************************/
/* Allocate a variable Value according to type, length and precision. */
/***********************************************************************/
PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
PSZ dom, PCATLG cat)
PVAL AllocateValue(PGLOBAL g, int type, int len, int prec, PSZ fmt)
{
PVAL valp;
......@@ -349,22 +322,38 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
valp = new(g) TYPVAL<PSZ>(g, (PSZ)NULL, len, prec);
break;
case TYPE_DATE:
valp = new(g) DTVAL(g, len, prec, dom);
valp = new(g) DTVAL(g, len, prec, fmt);
break;
case TYPE_INT:
valp = new(g) TYPVAL<int>((int)0, TYPE_INT);
if (prec)
valp = new(g) TYPVAL<uint>((uint)0, TYPE_INT, true);
else
valp = new(g) TYPVAL<int>((int)0, TYPE_INT);
break;
case TYPE_BIGINT:
valp = new(g) TYPVAL<longlong>((longlong)0, TYPE_BIGINT);
if (prec)
valp = new(g) TYPVAL<ulonglong>((ulonglong)0, TYPE_BIGINT, true);
else
valp = new(g) TYPVAL<longlong>((longlong)0, TYPE_BIGINT);
break;
case TYPE_SHORT:
valp = new(g) TYPVAL<short>((short)0, TYPE_SHORT);
if (prec)
valp = new(g) TYPVAL<ushort>((ushort)0, TYPE_SHORT, true);
else
valp = new(g) TYPVAL<short>((short)0, TYPE_SHORT);
break;
case TYPE_FLOAT:
valp = new(g) TYPVAL<double>(0.0, prec, TYPE_FLOAT);
break;
case TYPE_TINY:
valp = new(g) TYPVAL<char>((char)0, TYPE_TINY);
if (prec)
valp = new(g) TYPVAL<uchar>((uchar)0, TYPE_TINY, true);
else
valp = new(g) TYPVAL<char>((char)0, TYPE_TINY);
break;
default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), type);
......@@ -379,9 +368,10 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
/* Allocate a constant Value converted to newtype. */
/* 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
newtype = valp->GetType();
......@@ -395,14 +385,26 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
valp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
break;
case TYPE_SHORT:
valp = new(g) TYPVAL<short>(valp->GetShortValue(), 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);
break;
case TYPE_INT:
valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
if (un)
valp = new(g) TYPVAL<uint>(valp->GetUIntValue(), TYPE_INT, true);
else
valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
break;
case TYPE_BIGINT:
valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
if (un)
valp = new(g) TYPVAL<ulonglong>(valp->GetUBigintValue(), TYPE_BIGINT, true);
else
valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
break;
case TYPE_DATE:
valp = new(g) DTVAL(g, valp->GetIntValue());
......@@ -411,7 +413,11 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_FLOAT);
break;
case TYPE_TINY:
valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
if (un)
valp = new(g) TYPVAL<uchar>(valp->GetUTinyValue(), TYPE_TINY, true);
else
valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
break;
default:
sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype);
......@@ -428,14 +434,15 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype)
/***********************************************************************/
/* 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;
Nullable = false;
Nullable = false;
Unsigned = un;
Clen = 0;
Prec = 0;
Fmt = GetFmt(Type, Unsigned);
Xfmt = GetXfmt();
} // end of VALUE constructor
/***********************************************************************/
......@@ -446,11 +453,11 @@ const char *VALUE::GetXfmt(void)
const char *fmt;
switch (Type) {
case TYPE_STRING: fmt = "%*s"; break;
case TYPE_SHORT: fmt = "%*hd"; break;
case TYPE_BIGINT: fmt = "%*lld"; break;
case TYPE_FLOAT: fmt = "%*.*lf"; break;
default: fmt = "%*d"; break;
case TYPE_STRING: fmt = "%*s"; break;
case TYPE_SHORT: fmt = (Unsigned) ? "%*hu" : "%*hd"; break;
case TYPE_BIGINT: fmt = (Unsigned) ? "%*llu" : "%*lld"; break;
case TYPE_FLOAT: fmt = "%*.*lf"; break;
default: fmt = (Unsigned) ? "%*u" : "%*d"; break;
} // endswitch Type
return fmt;
......@@ -462,20 +469,9 @@ const char *VALUE::GetXfmt(void)
/* TYPVAL public constructor from a constant typed value. */
/***********************************************************************/
template <class TYPE>
TYPVAL<TYPE>::TYPVAL(TYPE n, int type) : VALUE(type)
{
Tval = n;
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)
TYPVAL<TYPE>::TYPVAL(TYPE n, int type, int prec, bool un)
: VALUE(type, un)
{
assert(Type == TYPE_FLOAT);
Tval = n;
Clen = sizeof(TYPE);
Prec = prec;
......@@ -522,14 +518,26 @@ template <>
short TYPVAL<short>::GetTypedValue(PVAL valp)
{return valp->GetShortValue();}
template <>
ushort TYPVAL<ushort>::GetTypedValue(PVAL valp)
{return valp->GetUShortValue();}
template <>
int TYPVAL<int>::GetTypedValue(PVAL valp)
{return valp->GetIntValue();}
template <>
uint TYPVAL<uint>::GetTypedValue(PVAL valp)
{return valp->GetUIntValue();}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PVAL valp)
{return valp->GetBigintValue();}
template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PVAL valp)
{return valp->GetUBigintValue();}
template <>
double TYPVAL<double>::GetTypedValue(PVAL valp)
{return valp->GetFloatValue();}
......@@ -538,6 +546,10 @@ template <>
char TYPVAL<char>::GetTypedValue(PVAL valp)
{return valp->GetTinyValue();}
template <>
uchar TYPVAL<uchar>::GetTypedValue(PVAL valp)
{return valp->GetUTinyValue();}
/***********************************************************************/
/* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/
/***********************************************************************/
......@@ -545,7 +557,7 @@ template <class TYPE>
void TYPVAL<TYPE>::SetValue_char(char *p, int n)
{
char *p2, buf[32];
bool minus;
bool minus = false;
for (p2 = p + n; p < p2 && *p == ' '; p++) ;
......@@ -570,7 +582,7 @@ void TYPVAL<TYPE>::SetValue_char(char *p, int n)
} // endswitch *p
if (minus && Tval)
Tval = - Tval;
Tval = - (signed)Tval;
if (trace > 1)
htrc(strcat(strcat(strcpy(buf, " setting %s to: "), Fmt), "\n"),
......@@ -622,13 +634,21 @@ void TYPVAL<TYPE>::SetValue_psz(PSZ s)
template <>
int TYPVAL<int>::GetTypedValue(PSZ s) {return atol(s);}
template <>
uint TYPVAL<uint>::GetTypedValue(PSZ s) {return (unsigned)atol(s);}
template <>
short TYPVAL<short>::GetTypedValue(PSZ s) {return (short)atoi(s);}
template <>
ushort TYPVAL<ushort>::GetTypedValue(PSZ s) {return (ushort)atoi(s);}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PSZ s) {return atoll(s);}
template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PSZ s) {return (unsigned)atoll(s);}
template <>
double TYPVAL<double>::GetTypedValue(PSZ s) {return atof(s);}
template <>
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. */
......@@ -644,14 +664,26 @@ template <>
int TYPVAL<int>::GetTypedValue(PVBLK blk, int n)
{return blk->GetIntValue(n);}
template <>
uint TYPVAL<uint>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetIntValue(n);}
template <>
short TYPVAL<short>::GetTypedValue(PVBLK blk, int n)
{return blk->GetShortValue(n);}
template <>
ushort TYPVAL<ushort>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetShortValue(n);}
template <>
longlong TYPVAL<longlong>::GetTypedValue(PVBLK blk, int n)
{return blk->GetBigintValue(n);}
template <>
ulonglong TYPVAL<ulonglong>::GetTypedValue(PVBLK blk, int n)
{return (unsigned)blk->GetBigintValue(n);}
template <>
double TYPVAL<double>::GetTypedValue(PVBLK blk, int n)
{return blk->GetFloatValue(n);}
......@@ -660,6 +692,10 @@ template <>
char TYPVAL<char>::GetTypedValue(PVBLK blk, int 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. */
/***********************************************************************/
......@@ -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.
// Therefore this test is useless anyway.
//#if defined(_DEBUG)
// if (sizeof(int) > buflen)
// if (sizeof(TYPE) > buflen)
// return true;
//#endif
......@@ -730,6 +766,7 @@ char *TYPVAL<double>::GetCharString(char *p)
return p;
} // end of GetCharString
#if 0
/***********************************************************************/
/* TYPVAL GetShortString: get short representation of a typed value. */
/***********************************************************************/
......@@ -779,6 +816,7 @@ char *TYPVAL<TYPE>::GetTinyString(char *p, int n)
sprintf(p, "%*d", n, (int)(char)Tval);
return p;
} // end of GetIntString
#endif // 0
/***********************************************************************/
/* TYPVAL compare value with another Value. */
......@@ -875,7 +913,6 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING)
TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c)
: VALUE(TYPE_STRING)
{
assert(Type == TYPE_STRING);
Len = (g) ? n : strlen(s);
if (!s) {
......@@ -981,6 +1018,24 @@ void TYPVAL<PSZ>::SetValue(int n)
Null = false;
} // 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. */
/***********************************************************************/
......@@ -990,6 +1045,15 @@ void TYPVAL<PSZ>::SetValue(short i)
Null = false;
} // 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.*/
/***********************************************************************/
......@@ -1008,6 +1072,24 @@ void TYPVAL<PSZ>::SetValue(longlong n)
Null = false;
} // 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. */
/***********************************************************************/
......@@ -1042,6 +1124,15 @@ void TYPVAL<PSZ>::SetValue(char c)
Null = false;
} // 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. */
/***********************************************************************/
......@@ -1086,6 +1177,7 @@ char *TYPVAL<PSZ>::GetCharString(char *p)
return Strp;
} // end of GetCharString
#if 0
/***********************************************************************/
/* STRING GetShortString: get short representation of a char value. */
/***********************************************************************/
......@@ -1130,6 +1222,7 @@ char *TYPVAL<PSZ>::GetTinyString(char *p, int n)
sprintf(p, "%*d", n, (Null) ? 0 : (char)atoi(Strp));
return p;
} // end of GetIntString
#endif // 0
/***********************************************************************/
/* STRING compare value with another Value. */
......
/**************** 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 */
/* */
......@@ -51,10 +51,10 @@ DllExport char *GetFormatType(int);
DllExport int GetFormatType(char);
DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type);
DllExport int ConvertType(int, int, CONV, bool match = false);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 2,
PSZ dom = NULL, PCATLG cat = NULL);
//lExport int ConvertType(int, int, CONV, bool match = false);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
PSZ fmt = NULL);
/***********************************************************************/
/* Class VALUE represents a constant or variable of any valid type. */
......@@ -68,6 +68,7 @@ class DllExport VALUE : public BLOCK {
virtual bool IsTypeNum(void) = 0;
virtual bool IsZero(void) = 0;
virtual bool IsCi(void) {return false;}
virtual bool IsUnsigned(void) {return Unsigned;}
virtual void Reset(void) = 0;
virtual int GetSize(void) = 0;
virtual int GetValLen(void) = 0;
......@@ -75,9 +76,13 @@ class DllExport VALUE : public BLOCK {
virtual int GetLength(void) {return 1;}
virtual PSZ GetCharValue(void) {assert(false); return NULL;}
virtual char GetTinyValue(void) {assert(false); return 0;}
virtual uchar GetUTinyValue(void) {assert(false); return 0;}
virtual short GetShortValue(void) {assert(false); return 0;}
virtual ushort GetUShortValue(void) {assert(false); return 0;}
virtual int GetIntValue(void) = 0;
virtual uint GetUIntValue(void) = 0;
virtual longlong GetBigintValue(void) = 0;
virtual ulonglong GetUBigintValue(void) = 0;
virtual double GetFloatValue(void) = 0;
virtual void *GetTo_Val(void) = 0;
virtual void SetPrec(int prec) {Prec = prec;}
......@@ -94,20 +99,24 @@ class DllExport VALUE : public BLOCK {
virtual void SetValue_char(char *p, int n) = 0;
virtual void SetValue_psz(PSZ s) = 0;
virtual void SetValue(char c) {assert(false);}
virtual void SetValue(uchar c) {assert(false);}
virtual void SetValue(short i) {assert(false);}
virtual void SetValue(ushort i) {assert(false);}
virtual void SetValue(int n) {assert(false);}
virtual void SetValue(uint n) {assert(false);}
virtual void SetValue(longlong n) {assert(false);}
virtual void SetValue(ulonglong n) {assert(false);}
virtual void SetValue(double f) {assert(false);}
virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
virtual void SetBinValue(void *p) = 0;
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
virtual char *ShowValue(char *buf, int len = 0) = 0;
virtual char *GetCharString(char *p) = 0;
virtual char *GetShortString(char *p, int n) {return "#####";}
virtual char *GetIntString(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 *GetTinyString(char *p, int n) {return "?";}
//virtual char *GetShortString(char *p, int n) {return "#####";}
//virtual char *GetIntString(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 *GetTinyString(char *p, int n) {return "?";}
virtual bool IsEqual(PVAL vp, bool chktype) = 0;
virtual bool FormatValue(PVAL vp, char *fmt) = 0;
......@@ -116,7 +125,7 @@ class DllExport VALUE : public BLOCK {
const char *GetXfmt(void);
// Constructor used by derived classes
VALUE(int type);
VALUE(int type, bool un = false);
// Members
PGLOBAL Global; // To reduce arglist
......@@ -124,6 +133,7 @@ class DllExport VALUE : public BLOCK {
const char *Xfmt;
bool Nullable; // True if value can be null
bool Null; // True if value is null
bool Unsigned; // True if unsigned
int Type; // The value type
int Clen; // Internal value length
int Prec;
......@@ -135,9 +145,8 @@ class DllExport VALUE : public BLOCK {
template <class TYPE>
class DllExport TYPVAL : public VALUE {
public:
// Constructors
TYPVAL(TYPE n, int type);
TYPVAL(TYPE n, int prec, int type);
// Constructor
TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
// Implementation
virtual bool IsTypeNum(void) {return true;}
......@@ -148,9 +157,13 @@ class DllExport TYPVAL : public VALUE {
virtual int GetSize(void) {return sizeof(TYPE);}
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual char GetTinyValue(void) {return (char)Tval;}
virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
virtual short GetShortValue(void) {return (short)Tval;}
virtual ushort GetUShortValue(void) {return (ushort)Tval;}
virtual int GetIntValue(void) {return (int)Tval;}
virtual uint GetUIntValue(void) {return (uint)Tval;}
virtual longlong GetBigintValue(void) {return (longlong)Tval;}
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
virtual double GetFloatValue(void) {return (double)Tval;}
virtual void *GetTo_Val(void) {return &Tval;}
......@@ -159,20 +172,24 @@ class DllExport TYPVAL : public VALUE {
virtual void SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;}
virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;}
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p);
virtual 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 char *GetTinyString(char *p, int n);
//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 char *GetTinyString(char *p, int n);
virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual bool FormatValue(PVAL vp, char *fmt);
......@@ -211,9 +228,13 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
virtual PSZ GetCharValue(void) {return 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 ushort GetUShortValue(void) {return (ushort)atoi(Strp);}
virtual int GetIntValue(void) {return atol(Strp);}
virtual uint GetUIntValue(void) {return (uint)atol(Strp);}
virtual longlong GetBigintValue(void) {return atoll(Strp);}
virtual ulonglong GetUBigintValue(void) {return (ulonglong)atoll(Strp);}
virtual double GetFloatValue(void) {return atof(Strp);}
virtual void *GetTo_Val(void) {return Strp;}
virtual void SetPrec(int prec) {Ci = prec != 0;}
......@@ -224,30 +245,34 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual void SetValue_psz(PSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c);
virtual void SetValue(uchar c);
virtual void SetValue(short i);
virtual void SetValue(ushort i);
virtual void SetValue(int n);
virtual void SetValue(uint n);
virtual void SetValue(longlong n);
virtual void SetValue(ulonglong n);
virtual void SetValue(double f);
virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
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 char *GetTinyString(char *p, int n);
//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 char *GetTinyString(char *p, int n);
virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool FormatValue(PVAL vp, char *fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&);
// Specialized functions
template <class T>
T GetValue_as(T type) {return Strp;}
int GetValue_as(int type) {return atol(Strp);}
short GetValue_as(short type) {return (short)atoi(Strp);}
longlong GetValue_as(longlong type) {return atoll(Strp);}
double GetValue_as(double type) {return atof(Strp);}
//template <class T>
//T GetValue_as(T type) {return Strp;}
//int GetValue_as(int type) {return atol(Strp);}
//short GetValue_as(short type) {return (short)atoi(Strp);}
//longlong GetValue_as(longlong type) {return atoll(Strp);}
//double GetValue_as(double type) {return atof(Strp);}
// Members
PSZ Strp;
......
......@@ -66,7 +66,7 @@ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/* to have rows filled by blanks to be compatible with QRY blocks. */
/***********************************************************************/
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. */
......@@ -2919,7 +2919,7 @@ void KXYCOL::SetValue(PCOL colp, int i)
assert (Kblp != NULL);
#endif
Kblp->SetValue(colp->GetValue(), (int)i);
Kblp->SetValue(colp->GetValue(), i);
} // end of SetValue
/***********************************************************************/
......@@ -2970,7 +2970,7 @@ void KXYCOL::FillValue(PVAL valp)
int KXYCOL::Compare(int i1, int i2)
{
// 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
htrc("Compare done result=%d\n", k);
......@@ -2991,7 +2991,7 @@ int KXYCOL::CompVal(int i)
htrc("Compare done result=%d\n", k);
return k;
#endif
return (int)Kblp->CompVal(Valp, (int)i);
return Kblp->CompVal(Valp, i);
} // end of CompVal
/***********************************************************************/
......@@ -3000,7 +3000,7 @@ int KXYCOL::CompVal(int i)
int KXYCOL::CompBval(int i)
{
// Do the actual comparison between key values.
return (int)Blkp->CompVal(Valp, (int)i);
return Blkp->CompVal(Valp, i);
} // 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