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

# TWriter

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

Object to write component data to an arbitrary format.

## Declaration

Source position: classesh.inc line 1546

`type TWriter = class(TFiler)`
`public`
`constructor Create();` |  | Creates a new Writer with a stream and bufsize.
`destructor Destroy; override;` |  | Destroys the writer instance.
`procedure FlushBuffer; override;` |  | Flush the buffer
`procedure DefineProperty(); override;` |  | Callback used when defining and streaming custom properties.
`procedure DefineBinaryProperty(); override;` |  | Callback used when defining and streaming custom properties.
`procedure Write(); virtual;` |  | Write raw data to stream
`procedure WriteBoolean();` |  | Write boolean value to the stream.
`procedure WriteCollection();` |  | Write a collection to the stream.
`procedure WriteComponent();` |  | Stream a component to the stream.
`procedure WriteChar();` |  | Write a character to the stream.
`procedure WriteWideChar();` |  | Write widechar to stream
`procedure WriteDescendent();` |  | Write descendent to stream
`procedure WriteFloat();` |  | Write a float to the stream.
`procedure WriteSingle();` |  | Write a single-type real to the stream.
`procedure WriteDate();` |  | Write a date to the stream.
`procedure WriteCurrency();` |  | Write a currency value to the stream
`procedure WriteIdent();` |  | Write an identifier to the stream.
`procedure WriteInteger();` |  | Write an integer to the stream.
`procedure WriteSet();` |  | Write a set value to the stream
`procedure WriteListBegin;` |  | Write a start-of-list marker to the stream.
`procedure WriteListEnd;` |  | Write an end-of-list marker to the stream.
`procedure WriteSignature;` |  | Write a signature to the stream
`procedure WriteRootComponent();` |  | Write a root component to the stream.
`procedure WriteString();` |  | Write a string to the stream.
`procedure WriteWideString();` |  | Write a widestring value to the stream
`procedure WriteUnicodeString();` |  | Write a Unicode string to the stream.
`procedure WriteVariant();` |  | Write a variant to the stream
`property RootAncestor: TComponent; [rw]` |  | Ancestor of root component.
`property OnFindAncestor: TFindAncestorEvent; [rw]` |  | Event occurring when an ancestor component must be found.
`property OnWriteMethodProperty: TWriteMethodPropertyEvent; [rw]` |  | Handler from writing method properties.
`property OnWriteStringProperty: TReadWriteStringPropertyEvent; [rw]` |  | Event handler for translating strings written to stream.
`property Driver: TAbstractObjectWriter; [r]` |  | Driver used when writing to the stream.
`property PropertyPath: string; [r]` |  | Path to the property that is currently being written
`end;`

## Inheritance

`TWriter` |  | Object to write component data to an arbitrary format.
`TFiler` |  | Class responsible for streaming of components.
`TObject` |  | Base class of all classes.

## Description

The TWriter class is a writer class that implements generic component streaming capabilities, independent of the format of the data in the stream. It uses a driver class TAbstractObjectWriter to do the actual reading of data. The interface of the TWriter class should be identical to the interface in Delphi.

Note that the TWriter design is such that it will write a single component to a stream. It will write all children of this component, but it is not designed to write multiple components in succession to one stream.

It should never be necessary to create an instance of this class directly. Instead, the TStream.WriteComponent call should be used.

## See also

TFiler |  | Class responsible for streaming of components.
TWriter |  | Object to write component data to an arbitrary format.
TAbstractObjectReader |  | Abstract driver class to read stored component data.