[Overview][Constants][Types][Classes][Procedures and functions][Variables] | Reference for unit 'Classes' (#fcl)

# TStream

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

Base class for streams.

## Declaration

`type TStream = class(TObject)`
`protected`
`procedure SetSize();` |  | Sets the size of the stream
`public`
`function Read(); virtual; abstract;` |  | Reads data from the stream to a buffer and returns the number of bytes read.
`function Write(); virtual; abstract;` |  | Writes data from the stream to the buffer and returns the number of bytes written.
`function Seek();` |  | Sets the current position in the stream
`procedure ReadBuffer();` |  | Reads data from the stream to a buffer
`procedure WriteBuffer();` |  | Writes data from the stream to the buffer
`function CopyFrom();` |  | Copy data from one stream to another
`function ReadComponent();` |  | Reads component data from a stream
`function ReadComponentRes();` |  | Reads component data and resource header from a stream
`procedure WriteComponent();` |  | Write component data to the stream
`procedure WriteComponentRes();` |  | Write resource header and component data to a stream
`procedure WriteDescendent();` |  | Write component data to a stream, relative to an ancestor
`procedure WriteDescendentRes();` |  | Write resource header and component data to a stream, relative to an ancestor
`procedure WriteResourceHeader();` |  | Write resource header to the stream
`procedure FixupResourceHeader();` |  | Not implemented in FPC
`procedure ReadResHeader;` |  | Read a resource header from the stream.
`function ReadByte;` |  | Read a byte from the stream and return its value.
`function ReadWord;` |  | Read a word from the stream and return its value.
`function ReadDWord;` |  | Read a DWord from the stream and return its value.
`function ReadAnsiString;` |  | Read an ansistring from the stream and return its value.
`procedure WriteByte();` |  | Write a byte to the stream.
`procedure WriteWord();` |  | Write a word to the stream.
`procedure WriteDWord();` |  | Write a DWord to the stream.
`procedure WriteAnsiString();` |  | Write an ansistring to the stream.
`property Position: Int64; [rw]` |  | The current position in the stream.
`property Size: Int64; [rw]` |  | The current size of the stream.
`property Position: LongInt; [rw]` |  | The current position in the stream.
`property Size: LongInt; [rw]` |  | The current size of the stream.
`end;`

## Inheritance

`TStream` |  | Base class for streams.
`TObject`

## Description

TStream is the base class for all streaming classes. It defines abstract 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.

Descendent classes such as TMemoryStream or TFileStream then implement these abstract methods to write streams to memory or file.

## See also

TMemoryStream |  | Standard implementation of a stream that stores its data in memory
TFileStream |  | Stream that stores its data in a named file on disk.
TStringStream |  | Stream that stores its data in a string.