RxFPC:add enumerator for TConfigValues

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5450 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-12-08 13:27:10 +00:00
parent af40a94fc1
commit 078466b678

View File

@ -46,6 +46,7 @@ const
cvtFloat = 5; // вещественное cvtFloat = 5; // вещественное
type type
TConfigValuesEnumerator = class;
{ TConfigValue } { TConfigValue }
@ -105,14 +106,46 @@ type
procedure SetByNameAsFloat(AName:string; ADefValue:Double); procedure SetByNameAsFloat(AName:string; ADefValue:Double);
procedure SetByNameAsBoolean(AName:string; ADefValue:Boolean); procedure SetByNameAsBoolean(AName:string; ADefValue:Boolean);
procedure SetByNameAsDateTime(AName:string; ADefValue:TDateTime); procedure SetByNameAsDateTime(AName:string; ADefValue:TDateTime);
function GetEnumerator: TConfigValuesEnumerator;
public public
property Items[Index:Integer]:TConfigValue read GetItem;default; property Items[Index:Integer]:TConfigValue read GetItem;default;
property Count:integer read GetCount; property Count:integer read GetCount;
end; end;
{ TConfigValuesEnumerator }
TConfigValuesEnumerator = class
private
FList: TConfigValues;
FPosition: Integer;
public
constructor Create(AList: TConfigValues);
function GetCurrent: TConfigValue;
function MoveNext: Boolean;
property Current: TConfigValue read GetCurrent;
end;
implementation implementation
{ TConfigValuesEnumerator }
constructor TConfigValuesEnumerator.Create(AList: TConfigValues);
begin
FList := AList;
FPosition := -1;
end;
function TConfigValuesEnumerator.GetCurrent: TConfigValue;
begin
Result := FList[FPosition];
end;
function TConfigValuesEnumerator.MoveNext: Boolean;
begin
Inc(FPosition);
Result := FPosition < FList.Count;
end;
{ TConfigValues } { TConfigValues }
function TConfigValues.CreateValue(AName: string; AType: byte): TConfigValue; function TConfigValues.CreateValue(AName: string; AType: byte): TConfigValue;
@ -293,6 +326,11 @@ begin
P.AsDateTime:=ADefValue; P.AsDateTime:=ADefValue;
end; end;
function TConfigValues.GetEnumerator: TConfigValuesEnumerator;
begin
Result:=TConfigValuesEnumerator.Create(Self);
end;
{ TConfigValue } { TConfigValue }
function TConfigValue.GetAsBoolean: boolean; function TConfigValue.GetAsBoolean: boolean;