Delphi中DB.PAS变迁概略

为了写QDB,我在群里收集了大家提供的从2007~XE7版的[Data.]DB.PAS文件,并进行一些对比,以试图找出它的变迁历史,我们以2007版(VER180,VER185)为基准,记录下变更的内容:

【RAD Studio 2009-VER200】

+ TFieldType 新增以下类型:

ftLongWord, ftShortint, ftByte, ftExtended, ftConnection, ftParams, ftStream

* WideString改为UnicodeString

+ TFieldDefs增加了一个保护的成员函数来获取字段定义类:

function GetFieldDefClass: TFieldDefClass; virtual;

* TFieldDefs构造函数改成了虚方法

* TIndexDef构造函数改成了虚方法

+ TIndexDefs加入了一保护的成员函数来获取索引定义类:

function GetIndexDefClass: TIndexDefClass; virtual;

* TFlatList的构造方法变成虚方法

* TFields的构造方法变成虚方法

* TLookupList的构造方法变成虚方法

+ TField加入AsExtended、AsAnsiString、AsBytes属性及GetLookupListClass函数,GetData和SetData加入了overload,当然其子类也就加入了相应的实现,就略过不表。

function GetLookupListClass: TLookupListClass; virtual;

+ 新增TLongwordField继承自TNumericField;TByteField继承自TIntegerField;TExtendedField继承自TNumericField;

* TCheckConstraints的构造方法变成虚方法

* TBlobData由String替换为TBytes

+ TParam新增以下函数和属性:

procedure SetDataSet(Dataset: TDataSet; AInstanceOwner: Boolean);
procedure SetParams(Params: TParams; AInstanceOwner: Boolean);
procedure SetStream(Stream: TStream; AInstanceOwner: Boolean);
property AsShortInt: LongInt read GetAsInteger write SetAsShortInt;
property AsByte: LongInt read GetAsInteger write SetAsByte;
property AsLongWord: LongWord read GetAsLongWord write SetAsLongWord;
property AsLargeInt: LargeInt read GetAsLargeInt write SetAsLargeInt;
property AsWideString: UnicodeString read GetAsWideString write SetAsWideString;
property AsAnsiString: AnsiString read GetAsAnsiString write SetAsAnsiString;
property AsBytes: TBytes read GetAsBytes write SetAsBytes;
property AsDataSet: TDataSet read GetAsDataSet write SetAsDataSet;
property AsParams: TParams read GetAsParams write SetAsParams;
property AsStream: TStream read GetAsStream write SetAsStream;

+ TParams加入了一保护的成员函数来获取参数类:

function GetParamClass: TParamClass; virtual;

+ IParamImplementation、TParamObject、TParamDataSetObject、TParamParamsObject、TParamStreamObject

+ TPSCommandType新增ctServerMethod

* IProviderSupport2被标记为作废

* TBookmark由AnsiString改为TBytes

+ 新增TRecordBuffer ,类型对应于 PByte

* TBufferList由array of PChar改为 array of  TRecordBuffer

* TBlobByteData由array of Byte改为TBytes

* TDataSet的CalcBuffer等记录缓冲区类型由PChar改变了TRecordBuffer,Bookmark由TBookmarkStr改为TBookmark

+ TDataSet.GetFieldClass加入了一个重载

+ TDataSet增加以下虚拟方法

function GetFieldDefsClass: TFieldDefsClass; virtual;
function GetFieldDefListClass: TFieldDefListClass; virtual;
function GetFieldsClass: TFieldsClass; virtual;
function GetFieldListClass: TFieldListClass; virtual;
function GetCheckConstraintsClass: TCheckConstraintsClass; virtual;
function GetAggFieldsClass: TFieldsClass; virtual;
function GetIndexDefsClass: TIndexDefsClass; virtual;
function GetParamsClass: TParamsClass; virtual;

+ ftFixedSizeTypes集全新增[ftLongWord, ftShortInt, ftByte, ftExtended]

+ DefaultFieldClasses新增[TStringField,TLongWordField, TShortintField, TByteField, TExtendedField],Interval类型被映射到TStringField了

+ FieldTypeNames和FieldTypeVarMap新增新类型的名称

