ThDelphiStreamAdapter

Provides an adapter to allow a ThStream instance to be used wherever a standard Delphi TStream is expected.
Implements the necessary methods to enable interoperability with Delphi’s native stream handling and VCL/FMX components.
This class is typically used to bridge custom stream logic with standard Delphi libraries and third-party code that operate on TStream objects.

Public Procedures and Functions

Read

Reads up to Count bytes from the adapted stream into the specified Buffer.
Returns the number of bytes actually read.
function Read(var Buffer; Count: Integer): Integer; override;

Parameters

  • Buffer: var (untyped); Memory location to store the data read from the stream.
  • Count: Integer; The maximum number of bytes to read from the stream.

Return Value

Returns the number of bytes actually read from the stream.

Write

Writes up to Count bytes from the specified Buffer to the adapted stream.
Returns the number of bytes actually written.
function Write(const Buffer; Count: Integer): Integer; override;

Parameters

  • Buffer: const (untyped); The data to be written into the stream.
  • Count: Integer; The maximum number of bytes to write to the stream.

Return Value

Returns the number of bytes actually written to the stream.

Seek (Integer overload)

Moves the current position within the stream by Offset bytes, relative to the origin specified.
Returns the new position as an integer.
function Seek(Offset: Integer; Origin: Word): Integer; override;

Parameters

  • Offset: Integer; The number of bytes to move the current position.
  • Origin: Word; The reference point for the seek operation (typically soBeginning, soCurrent, or soEnd).

Return Value

Returns the new position in the stream, as an integer.

Seek (Int64 overload)

Moves the current position within the stream by Offset bytes, relative to the specified TSeekOrigin.
Returns the new position as a 64-bit integer.
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;

Parameters

  • Offset: Int64; The number of bytes to move the current position.
  • Origin: TSeekOrigin; The reference point for the seek operation (soBeginning, soCurrent, or soEnd).

Return Value

Returns the new position in the stream, as a 64-bit integer.