mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-18 17:19:32 +02:00
packages: add enumerator for TFields class
git-svn-id: trunk@14065 -
This commit is contained in:
parent
eee6658a46
commit
7db712c566
@ -992,6 +992,19 @@ type
|
||||
property Items[Index: Longint]: TCheckConstraint read GetItem write SetItem; default;
|
||||
end;
|
||||
|
||||
{ TFieldsEnumerator }
|
||||
|
||||
TFieldsEnumerator = class
|
||||
private
|
||||
FPosition: Integer;
|
||||
FFields: TFields;
|
||||
function GetCurrent: TField;
|
||||
public
|
||||
constructor Create(AFields: TFields);
|
||||
function MoveNext: Boolean;
|
||||
property Current: TField read GetCurrent;
|
||||
end;
|
||||
|
||||
{ TFields }
|
||||
|
||||
Tfields = Class(TObject)
|
||||
@ -1019,6 +1032,7 @@ type
|
||||
Function FindField (Const Value : String) : TField;
|
||||
Function FieldByName (Const Value : String) : TField;
|
||||
Function FieldByNumber(FieldNo : Integer) : TField;
|
||||
Function GetEnumerator: TFieldsEnumerator;
|
||||
Procedure GetFieldNames (Values : TStrings);
|
||||
Function IndexOf(Field : TField) : Longint;
|
||||
procedure Remove(Value : TField);
|
||||
|
@ -2796,6 +2796,25 @@ begin
|
||||
SetData(@aValue);
|
||||
end;
|
||||
|
||||
{ TFieldsEnumerator }
|
||||
|
||||
function TFieldsEnumerator.GetCurrent: TField;
|
||||
begin
|
||||
Result := FFields[FPosition];
|
||||
end;
|
||||
|
||||
constructor TFieldsEnumerator.Create(AFields: TFields);
|
||||
begin
|
||||
inherited Create;
|
||||
FFields := AFields;
|
||||
FPosition := -1;
|
||||
end;
|
||||
|
||||
function TFieldsEnumerator.MoveNext: Boolean;
|
||||
begin
|
||||
inc(FPosition);
|
||||
Result := FPosition < FFields.Count;
|
||||
end;
|
||||
|
||||
{ TFields }
|
||||
|
||||
@ -2955,6 +2974,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TFields.GetEnumerator: TFieldsEnumerator;
|
||||
|
||||
begin
|
||||
Result:=TFieldsEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
Procedure TFields.GetFieldNames (Values : TStrings);
|
||||
|
||||
Var i : longint;
|
||||
|
Loading…
Reference in New Issue
Block a user