⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 absvariant.pas

📁 Absolute Database 是来替代BDE[Borland数据库引擎]的用于Delphi 和 C++ Builder 开发用的数据库引擎. 它小巧, 高速, 健壮, 易于使用. 它能直接编译进
💻 PAS
📖 第 1 页 / 共 5 页
字号:

//------------------------------------------------------------------------------
// Get Data for Unsigned Int8 (Byte)
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsUnsignedInt8: Byte;
begin
  GetDataValue(Result, bftUnsignedInt8);
end;//GetDataAsUnsignedInt8


//------------------------------------------------------------------------------
// Set Data for Unsigned Int16 (Word)
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsUnsignedInt16(Value: Word);
begin
  SetDataValue(Value, bftUnsignedInt16);
end;//SetDataAsUnsignedInt16


//------------------------------------------------------------------------------
// Get Data for Unsigned Int16 (Word)
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsUnsignedInt16: Word;
begin
  GetDataValue(Result, bftUnsignedInt16);
end;//GetDataAsUnsignedInt16


//------------------------------------------------------------------------------
// Set Data for Unsigned Int32 (Cardinal)
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsUnsignedInt32(Value: Cardinal);
begin
  SetDataValue(Value, bftUnsignedInt32);
end;//SetDataAsUnsignedInt32


//------------------------------------------------------------------------------
// Get Data for Unsigned Int32 (Cardinal)
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsUnsignedInt32: Cardinal;
begin
  GetDataValue(Result, bftUnsignedInt32);
end;//GetDataAsUnsignedInt32


//------------------------------------------------------------------------------
// Set Data for Char, Varchar (String)
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsString(Value: String);
begin
  SetDataValue(Value, bftVarchar);
end;//SetDataAsString


//------------------------------------------------------------------------------
// Get Data as String
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsString: String;
begin
  GetDataValue(Result, bftVarchar);
end;//GetDataAsString


//------------------------------------------------------------------------------
// Set Data for WideChar, WideVarchar (WideString)
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsWideString(Value: WideString);
begin
  SetDataValue(Value, bftWideVarchar);
end;//SetDataAsWideString


//------------------------------------------------------------------------------
// Get Data as WideString
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsWideString: WideString;
begin
  GetDataValue(Result, bftWideVarchar);
end;//GetDataAsWideString


//------------------------------------------------------------------------------
// Set Data for Single
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsSingle(Value: Single);
begin
  SetDataValue(Value, bftSingle);
end;//SetDataAsSingle


//------------------------------------------------------------------------------
// Get Data for Single
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsSingle: Single;
begin
  GetDataValue(Result, bftSingle);
end;//GetDataAsSingle


//------------------------------------------------------------------------------
// Set Data for Double
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsDouble(Value: Double);
begin
  SetDataValue(Value, bftDouble);
end;//SetDataAsDouble


//------------------------------------------------------------------------------
// Get Data for Double
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsDouble: Double;
begin
  GetDataValue(Result, bftDouble);
end;//GetDataAsDouble


//------------------------------------------------------------------------------
// Set Data for Extended
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsExtended(Value: Extended);
begin
  SetDataValue(Value, bftExtended);
end;//SetDataAsExtended


//------------------------------------------------------------------------------
// Get Data for Extended
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsExtended: Extended;
begin
  GetDataValue(Result, bftExtended);
end;//GetDataAsExtended




//------------------------------------------------------------------------------
// Set Data for ABSDate
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsABSDate(Value: TABSDate);
begin
  SetDataValue(Value, bftDate);
end;//SetDataAsABSDate


//------------------------------------------------------------------------------
// Get Data for ABSDate
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsABSDate: TABSDate;
begin
  GetDataValue(Result, bftDate);
end;//GetDataAsABSDate


//------------------------------------------------------------------------------
// Set Data for TDate
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsTDate(Value: TDateTime);
begin
  SetDataAsABSDate(DateToABSDate(Value));
end;//SetDataAsTDate


//------------------------------------------------------------------------------
// Get Data for TDate
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsTDate: TDateTime;
begin
  Result := ABSDateToDate(GetDataAsABSDate);
end;//GetDataAsTDate


//------------------------------------------------------------------------------
// Set Data for ABSTime
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsABSTime(Value: TABSTime);
begin
  SetDataValue(Value, bftTime);