【RAD Studio 2010-VER210】

+ TFieldType新增类型[ftTimeStampOffset, ftObject, ftSingle]

+ TNamedItem新增哈希

class function HashName(const Name: string): Cardinal; static;

+ 新增Int64别名Largeint定义

+ TField新增以下属性,并且有些函数改成了内联

property AsSQLTimeStampOffset: TSQLTimeStampOffset read GetAsSQLTimeStampOffset write SetAsSQLTimeStampOffset;
property AsSingle: Single read GetAsSingle write SetAsSingle;
property AsLargeInt: Largeint read GetAsLargeInt write SetAsLargeInt;

+ 新增TSingleField、TSQLTimeStampOffsetField实现

+ TParam也加入了AsSQLTimeStampOffset、AsSingle、AsLargeInt属性

* TParamObject、TParamStreamObject及相关定义完全变了

+ ftFixedSizeTypes新增ftTimeStampOffset, ftSingle,同样DefaultFieldClasses、FieldTypeNames和FieldTypeVarMap都增加了新类型

【RadStudio XE-VER220】

* 基本可以认为无变化,你是将Windows单元的引用改为条件编译选项了。

【RadStudio XE2-VER230】

* 很多函数的整数类型参数被换成了NativeInt,也就是说NativeInt正式进入DB.PAS的视野。

TDataLink/TDataSet/TDataSource/TDataSetDesigner.DataEvent的Info参数
TDataSource.NotifyDataLinks、NotifyLinkTypes的Info参数

+ 新增TDataSetCommandStates 枚举类型和IDataSetCommandSupport接口

【RadStudio XE3-VER240】

* TList相关的成员全部改为了泛型TList<类型>

* TFieldChars在移动平台标记为作废了。

+ ISubDataSet接口及TValueBuffer类型(映射到TArray<Byte>)

* TField的FValueBuffer由Pointer改为TValueBuffer,相关的函数也都改成TValueBuffer的重载了:

procedure CopyData(Source, Dest: TValueBuffer); overload; virtual;
function GetData(Buffer: TValueBuffer; NativeFormat: Boolean = True): Boolean; overload;
procedure SetData(Buffer: TValueBuffer; NativeFormat: Boolean = True); overload;
procedure Validate(Buffer: TValueBuffer); overload;

+ TField加入AsLongWord属性

* TBlobField的Value由TBytes改成了TArray<Byte>

* TAggregateField的Handle类型由Pointer改成了TAggHandle(映射到TObject),并且发布了一个Handle属性。

+ 新增了TBitConverter

* TBlobData、TBookmark类型再次改为了TArray<Byte>

+ TBlobByteData映射到TArray<Byte>

* TDataSet.DataConvert函数重载为(好吧,又是TValueBuffer):

procedure DataConvert(Field: TField; Source, Dest: TValueBuffer; ToNative: Boolean); overload; virtual;

 * TBookmark开始真正大显神威

procedure GetBookmarkData(Buffer: TRecordBuffer; Data: TBookmark); overload; virtual;//Data:Pointer->TBookmark
procedure InternalAddRecord(Buffer: TRecordBuffer; Append: Boolean); overload; virtual;//Buffer:Pointer->TRecordBuffer
procedure InternalGotoBookmark(Bookmark: TBookmark); overload; virtual;//Bookmark:Pointer->TBookmark
procedure SetBookmarkData(Buffer: TRecordBuffer; Data: TBookmark); overload; virtual;//Data:Pointer->TBookmark
procedure SetFieldData(Field: TField; Buffer: TValueBuffer); overload; virtual;//Buffer:Pointer->TValueBuffer
procedure SetFieldData(Field: TField; Buffer: TValueBuffer; NativeFormat: Boolean); overload; virtual;//Buffer:Pointer->TValueBuffer
function GetFieldData(Field: TField; Buffer: TValueBuffer): Boolean; overload; virtual;///Buffer:Pointer->TValueBuffer
function GetFieldData(FieldNo: Integer; Buffer: TValueBuffer): Boolean; overload; virtual;//Buffer:Pointer->TValueBuffer
function GetFieldData(Field: TField; Buffer: TValueBuffer; NativeFormat: Boolean): Boolean; overload; virtual;;//Buffer:Pointer->TValueBuffer

 * TWideDataSet被删除了

