[fpc-pascal](Auto) XML Record Loader & RTTI Info

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Wed Jun 18 23:24:26 CEST 2003


On Wed, 18 Jun 2003, RRC2Soft wrote:

> > > >> I want to know if there's a tool that creates the OpenXML code
> > > >> needed for loading and saving an entire record from/to XML
> > > >> automatically.
> > > >
> > > >What would the purpose of this be ?
> > >
> > > Imagine that you have an structure in memory and you want to save
> > > it from disk and to load it from disk, but in XML format.
> > > (bla, bla, bla)
> >
> > If there was record RTTI, I think it could be done runtime?
>
> Hmmm maybe. In that case a record can be processed like a tree
> structure...
>
> TLayer = Record
>             L1,L2:Integer;
> TZone = Record
>            ID:Integer;
>            Tile:Array[1..3] of TLayer;
>         End;
>
> =>
>
> proc CreateXML(Type,OptInfo)
> begin
>     for every field in the record
>     begin
>        if Type = Simple-Type
>           Store in XML File
>        if Type = Array-Type
>           For i=StartArray to EndArray
>               CreateXML(Array-Type,i)
>        if Type = Record-Type
>           CreateXML(record-Type)
>     end
> end
>
> =>
>
> <TZONE>
>    <ID> Value </ID>
>    <TILE>
>       <TLAYER Pos='1'>
>          <L1> Value </L1>
>          <L2> Value </L2>
>       </TLAYER>
>       <TLAYER Pos='2'>
>          <L1> Value </L1>
>          <L2> Value </L2>
>       </TLAYER>
>       <TLAYER Pos='3'>
>          <L1> Value </L1>
>          <L2> Value </L2>
>       </TLAYER>
>    </TILE>
> </TZONE>
>
> ...sort of.
>
> How is RTTI information accesible from FreePascal/Delphi?

See the typinfo unit. It's used for instance in the classes.pas unit.

Michael.





More information about the fpc-pascal mailing list