Skip to content

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 1701

Type
  TWriter = class (TFiler)
  private
    FDriver : TAbstractObjectWriter;
    FDestroyDriver : Boolean;
    FRootAncestor : TComponent;
    FPropPath : string;
    FAncestors : TStringList;
    FAncestorPos : Integer;
    FCurrentPos : Integer;
    FOnFindAncestor : TFindAncestorEvent;
    FOnWriteMethodProperty : TWriteMethodPropertyEvent;
    FOnWriteStringProperty : TReadWriteStringPropertyEvent;
    procedure AddToAncestorList(Component: TComponent);
    procedure WriteComponentData(Instance: TComponent);
    procedure DetermineAncestor(Component: TComponent);
    procedure DoFindAncestor(Component: TComponent);
  protected
    procedure SetRoot(ARoot: TComponent);  Override;
    procedure WriteBinary(AWriteData: TStreamProc);
    procedure WriteProperty(Instance: TPersistent; PropInfo: Pointer);
    procedure WriteProperties(Instance: TPersistent);
    procedure WriteChildren(Component: TComponent);
    function CreateDriver(Stream: TStream; BufSize: Integer)
                          : TAbstractObjectWriter;  Virtual;
  public
    constructor Create(ADriver: TAbstractObjectWriter);
    constructor Create(Stream: TStream; BufSize: Integer);
    destructor Destroy;  Override;
    procedure FlushBuffer;  Override;
    procedure DefineProperty(const Name: string; ReadData: TReaderProc; 
                            AWriteData: TWriterProc; HasData: Boolean)
                            ;  Override;
    procedure DefineBinaryProperty(const Name: string; 
                                  ReadData: TStreamProc; 
                                  AWriteData: TStreamProc; HasData: Boolean)
                                  ;  Override;
    procedure Write(const Buffer; Count: LongInt);  Virtual;
    procedure WriteBoolean(Value: Boolean);
    procedure WriteCollection(Value: TCollection);
    procedure WriteComponent(Component: TComponent);
    procedure WriteChar(Value: Char);
    procedure WriteWideChar(Value: WideChar);
    procedure WriteDescendent(ARoot: TComponent; AAncestor: TComponent);
    procedure WriteFloat(const Value: Extended);
    procedure WriteSingle(const Value: Single);
    procedure WriteDate(const Value: TDateTime);
    procedure WriteCurrency(const Value: Currency);
    procedure WriteIdent(const Ident: string);
    procedure WriteInteger(Value: LongInt);  Overload;
    procedure WriteInteger(Value: Int64);  Overload;
    procedure WriteSet(Value: LongInt; SetType: Pointer);
    procedure WriteListBegin;
    procedure WriteListEnd;
    procedure WriteSignature;
    procedure WriteRootComponent(ARoot: TComponent);
    procedure WriteString(const Value: string);
    procedure WriteWideString(const Value: WideString);
    procedure WriteUnicodeString(const Value: UnicodeString);
    procedure WriteVariant(const VarValue: Variant);
    RootAncestor : TComponent;
    OnFindAncestor : TFindAncestorEvent;
    OnWriteMethodProperty : TWriteMethodPropertyEvent;
    OnWriteStringProperty : TReadWriteStringPropertyEvent;
    Driver : TAbstractObjectWriter;
    PropertyPath : string;
  end
  ;

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.

Members

Member Type Visibility Description
AddToAncestorList Method private
Create Method public Creates a new Writer with a stream and bufsize.
CreateDriver Method protected
DefineBinaryProperty Method public Callback used when defining and streaming custom properties.
DefineProperty Method public Callback used when defining and streaming custom properties.
Destroy Method public Destroys the writer instance.
DetermineAncestor Method private
DoFindAncestor Method private
Driver Property public Driver used when writing to the stream.
FAncestorPos Field private
FAncestors Field private
FCurrentPos Field private
FDestroyDriver Field private
FDriver Field private
FlushBuffer Method public Flush the buffer
FOnFindAncestor Field private
FOnWriteMethodProperty Field private
FOnWriteStringProperty Field private
FPropPath Field private
FRootAncestor Field private
OnFindAncestor Property public Event occurring when an ancestor component must be found.
OnWriteMethodProperty Property public Handler from writing method properties.
OnWriteStringProperty Property public Event handler for translating strings written to stream.
PropertyPath Property public Path to the property that is currently being written
RootAncestor Property public Ancestor of root component.
SetRoot Method protected Sets the root component
Write Method public Write raw data to stream
WriteBinary Method protected Writes binary data to the stream.
WriteBoolean Method public Write boolean value to the stream.
WriteChar Method public Write a character to the stream.
WriteChildren Method protected
WriteCollection Method public Write a collection to the stream.
WriteComponent Method public Stream a component to the stream.
WriteComponentData Method private
WriteCurrency Method public Write a currency value to the stream
WriteDate Method public Write a date to the stream.
WriteDescendent Method public Write descendent to stream
WriteFloat Method public Write a float to the stream.
WriteIdent Method public Write an identifier to the stream.
WriteInteger Method public Write an integer to the stream.
WriteListBegin Method public Write a start-of-list marker to the stream.
WriteListEnd Method public Write an end-of-list marker to the stream.
WriteProperties Method protected Writes the published properties to the stream.
WriteProperty Method protected Writes one property to the stream.
WriteRootComponent Method public Write a root component to the stream.
WriteSet Method public Write a set value to the stream
WriteSignature Method public Write a signature to the stream
WriteSingle Method public Write a single-type real to the stream.
WriteString Method public Write a string to the stream.
WriteUnicodeString Method public Write a Unicode string to the stream.
WriteVariant Method public Write a variant to the stream
WriteWideChar Method public Write widechar to stream
WriteWideString Method public Write a widestring value to the stream

Inheritance

Class Description
TWriter Object to write component data to an arbitrary format.

See also

Name Description
Integer A signed 16-bits integer
Integer A signed 16-bits integer
TAbstractObjectReader Abstract driver class to read stored component data.
TAbstractObjectWriter Abstract driver class for writing component data.
TAbstractObjectWriter Abstract driver class for writing component data.
TComponent Base class for all components that need owner-owned functionality.
TComponent Base class for all components that need owner-owned functionality.
TFiler Class responsible for streaming of components.
TFindAncestorEvent Event that occurs w
TFindAncestorEvent Event that occurs w
TReadWriteStringPropertyEvent Callback for the TReader.OnReadStringProperty event handler
TReadWriteStringPropertyEvent Callback for the TReader.OnReadStringProperty event handler
TStringList Standard implementation of the TStrings class.
TWriteMethodPropertyEvent Callback for the TWriter.OnWriteMethodProperty event.
TWriteMethodPropertyEvent Callback for the TWriter.OnWriteMethodProperty event.
TWriter Object to write component data to an arbitrary format.