mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Make use of "Generics" provided by Delphi, to hold the list of tables, views etc. Easy to use and removes silly, redundant code.
This commit is contained in:
@@ -4,7 +4,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, windows, mysql_api, mysql_structures, WideStrings, WideStrUtils, SynRegExpr,
|
||||
Contnrs;
|
||||
Contnrs, Generics.Collections;
|
||||
|
||||
type
|
||||
{ TDBObjectList and friends }
|
||||
@@ -17,16 +17,7 @@ type
|
||||
Rows, Size, Version, AvgRowLen, MaxDataLen, IndexLen, DataLen, DataFree, AutoInc, CheckSum: Int64;
|
||||
NodeType: TListNodeType;
|
||||
end;
|
||||
TDBObjectList = class(TObjectList)
|
||||
protected
|
||||
function getItem(AIndex: Integer): TDBObject; virtual;
|
||||
procedure setItem(AIndex: Integer; AObject: TDBObject); virtual;
|
||||
public
|
||||
function Add(AObject: TDBObject): Integer; virtual;
|
||||
procedure Insert(AIndex: Integer; AObject: TDBObject); virtual;
|
||||
function First: TDBObject; virtual;
|
||||
property Items[Index: Integer]: TDBObject read getItem write setItem; default;
|
||||
end;
|
||||
TDBObjectList = TObjectList<TDBObject>;
|
||||
|
||||
{ TMySQLConnection }
|
||||
|
||||
@@ -1330,32 +1321,4 @@ end;
|
||||
|
||||
|
||||
|
||||
{ TDBObjectList }
|
||||
|
||||
function TDBObjectList.Add(AObject: TDBObject): Integer;
|
||||
begin
|
||||
Result := inherited Add(AObject);
|
||||
end;
|
||||
|
||||
function TDBObjectList.First: TDBObject;
|
||||
begin
|
||||
Result := inherited First as TDBObject;
|
||||
end;
|
||||
|
||||
function TDBObjectList.getItem(AIndex: Integer): TDBObject;
|
||||
begin
|
||||
Result := inherited GetItem(AIndex) as TDBObject;
|
||||
end;
|
||||
|
||||
procedure TDBObjectList.Insert(AIndex: Integer; AObject: TDBObject);
|
||||
begin
|
||||
inherited Insert(AIndex, AObject);
|
||||
end;
|
||||
|
||||
procedure TDBObjectList.setItem(AIndex: Integer; AObject: TDBObject);
|
||||
begin
|
||||
inherited setItem(AIndex, AObject);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user