Indy 9
TIdReadMemoryStream
Hierarchy, Methods, See Also, Unit: IdGlobal
Implements read-only stream access to memory.
TIdReadMemoryStream = class(TCustomMemoryStream)
Unit
IdGlobal
Description
TIdReadMemoryStream is a TCustomMemoryStream descendant, and is used to provide fast, read-only, stream-based access to values in memory. TIdReadMemoryStream implements the SetPointer and Write methods from the abstract ancestor class.

TIdReadMemoryStream is used internally in the implementation of some Indy methods like TIdEncoder.Encode, TIdHash32.HashValue, TIdHash16.HashValue, and TIdHash128.HashValue.


TIdReadMemoryStream.SetPointer
TIdReadMemoryStream
Assigns the memory buffer associated with the memory stream.
procedure SetPointer(Ptr: Pointer; Size: Longint);
Parameters
Ptr: Pointer
Pointer to the memory buffer for the stream.
Size: Longint
Size of the buffer for the stream.
Description
SetPointer is a procedure that assigns the internal memory buffer associated with the memory stream. SetPointer is a public method in TIdReadMemoryStream, and calls the inherited method using Ptr and Size as arguments.

Ptr is as pointer to the internal buffer to be assigned to Memory. Size is the number of bytes allocated to the buffer in Ptr.

SetPointer sets the Position of the memory stream to byte 0 (zero) using Seek prior to exiting the method.

Note: SetPointer does not free the existing value of Memory, if any, when it replaces the memory buffer. Descendant classes that use SetPointer to replace an existing stream memory pool should free the memory pointed to by the Memory property before calling SetPointer to replace the memory buffer.


TIdReadMemoryStream.Write
TIdReadMemoryStream
Overrides the default write behavior for the read-only memory stream.
function Write(const Buffer; Count: Longint): Longint; override;
Parameters
const Buffer
Values to be written. Ignored.
Count: Longint
Number of bytes to be written. Ignored.
Return Value
LongInt - Numer of bytes written. Always returns 0 (zero).
Description
Write is a LongInt function that is reimplemented in TIdReadMemoryStream to override the default behavior for the custom memory stream. TIdReadMemoryStream is a read-only stream, and the return value for the Write method will always be 0 (zero).

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.