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:
Ansgar Becker
2010-01-07 23:46:30 +00:00
parent fd516f8b0c
commit 35aa9c4dbf

View File

@@ -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.