【RADStudio XE4-VER250】

* 许多内部成员被标记为Weak,以解决循环引用计数问题

* TField增加了一个FValueBufferPtr的Pointer类型成员(折腾)

+加入TRecBuf类型定义,映射到( NativeInt),然后TBufList映射为 TArray<NativeInt>;严重怀疑回头映射到TArray<TRecBuf>

* TDataSet大变动:

FBuffers:TBufferList->TBufList;
FCalcBuffer: TRecordBuffer->NativeInt;
GetBuffer: 返回值TRecordBuffer->TRecBuf;
procedure CalculateFields(Buffer: NativeInt); overload; virtual;//Buffer:TRecordBuffer->NativeInt
procedure ClearCalcFields(Buffer: NativeInt); overload; virtual;//Buffer:TRecordBuffer->NativeInt
procedure DataConvert(Field: TField; Source: TValueBuffer; var Dest: TValueBuffer; ToNative: Boolean); overload; virtual;//Dest改为var
procedure GetCalcFields(Buffer: TRecBuf); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure InitRecord(Buffer: TRecBuf); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure RefreshInternalCalcFields(Buffer: TRecBuf); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
function TempBuffer: TRecBuf; inline;//返回值:TRecordBuffer->TRecBuf
property Buffers://TRecordBuffer->TRecBuf;
property CalcBuffer://TRecordBuffer->NativeInt;
procedure GetBookmarkData(Buffer: TRecBuf; Data: TBookmark); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
function GetBookmarkFlag(Buffer: TRecBuf): TBookmarkFlag; overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure InternalAddRecord(Buffer: TRecBuf; Append: Boolean); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure InternalInitRecord(Buffer: TRecBuf); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure InternalSetToRecord(Buffer: TRecBuf); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure SetBookmarkFlag(Buffer: TRecBuf; Value: TBookmarkFlag); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
procedure SetBookmarkData(Buffer: TRecBuf; Data: TBookmark); overload; virtual;//Buffer:TRecordBuffer->TRecBuf
function GetRecord(Buffer: TRecBuf; GetMode: TGetMode; DoCheck: Boolean): TGetResult; overload; virtual; //Buffer:TRecordBuffer->TRecBuf
function ActiveBuffer: TRecBuf; inline; //Buffer:TRecordBuffer->TRecBuf
function GetCurrentRecord(Buffer: TRecBuf): Boolean; overload; virtual;//Buffer:TRecordBuffer->TRecBuf
function GetFieldData(Field: TField; var Buffer: TValueBuffer): Boolean; overload; virtual;//Buffer加增var
function GetFieldData(FieldNo: Integer; var Buffer: TValueBuffer): Boolean; overload; virtual;//Buffer加增var
function GetFieldData(Field: TField; var Buffer: TValueBuffer; NativeFormat: Boolean): Boolean; overload; virtual;//Buffer加增var

移动平台下增加下面两个函数
function AllocRecBuf: TRecBuf; virtual;
procedure FreeRecBuf(var Buffer: TRecBuf); virtual;

【RadStudio XE5-VER260】

+ 加了个PDateTimeRec定义,剩下的定义基本没变,只是修改Bug

【RadStudio XE6-VER270】

+ 增加类型TFieldsAutoCreationMode、TFieldsPositionMode、TFieldLifeCycle、TFieldLifeCycles

+ TFields增加ClearAutomatic函数和LifeCycles属性

+ TField增加两个虚拟函数和LifeCycle、Validating、AutoGenerateValue属性

procedure SetFieldProps(FieldDef: TFieldDef); virtual;
procedure SetFieldDefProps(FieldDef: TFieldDef); virtual;

+ TFieldOptions类

+ TDataSet增加CanRefresh属性及一些新的保护函数

+ 增加ftCalcFieldTypes集合来标记允许设置为计算字段的类型

【RadStudio XE7-VER280】

+ TFieldTypes集合类型

* TParamStreamObject接口又变了,好在我好象用不到

– ftCalcFieldTypes将ftVariant给删除了

* DefaultFields 已经被标记为作废

分享到: