Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 1.78 KB

TPJPipeFilter-Create.md

File metadata and controls

63 lines (47 loc) · 1.78 KB

Create constructor

Project: I/O Utility Classes

Unit: PJPipeFilters

Classes: TPJPipeFilter, TPJUnicodeBMPPipeFilter, TPJAnsiSBCSPipeFilter

Applies to: ~>1.0

constructor Create(const APipe: TPJPipe; const AOwnsPipe: Boolean = False);

Description

This constructor creates an instance of the filter object to operate on a specified pipe.

Parameters:

  • APipe - Pipe on which the filters are to act. The pipe will be exposed via the read only Pipe property.

  • AOwnsPipe - Flag that indicates whether the filter object owns the pipe. If true then the pipe object will be freed when the filter object is destroyed.

Remarks

The filter object will read the pipe whenever the filter's ReadPipe method is called.

Setting AOwnsPipe to true means that pipes can be created on the fly in the filter's constructor and they will be freed automatically at the appropriate time. For example the two following code fragments are functionally the same:

var
  Filter: TPJUnicodeBMPPipeFilter;
  Pipe: TPJPipe;
begin
  Pipe := TPJPipe.Create;
  try
    Filter := TPJUnicodeBMPPipeFilter.Create(Pipe, False);
    try
      // do something with Filter and Pipe
    finally
      Filter.Free;
    end;
  finally
    Pipe.Free;
  end;
end;
var
  Filter: TPJUnicodeBMPPipeFilter;
begin
  Filter := TPJUnicodeBMPPipeFilter.Create(TPJPipe.Create, True);
  try
    // do something with Filter and Filter.Pipe
  finally
    Filter.Free;
  end;
end;

In the second listing, if we need to access the pipe object we must use the filter's Pipe property.