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

RRC2Soft rrc2soft at telefonica.net
Wed Jun 18 22:03:34 CEST 2003


> > >> 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?

Rodrigo "Rui" R. (1/2 RRC2Soft)




More information about the fpc-pascal mailing list