TROStream
Overview
The TROStream class wraps the access to a Delphi TStream class. TROStream has all the basic methods and properties of TStream, but also exposes the underlying wrapped object via the Stream property.
Location
- Unit: uROStream.pas
- Ancestry: TInterfacedObject | TROStream
constructor Create overload
Creates a new instance.
constructor Create
constructor Create (TStream, Boolean) overload virtual
Creates an instance and determines whether it has its own stream; otherwise it will be referenced to aStream.
constructor Create(Source: TStream; OwnsStream: Boolean)
Parameters:
- Source:
- OwnsStream:
BeginUpdate protected
Sets the changing mode. Each BeginUpdate must have an associated EndUpdate.
procedure BeginUpdate
EndUpdate protected
Cancels the changing mode and calls the OnChange event.
procedure EndUpdate
GetPosition protected
Obtains the current position of the stream, i.e. the number of bytes from the beginning of the streamed data.
function GetPosition: Int64
GetStreamObj protected
Gets access to the TStream object directly.
function GetStreamObj: TStream
InUpdateMode protected
Returns true if the stream is in changing mode.
function InUpdateMode: Boolean
OnChange
Fires whenever a stream is changed.
property OnChange: TNotifyEvent read write
Read protected
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 protected
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 protected
Reads data values from the stream and assigns them to the Instance’s properties.
function ReadComponent(Instance: TComponent): TComponent
Parameters:
- Instance: given instance
Seek (Longint, Word): Longint protected 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.
Seek (Int64, TSeekOrigin): Int64 protected 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.
Write protected
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 protected
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 protected
Writes the Instance and its properties to a stream.
procedure WriteComponent(Instance: TComponent)
Parameters:
- Instance: given instance
constructor Create overload
Creates a new instance.
constructor Create
constructor Create (TStream, Boolean) overload virtual
Creates an instance and determines whether it has its own stream; otherwise it will be referenced to aStream.
constructor Create(Source: TStream; OwnsStream: Boolean)
Parameters:
- Source:
- OwnsStream:
BeginUpdate protected
Sets the changing mode. Each BeginUpdate must have an associated EndUpdate.
procedure BeginUpdate
EndUpdate protected
Cancels the changing mode and calls the OnChange event.
procedure EndUpdate
GetPosition protected
Obtains the current position of the stream, i.e. the number of bytes from the beginning of the streamed data.
function GetPosition: Int64
GetStreamObj protected
Gets access to the TStream object directly.
function GetStreamObj: TStream
InUpdateMode protected
Returns true if the stream is in changing mode.
function InUpdateMode: Boolean
Read protected
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 protected
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 protected
Reads data values from the stream and assigns them to the Instance’s properties.
function ReadComponent(Instance: TComponent): TComponent
Parameters:
- Instance: given instance
Seek (Longint, Word): Longint protected 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.
Seek (Int64, TSeekOrigin): Int64 protected 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.
Write protected
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 protected
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 protected
Writes the Instance and its properties to a stream.
procedure WriteComponent(Instance: TComponent)
Parameters:
- Instance: given instance
OnChange
Fires whenever a stream is changed.
property OnChange: TNotifyEvent read write