Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

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:

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.