TCustomMemoryStream
[Properties (by Name)][Methods (by Name)][Events (by Name)]
Abstract stream that stores its data in memory.
Declaration
Source position: classesh.inc line 1193
Type
TCustomMemoryStream = class (TStream)
private
FMemory : Pointer;
FSize : PtrInt;
FPosition : PtrInt;
FSizeBoundsSeek : Boolean;
protected
function GetSize : Int64; Override;
function GetPosition : Int64; Override;
procedure SetPointer(Ptr: Pointer; ASize: PtrInt);
public
function Read(var Buffer; Count: LongInt) : LongInt; Override;
function Seek(const Offset: Int64; Origin: TSeekOrigin) : Int64
; Override;
procedure SaveToStream(Stream: TStream);
procedure SaveToFile(const FileName: string);
Memory : Pointer;
SizeBoundsSeek : Boolean;
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 .
!!!
Members
Member | Type | Visibility | Description |
---|---|---|---|
FMemory | Field | private | |
FPosition | Field | private | |
FSize | Field | private | |
FSizeBoundsSeek | Field | private | |
GetPosition | Method | protected | |
GetSize | Method | protected | return the size of the stream. |
Memory | Property | public | Pointer to the data kept in the memory stream. |
Read | Method | public | Reads Count bytes from the stream into buffer. |
SaveToFile | Method | public | Writes the contents of the stream to a file. |
SaveToStream | Method | public | Writes the contents of the memory stream to another stream. |
Seek | Method | public | Sets a new position in the stream. |
SetPointer | Method | protected | Sets the internal memory pointer and size of the memory block. |
SizeBoundsSeek | Property | public |
Inheritance
Class | Description |
---|---|
TCustomMemoryStream | Abstract stream that stores its data in memory. |
See also
Name | Description |
---|---|
PtrInt | Signed integer type with same size as Pointer. |
PtrInt | Signed integer type with same size as Pointer. |
TMemoryStream | Standard implementation of a stream that stores its data in memory |
TStream | Base class for streams. |