Skip to content

TCustomMemoryStream

Abstract stream that stores its data in memory.

Declaration

Source position: classesh.inc line 1610

type

  TCustomMemoryStream = class(TStream)
  public
    function Read : LongInt;
    function Seek : Int64;
    procedure SaveToStream;
    procedure SaveToFile;
    property Memory: Pointer; {r}
    property SizeBoundsSeek: Boolean; {rw}
  end;

Description

TCustomMemoryStream is the parent class for streams that stored their data in memory. It introduces all needed functions to handle reading from and navigating through the memory, and introduces a Memory property which points to the memory area where the stream data is kept.

The only thing which TCustomMemoryStream does not do is obtain memory to store data when writing data or the writing of data. This functionality is implemented in descendant streams such as TMemoryStream. The reason for this approach is that this way it is possible to create e.g. read-only descendants of TCustomMemoryStream that point to a fixed part in memory which can be read from, but not written to.

Remark:

Since TCustomMemoryStream is an abstract class, do not create instances of TMemoryStream directly. Instead, create instances of descendants such as TMemoryStream.

Properties

Member Visibility Description
Memory read only public Pointer to the data kept in the memory stream.
SizeBoundsSeek public
See all Properties

Methods

Member Visibility Description
Read public Reads Count bytes from the stream into buffer.
SaveToFile public Writes the contents of the stream to a file.
SaveToStream public Writes the contents of the memory stream to another stream.
Seek public Sets a new position in the stream.
See all Methods

See also

Name Description
TMemoryStream Standard implementation of a stream that stores its data in memory.
TStream Base class for streams.