Skip to content

Add enumerator overloads with no Data parameter. #17

@delphidabbler

Description

@delphidabbler

Although the Data parameter of the various TPJEnvironmentVars enumerator methods is useful on occasion, a lot of the time it isn't required.

So how about a couple more enumerator overloads without the Data parameter? E.g.:

TPJEnvironmentVars = class(TObject)
// ...
public 
  // ...
  type
    TEnumNamesCallback = reference to procedure (const VarName: string);
    TEnumVarsCallback = reference to procedure(const EnvVar: TPJEnvironmentVar);
    //.. 
  class procedure EnumNames(Callback: TEnumNamesCallback); overload;
  class procedure EnumVars(Callback: TEnumVarsCallback); overload;
  // ...
end;

// ...

class procedure TPJEnvironmentVars.EnumNames(Callback: TEnumNamesCallback)
begin
  Assert(Assigned(Callback));
  EnumNames<Integer>(
    procedure (const VarName: string; Data: Integer)
    begin
      Callback(VarName);
    end,
    0 // Dummy value
  );
end;

class procedure TPJEnvironmentVars.EnumVars(Callback: TEnumVarsCallback)
begin
  Assert(Assigned(Callback));
  EnumVars<Integer>(
    procedure (const EnvVar: TPJEnvironmentVar; Data: Integer)
    begin
      Callback(EnvVar);
    end,
    0 // Dummy value
  );
end;

Metadata

Metadata

Assignees

Labels

completedWork has completed (may not have been pushed to GitHub yet)enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions