TStream = class(TObject)
class PASCALIMPLEMENTATION TStream : public System::TObject
TStream is the base class type for stream objects that can read from or write to various kinds of storage media, such as disk files, dynamic memory, and so on.
Use specialized stream objects to read from, write to, or copy information stored in a particular medium. Each descendant of TStream implements methods for transferring information to and from a particular storage medium, such as a disk file, dynamic memory, and so on. In addition to methods for reading, writing, and copying bytes to and from the stream, stream objects permit applications to seek to an arbitrary position in the stream. Properties of TStream provide information about the stream, such as its size and the current position in the stream.
TStream also introduces methods that work in conjunction with components and filers for loading and saving components in simple and inherited forms. These methods are called automatically by global routines that initiate component streaming. They can also be called directly to initiate the streaming process. Note, however, that component streaming always involves two additional objects:
- A component object that is passed as a parameter to the stream's methods.
- A filer object that is automatically created by the stream, and associated with the stream.
TStream is an abstract or, in C++ terminology, pure virtual class. It should not be instantiated; it relies on abstract or pure virtual methods that must be overridden in descendent classes. Descendent stream objects, such as memory and file streams used for component streaming, are created automatically by the global functions ReadComponentRes and WriteComponentRes. For streaming other kinds of information, choose a descendent class according to the specific data and storage needs. These include:
- TFileStream (for working with files)
- TStringStream (for manipulating in-memory strings)
- TMemoryStream (for working with a memory buffer)
- TBlobStream (for working with BLOB fields)
- TWinSocketStream (for reading and writing over a socket connection)
- TOleStream (for using a COM interface to read and write)