TStream

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Base class for streams.

Declaration

Source position: classesh.inc line 937

Type
  TStream = class (TObject)
  protected
    procedure InvalidSeek;  Virtual;
    procedure Discard(const Count: Int64);
    procedure DiscardLarge(Count: Int64; const MaxBufferSize: LongInt);
    procedure FakeSeekForward(Offset: Int64; const Origin: TSeekOrigin; 
                             const Pos: Int64);
    function GetPosition : Int64;  Virtual;
    procedure SetPosition(const Pos: Int64);  Virtual;
    function GetSize : Int64;  Virtual;
    procedure SetSize64(const NewSize: Int64);  Virtual;
    procedure SetSize(NewSize: LongInt);  Virtual;  Overload;
    procedure SetSize(const NewSize: Int64);  Virtual;  Overload;
    procedure ReadNotImplemented;
    procedure WriteNotImplemented;
    function ReadMaxSizeData(var Buffer; aSize: NativeInt; 
                            aCount: NativeInt) : NativeInt;
    procedure ReadExactSizeData(var Buffer; aSize: NativeInt; 
                               aCount: NativeInt);
    function WriteMaxSizeData(const Buffer; aSize: NativeInt; 
                             aCount: NativeInt) : NativeInt;
    procedure WriteExactSizeData(const Buffer; aSize: NativeInt; 
                                aCount: NativeInt);
  public
    function Read(var Buffer; Count: LongInt) : LongInt;  Virtual;  Overload;
    function Read(var Buffer: TBytes; Count: LongInt) : LongInt;  Overload;
    function Read(Buffer: TBytes; aOffset: LongInt; Count: LongInt)
                  : LongInt;  Overload;
    function Write(const Buffer: TBytes; Offset: LongInt; Count: LongInt)
                   : LongInt;  Overload;
    function Write(const Buffer: TBytes; Count: LongInt) : LongInt
                  ;  Overload;
    function Write(const Buffer; Count: LongInt) : LongInt;  Virtual
                  ;  Overload;
    function Seek(Offset: LongInt; Origin: Word) : LongInt;  Virtual
                 ;  Overload;
    function Seek(const Offset: Int64; Origin: TSeekOrigin) : Int64
                 ;  Virtual;  Overload;
    function ReadData(Buffer: Pointer; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(Buffer: TBytes; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Boolean) : NativeInt;  Overload;
    function ReadData(var Buffer: Boolean; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: AnsiChar) : NativeInt;  Overload;
    function ReadData(var Buffer: AnsiChar; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: WideChar) : NativeInt;  Overload;
    function ReadData(var Buffer: WideChar; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Int8) : NativeInt;  Overload;
    function ReadData(var Buffer: Int8; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: UInt8) : NativeInt;  Overload;
    function ReadData(var Buffer: UInt8; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Int16) : NativeInt;  Overload;
    function ReadData(var Buffer: Int16; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: UInt16) : NativeInt;  Overload;
    function ReadData(var Buffer: UInt16; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Int32) : NativeInt;  Overload;
    function ReadData(var Buffer: Int32; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: UInt32) : NativeInt;  Overload;
    function ReadData(var Buffer: UInt32; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Int64) : NativeInt;  Overload;
    function ReadData(var Buffer: Int64; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: UInt64) : NativeInt;  Overload;
    function ReadData(var Buffer: UInt64; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Single) : NativeInt;  Overload;
    function ReadData(var Buffer: Single; Count: NativeInt) : NativeInt
                     ;  Overload;
    function ReadData(var Buffer: Double) : NativeInt;  Overload;
    function ReadData(var Buffer: Double; Count: NativeInt) : NativeInt
                     ;  Overload;
    procedure ReadBuffer(var Buffer; Count: LongInt);
    procedure ReadBuffer(var Buffer: TBytes; Count: NativeInt);  Overload;
    procedure ReadBuffer(var Buffer: TBytes; Offset: NativeInt; 
                        Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: Boolean);  Overload;
    procedure ReadBufferData(var Buffer: Boolean; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: AnsiChar);  Overload;
    procedure ReadBufferData(var Buffer: AnsiChar; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: WideChar);  Overload;
    procedure ReadBufferData(var Buffer: WideChar; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: Int8);  Overload;
    procedure ReadBufferData(var Buffer: Int8; Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: UInt8);  Overload;
    procedure ReadBufferData(var Buffer: UInt8; Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: Int16);  Overload;
    procedure ReadBufferData(var Buffer: Int16; Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: UInt16);  Overload;
    procedure ReadBufferData(var Buffer: UInt16; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: Int32);  Overload;
    procedure ReadBufferData(var Buffer: Int32; Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: UInt32);  Overload;
    procedure ReadBufferData(var Buffer: UInt32; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: Int64);  Overload;
    procedure ReadBufferData(var Buffer: Int64; Count: NativeInt);  Overload;
    procedure ReadBufferData(var Buffer: UInt64);  Overload;
    procedure ReadBufferData(var Buffer: UInt64; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: Single);  Overload;
    procedure ReadBufferData(var Buffer: Single; Count: NativeInt)
                            ;  Overload;
    procedure ReadBufferData(var Buffer: Double);  Overload;
    procedure ReadBufferData(var Buffer: Double; Count: NativeInt)
                            ;  Overload;
    procedure WriteBuffer(const Buffer; Count: LongInt);
    procedure WriteBuffer(const Buffer: TBytes; Count: NativeInt);  Overload;
    procedure WriteBuffer(const Buffer: TBytes; Offset: NativeInt; 
                         Count: NativeInt);  Overload;
    function WriteData(const Buffer: TBytes; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Pointer; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Boolean) : NativeInt;  Overload;
    function WriteData(const Buffer: Boolean; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: AnsiChar) : NativeInt;  Overload;
    function WriteData(const Buffer: AnsiChar; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: WideChar) : NativeInt;  Overload;
    function WriteData(const Buffer: WideChar; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Int8) : NativeInt;  Overload;
    function WriteData(const Buffer: Int8; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: UInt8) : NativeInt;  Overload;
    function WriteData(const Buffer: UInt8; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Int16) : NativeInt;  Overload;
    function WriteData(const Buffer: Int16; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: UInt16) : NativeInt;  Overload;
    function WriteData(const Buffer: UInt16; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Int32) : NativeInt;  Overload;
    function WriteData(const Buffer: Int32; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: UInt32) : NativeInt;  Overload;
    function WriteData(const Buffer: UInt32; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Int64) : NativeInt;  Overload;
    function WriteData(const Buffer: Int64; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: UInt64) : NativeInt;  Overload;
    function WriteData(const Buffer: UInt64; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Single) : NativeInt;  Overload;
    function WriteData(const Buffer: Single; Count: NativeInt) : NativeInt
                      ;  Overload;
    function WriteData(const Buffer: Double) : NativeInt;  Overload;
    function WriteData(const Buffer: Double; Count: NativeInt) : NativeInt
                      ;  Overload;
    procedure WriteBufferData(Buffer: Int32);  Overload;
    procedure WriteBufferData(Buffer: Int32; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Boolean);  Overload;
    procedure WriteBufferData(Buffer: Boolean; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: AnsiChar);  Overload;
    procedure WriteBufferData(Buffer: AnsiChar; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: WideChar);  Overload;
    procedure WriteBufferData(Buffer: WideChar; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Int8);  Overload;
    procedure WriteBufferData(Buffer: Int8; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: UInt8);  Overload;
    procedure WriteBufferData(Buffer: UInt8; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Int16);  Overload;
    procedure WriteBufferData(Buffer: Int16; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: UInt16);  Overload;
    procedure WriteBufferData(Buffer: UInt16; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: UInt32);  Overload;
    procedure WriteBufferData(Buffer: UInt32; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Int64);  Overload;
    procedure WriteBufferData(Buffer: Int64; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: UInt64);  Overload;
    procedure WriteBufferData(Buffer: UInt64; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Single);  Overload;
    procedure WriteBufferData(Buffer: Single; Count: NativeInt);  Overload;
    procedure WriteBufferData(Buffer: Double);  Overload;
    procedure WriteBufferData(Buffer: Double; Count: NativeInt);  Overload;
    function CopyFrom(Source: TStream; Count: Int64) : Int64;
    function ReadComponent(Instance: TComponent) : TComponent;
    function ReadComponentRes(Instance: TComponent) : TComponent;
    procedure WriteComponent(Instance: TComponent);
    procedure WriteComponentRes(const ResName: string; Instance: TComponent);
    procedure WriteDescendent(Instance: TComponent; Ancestor: TComponent);
    procedure WriteDescendentRes(const ResName: string; 
                                Instance: TComponent; Ancestor: TComponent);
    procedure WriteResourceHeader(const ResName: string; 
                                 var FixupInfo: LongInt);
    procedure FixupResourceHeader(FixupInfo: LongInt);
    procedure ReadResHeader;
    function ReadByte : Byte;
    function ReadWord : Word;
    function ReadDWord : Cardinal;
    function ReadQWord : QWord;
    function ReadAnsiString : string;
    procedure WriteByte(b: Byte);
    procedure WriteWord(w: Word);
    procedure WriteDWord(d: Cardinal);
    procedure WriteQWord(q: QWord);
    procedure WriteAnsiString(const S: string);  Virtual;
    Position : Int64;
    Size : Int64;
  end
  ;

Description

TStream is the base class for all streaming classes. It defines methods for reading , writing from and to streams, as well as functions to determine the size of the stream as well as the current position of the stream.

Descendant classes such as TMemoryStream or TFileStream then override these methods to write streams to memory or file.

Members

Member Type Visibility Description
CopyFrom Method public Copy data from one stream to another
Discard Method protected
DiscardLarge Method protected
FakeSeekForward Method protected
FixupResourceHeader Method public Not implemented in FPC
GetPosition Method protected
GetSize Method protected
InvalidSeek Method protected
Position Property public The current position in the stream.
Read Method public Reads data from the stream to a buffer and returns the number of bytes read.
ReadAnsiString Method public Read an ansistring from the stream and return its value.
ReadBuffer Method public Reads data from the stream to a buffer
ReadBufferData Method public
ReadByte Method public Read a byte from the stream and return its value.
ReadComponent Method public Reads component data from a stream
ReadComponentRes Method public Reads component data and resource header from a stream
ReadData Method public
ReadDWord Method public Read a DWord from the stream and return its value.
ReadExactSizeData Method protected
ReadMaxSizeData Method protected
ReadNotImplemented Method protected
ReadQWord Method public Read a QWord value from the stream and return its value
ReadResHeader Method public Read a resource header from the stream.
ReadWord Method public Read a word from the stream and return its value.
Seek Method public Sets the current position in the stream
SetPosition Method protected
SetSize Method protected Sets the size of the stream
SetSize64 Method protected
Size Property public The current size of the stream.
Write Method public Writes data from a buffer to the stream and returns the number of bytes written.
WriteAnsiString Method public Write an ansistring to the stream.
WriteBuffer Method public Writes data from a buffer to the stream
WriteBufferData Method public
WriteByte Method public Write a byte to the stream.
WriteComponent Method public Write component data to the stream
WriteComponentRes Method public Write resource header and component data to a stream
WriteData Method public
WriteDescendent Method public Write descendent of a component
WriteDescendentRes Method public Write descendent of a component as resource
WriteDWord Method public Write a DWord to the stream.
WriteExactSizeData Method protected
WriteMaxSizeData Method protected
WriteNotImplemented Method protected
WriteQWord Method public Write a QWord value to the stream
WriteResourceHeader Method public Write resource header to the stream
WriteWord Method public Write a word to the stream.

Inheritance

Class Description
TStream Base class for streams.

See also

Name Description
Int64 64-bit, signed integer
Int64 64-bit, signed integer
TFileStream Stream that stores its data in a named file on disk.
TMemoryStream Standard implementation of a stream that stores its data in memory
TStringStream Stream that stores its data in a string.