From 078466b6781374b17b5b82de74e05ead5d2acd85 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 8 Dec 2016 13:27:10 +0000 Subject: [PATCH] RxFPC:add enumerator for TConfigValues git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5450 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/trunk/rxconfigvalues.pas | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/components/rx/trunk/rxconfigvalues.pas b/components/rx/trunk/rxconfigvalues.pas index 68d53abce..8ea648a58 100644 --- a/components/rx/trunk/rxconfigvalues.pas +++ b/components/rx/trunk/rxconfigvalues.pas @@ -46,6 +46,7 @@ const cvtFloat = 5; // вещественное type + TConfigValuesEnumerator = class; { TConfigValue } @@ -105,14 +106,46 @@ type procedure SetByNameAsFloat(AName:string; ADefValue:Double); procedure SetByNameAsBoolean(AName:string; ADefValue:Boolean); procedure SetByNameAsDateTime(AName:string; ADefValue:TDateTime); + function GetEnumerator: TConfigValuesEnumerator; public property Items[Index:Integer]:TConfigValue read GetItem;default; property Count:integer read GetCount; 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 +{ 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 } function TConfigValues.CreateValue(AName: string; AType: byte): TConfigValue; @@ -293,6 +326,11 @@ begin P.AsDateTime:=ADefValue; end; +function TConfigValues.GetEnumerator: TConfigValuesEnumerator; +begin + Result:=TConfigValuesEnumerator.Create(Self); +end; + { TConfigValue } function TConfigValue.GetAsBoolean: boolean;