#include "decimals.h"
#include "inter.h"
#include "tick.h"
#include "exlib.h"
static const L_LONG Byte_Const = 0x010203ff;
static const L_LONG Varbyte_Const = 0xff0302;
static const L_CHAR Char_Const[] = "char";
static const L_CHAR Varchar_Const[] = "vchar";
static const wchar_t NVarchar_Const[] = L"nvarchar";
static const wchar_t NChar_Const[] = L"nchar";
static const L_DOUBLE Double_Const = 30.01;
static const L_REAL Real_Const = -12.34567f;
static const L_BOOL Bool_Const = L_TTRUE;
static const L_CHAR Extfile_Const[] = "EXTFILE";
static const L_SWORD Smallint_Const = 2;
static const L_LONG Int_Const = 4;
// Заполняет буфер простейшим значением в зависимости от типа в байтовом виде:
L_BYTE *MakeBYTEValue(int type, int Len, L_BYTE* buf)
{
switch (type)
{
case DT_CHAR: return memcpy(buf, Char_Const, sizeof(Char_Const));
case DT_VARCHAR: return memcpy(buf, Varchar_Const, sizeof(Varchar_Const));
case DT_BYTE: return memcpy(buf, &Byte_Const, sizeof(Byte_Const));
case DT_VARBYTE: return memcpy(buf, &Varbyte_Const, sizeof(Varbyte_Const));
case DT_NCHAR: return memcpy(buf, NChar_Const, sizeof(NChar_Const));
case DT_NVARCHAR: return memcpy(buf, NVarchar_Const, sizeof(NVarchar_Const));
case DT_DATE:
{
DECIMAL dateVal;
STRTOTICK("03.03.2003:16:29:00.00", dateVal);
return memcpy(buf, &dateVal, Len);
}
case DT_INTEGER:
if (Len == sizeof(L_SWORD))
return memcpy(buf, &Smallint_Const, Len);
if (Len == sizeof(L_LONG))
return memcpy(buf, &Int_Const, Len);
return NULL; // Будет обозначать NULL-значение
case DT_REAL:
if (Len == sizeof(L_REAL))
return memcpy(buf, &Real_Const, Len);
return memcpy(buf, &Double_Const, Len);
case DT_DECIMAL:
{
DECIMAL decVal;
DblToDec(12.34, decVal);
return memcpy(buf, &decVal, Len);
}
case DT_BOOL: return memcpy(buf, &Bool_Const, Len);
case DT_EXTFILE: return memcpy(buf, Extfile_Const, sizeof(Extfile_Const));
default: return NULL;
} // switch
} // MakeBYTEValue