IROStream

Overview

The IROStream interface wraps access to a Delphi TStream instance to provide a reference-counted, interface-based reference that can be freed automatically as it goes out of scope. IROStream exposes all the basic methods and properties of TStream, and also exposes the underlying wrapped object via the Stream property. Use one of the overloads of the global NewROStream function to instantiate a new IROStream instance.

Location

Implemented in

 

BeginUpdate

Sets the changing mode. Each BeginUpdate must have an associated EndUpdate.

procedure BeginUpdate

EndUpdate

Cancels the changing mode.

procedure EndUpdate

GetStreamObj

Gets access to the TStream object directly.

function GetStreamObj: TStream

InUpdateMode

Returns true if the stream is in changing mode.

function InUpdateMode: Boolean

Position

Current position

property Position: Int64 read write

Read

Reads up to Count bytes of data from the file into Buffer.

function Read(var Buffer: ; Count: Longint): Longint

Parameters:

  • Buffer: buffer
  • Count: count

ReadBuffer

Reads Count bytes from the stream into the Buffer in cases where the number of bytes is known and fixed, for example when reading in structures. ReadBuffer is used internally for loading from a stream and copying from a stream.

procedure ReadBuffer(var Buffer: ; Count: Longint)

Parameters:

  • Buffer: buffer
  • Count: count

ReadComponent

Reads data values from the stream and assigns them to the Instance’s properties.

function ReadComponent(Instance: TComponent): TComponent

Parameters:

  • Instance: given instance

Seek (Int64, TSeekOrigin): Int64  overload

Moves the current position within the memory stream by the indicated offset.

Seek returns the new value of the Position property.
Note: Seek does no error checking on the value provided for Offset. Do not call seek with an offset that would move the current position to less than 0 (before the start of Memory) or greater than Size (beyond the end of the memory buffer).

function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64

Parameters:

  • Offset: If Offset is a negative number, the seek goes backward from the specified origin.
  • Origin: Direction: ** soBeginning - Offset is from the beginning of the Memory. Seek moves to the position Offset. Offset must be >= 0. ** soCurrent - Offset is from the current position. Seek moves to Position + Offset. ** soEnd - Offset is from the end of Memory. Offset must be <= 0 to indicate a number of bytes before the end of the memory buffer.

Seek (Longint, Word): Longint  overload

Moves the current position within the memory stream by the indicated offset.

Seek returns the new value of the Position property.
Note: Seek does no error checking on the value provided for Offset. Do not call seek with an offset that would move the current position to less than 0 (before the start of Memory) or greater than Size (beyond the end of the memory buffer).

function Seek(Offset: Longint; Origin: Word): Longint

Parameters:

  • Offset: If Offset is a negative number, the seek goes backward from the specified origin.
  • Origin: Direction: ** soFromBeginning - Offset is from the beginning of the Memory. Seek moves to the position Offset. Offset must be >= 0. ** soFromCurrent - Offset is from the current position. Seek moves to Position + Offset. ** soFromEnd - Offset is from the end of Memory. Offset must be <= 0 to indicate a number of bytes before the end of the memory buffer.

Size

property Size: Int64 read write

Stream

Exposes the underlying TStream instance wrapped by this IROStream interface.

property Stream: TStream read write

Write

Writes up to Count bytes from the Buffer and returns the number of bytes actually written.

function Write(const Buffer: ; Count: Longint): Longint

Parameters:

  • Buffer: Buffer
  • Count: Count

WriteBuffer

Writes Count bytes from the Buffer onto the stream and advances the current position of the stream by Count bytes.

procedure WriteBuffer(const Buffer: ; Count: Longint)

Parameters:

  • Buffer: Buffer
  • Count: Count

WriteComponent

Writes the Instance and its properties to a stream.

procedure WriteComponent(Instance: TComponent)

Parameters:

  • Instance: given instance

 

Position

Current position

property Position: Int64 read write

Size

property Size: Int64 read write

Stream

Exposes the underlying TStream instance wrapped by this IROStream interface.

property Stream: TStream read write

 

BeginUpdate

Sets the changing mode. Each BeginUpdate must have an associated EndUpdate.

procedure BeginUpdate

EndUpdate

Cancels the changing mode.

procedure EndUpdate

GetStreamObj

Gets access to the TStream object directly.

function GetStreamObj: TStream

InUpdateMode

Returns true if the stream is in changing mode.

function InUpdateMode: Boolean

Read

Reads up to Count bytes of data from the file into Buffer.

function Read(var Buffer: ; Count: Longint): Longint

Parameters:

  • Buffer: buffer
  • Count: count

ReadBuffer

Reads Count bytes from the stream into the Buffer in cases where the number of bytes is known and fixed, for example when reading in structures. ReadBuffer is used internally for loading from a stream and copying from a stream.

procedure ReadBuffer(var Buffer: ; Count: Longint)

Parameters:

  • Buffer: buffer
  • Count: count

ReadComponent

Reads data values from the stream and assigns them to the Instance’s properties.

function ReadComponent(Instance: TComponent): TComponent

Parameters:

  • Instance: given instance

Seek (Int64, TSeekOrigin): Int64  overload

Moves the current position within the memory stream by the indicated offset.

Seek returns the new value of the Position property.
Note: Seek does no error checking on the value provided for Offset. Do not call seek with an offset that would move the current position to less than 0 (before the start of Memory) or greater than Size (beyond the end of the memory buffer).

function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64

Parameters:

  • Offset: If Offset is a negative number, the seek goes backward from the specified origin.
  • Origin: Direction: ** soBeginning - Offset is from the beginning of the Memory. Seek moves to the position Offset. Offset must be >= 0. ** soCurrent - Offset is from the current position. Seek moves to Position + Offset. ** soEnd - Offset is from the end of Memory. Offset must be <= 0 to indicate a number of bytes before the end of the memory buffer.

Seek (Longint, Word): Longint  overload

Moves the current position within the memory stream by the indicated offset.

Seek returns the new value of the Position property.
Note: Seek does no error checking on the value provided for Offset. Do not call seek with an offset that would move the current position to less than 0 (before the start of Memory) or greater than Size (beyond the end of the memory buffer).

function Seek(Offset: Longint; Origin: Word): Longint

Parameters:

  • Offset: If Offset is a negative number, the seek goes backward from the specified origin.
  • Origin: Direction: ** soFromBeginning - Offset is from the beginning of the Memory. Seek moves to the position Offset. Offset must be >= 0. ** soFromCurrent - Offset is from the current position. Seek moves to Position + Offset. ** soFromEnd - Offset is from the end of Memory. Offset must be <= 0 to indicate a number of bytes before the end of the memory buffer.

Write

Writes up to Count bytes from the Buffer and returns the number of bytes actually written.

function Write(const Buffer: ; Count: Longint): Longint

Parameters:

  • Buffer: Buffer
  • Count: Count

WriteBuffer

Writes Count bytes from the Buffer onto the stream and advances the current position of the stream by Count bytes.

procedure WriteBuffer(const Buffer: ; Count: Longint)

Parameters:

  • Buffer: Buffer
  • Count: Count

WriteComponent

Writes the Instance and its properties to a stream.

procedure WriteComponent(Instance: TComponent)

Parameters:

  • Instance: given instance