end;//SetDataAsABSTime


//------------------------------------------------------------------------------
// Get Data for ABSTime
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsABSTime: TABSTime;
begin
  GetDataValue(Result, bftTime);
end;//GetDataAsABSTime


//------------------------------------------------------------------------------
// Set Data for TTime
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsTTime(Value: TDateTime);
begin
  SetDataAsABSTime(TimeToABSTime(Value));
end;//SetDataAsTTime


//------------------------------------------------------------------------------
// Get Data for ABSTime
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsTTime: TDateTime;
begin
  Result := ABSTimeToTime(GetDataAsABSTime);
end;//GetDataAsTTime



//------------------------------------------------------------------------------
// Set Data for ABSDateTime
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsABSDateTime(Value: TABSDateTime);
begin
  SetDataValue(Value, bftDateTime);
end;//SetDataAsABSDateTime


//------------------------------------------------------------------------------
// Get Data for ABSDateTime
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsABSDateTime: TABSDateTime;
begin
  GetDataValue(Result, bftDateTime);
end;//GetDataAsABSDateTime


//------------------------------------------------------------------------------
// Set Data for TDateTime
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsTDateTime(Value: TDateTime);
begin
  SetDataAsABSDateTime(DateTimeToABSDateTime(Value));
end;//SetDataAsTDateTime


//------------------------------------------------------------------------------
// Get Data for TDateTime
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsTDateTime: TDateTime;
begin
  Result := ABSDateTimeToDateTime(GetDataAsABSDateTime);
end;//GetDataAsTDateTime



procedure TABSVariant.SetDataAsBoolean(Value: TABSLogical);
begin
  SetDataValue(Value, bftLogical);
end;


//------------------------------------------------------------------------------
// Get Data for Boolean
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsBoolean: TABSLogical;
begin
  GetDataValue(Result, bftLogical);
end;//GetDataAsBoolean


//------------------------------------------------------------------------------
// Set Data for Currency
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsCurrency(Value: TABSCurrency);
begin
  SetDataValue(Value, bftCurrency);
end;//SetDataAsCurrency


//------------------------------------------------------------------------------
// Get Data for Currency
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsCurrency: TABSCurrency;
begin
  GetDataValue(Result, bftCurrency);
end;//GetDataAsCurrency


//------------------------------------------------------------------------------
// Set Data from Borland Variant type
//------------------------------------------------------------------------------
procedure TABSVariant.SetDataAsVariant(Value: Variant);
begin
  case VarType(Value) of
    varSmallint:
      AsSmallint := Value;
    varInteger:
      AsInteger := Value;
    varSingle:
      AsSingle := Value;
    varDouble:
      AsDouble := Value;
    varCurrency:
      AsCurrency := Value;
    varDate:
      AsTDateTime := Value;
    varOleStr:
      AsWideString := Value;
    //varDispatch
    //varError
    varBoolean: AsBoolean := Value;
    //varVariant
    //varUnknown
{$IFDEF D6H}
    varShortInt:
      AsShortInt := Value;
    varWord:
      AsWord := Value;
    varLongWord:
      AsCardinal := Value;
    varInt64:
      AsInt64 := Value;
{$ENDIF}      
    varByte:
      AsByte := Value;
    //varStrArg
    //varString,
    varString .. varString + $1F:
      AsString := Value;
    //varAny
    //varTypeMask
    //varArray
    //varByRef
    varNull, varEmpty:
      SetNull(FDataType);
    else
      raise EABSException.Create(30113, ErrorGUnsupportedVariantType, [IntToStr(VarType(Value))]);
  end;
end;//SetDataAsVariant


//------------------------------------------------------------------------------
// Get Data to Borland Variant type
//------------------------------------------------------------------------------
function TABSVariant.GetDataAsVariant: Variant;
begin
  if (IsNull) then
    Result := Null
  else
    case FDataType of
      bftChar,
      bftVarchar:
        Result := AsString;
      bftWideChar,
      bftWideVarchar:
        Result := AsWideString;


      bftSignedInt8:
        Result := AsShortint;
      bftSignedInt16:
        Result := AsSmallint;
      bftSignedInt32:
        Result := AsInteger;
  {$IFDEF D6H}
      bftSignedInt64:
        Result := AsInt64;
  {$ENDIF}
      bftUnsignedInt8:
        Result := AsByte;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -