You've already forked lazarus-ccr
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:
@ -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;
|
||||
|
Reference in New Issue
Block a user