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.

PJStreamWrapper Unit

Project: Stream Extension Classes

Applies to: ~>3.0

Description

This unit defines TPJStreamWrapper which is a base class for descendants that “wrap” TStream instances to provide a filter or to add functionality.

The wrapped TStream instance is used to do physical i/o. TPJStreamWrapper simply replicates the facilities in the wrapped stream. It is for descendant classes to add functionality.

Declarations

Optional Conditionally Defined Symbol [~>3.1]

There is an error in TStringStream’s Seek implementation that occurs only in non-Unicode versions of the Classes unit. Calls to Seek using the soFromEnd origin incorrectly handle offsets: positive offsets move back from the end of the stream. This behaviour is the opposite of all other stream classes which require a negative offset to move back from the end of the stream. Note that Unicode implementations of TStringStream do not have this error.

By default TPJStreamWrapper fixes this problem and all wrapped streams behave correctly and in the same way.

If you prefer this bug to be replicated in wrapped TStringStream classes, or if this change in behaviour from earlier versions of TPJStreamWrapper may break existing code, you can revert to the earlier behaviour by commenting out the FIX_TSTRINGSTREAM_SEEK_ERROR defined symbol in the unit source code.