20th Chapter-Development Delphi Object Type Data management function (III.) (6)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.