Writing of ⑶ Parts
The methods associated with writing parts in the Twriter object are Writesignature, Writeprefix, Writecomponent, Writedescendant, and Writerootcomponent.
The Writesignature method is used to write the Filer object label to the stream.
Procedure Twriter.writesignature;
Begin
Write (Filersignature, SizeOf (filersignature));
End
Filerstgnature is a string constant whose value is "TPF0", which represents the object label.
The Writeprefix method is used to write the ffinherited and Ffchildpos flags that represent the inheritance characteristics of the part and the creation of the order value feature before the part is written.
Procedure Twriter.writeprefix (flags:tfilerflags; Achildpos:integer);
Var
Prefix:byte;
Begin
If Flags <> [] Then
Begin
Prefix: = $F 0 or Byte (Flags);
Write (Prefix, SizeOf (Prefix));
If Ffchildpos in Flags then Writeinteger (Achildpos);
End
End
If the ffchildpos is placed, the creation value of the part in owner is saved. For more information, see the Readprefix method for Treader.
The Writecomponent method writes a part to the stream.
Procedure Twriter.writecomponent (component:tcomponent);
function FindAncestor (const name:string): tcomponent;
Begin
...
End
Begin
Include (Component.fcomponentstate, cswriting);
If assigned (fancestorlist) then
Ancestor: = FindAncestor (Component.name);
Component.writestate (Self);
Exclude (Component.fcomponentstate, cswriting);
End
method to write the properties of the part using the component Writstate method. Before writing, Component.fcomponentstate is reset to cswriting after the write is finished.
Writedescendant writes the part root according to the ancestor Aancestor.
Procedure Twriter.writedescendent (root:tcomponent; Aancestor:tcomponent);
Begin
Frootancestor: = Aancestor;
Fancestor: = Aancestor;
Froot: = Root;
Writesignature;
Writecomponent (Root);
End
method to write the Filer object label first by calling the Writesignature method. Then call Writecomponent to write the part root to the stream.
The Writerootcomponent method calls the Writedescendant method to write the part, but passes the ancestor parameter of the latter to the nil value.
Procedure Twriter.writerootcomponent (root:tcomponent);
Begin
Writedescendent (Root, nil);
End