[fpc-pascal] OOP and XML usage
Jorge Aldo G. de F. Junior
jagfj80 at gmail.com
Thu Jan 28 19:43:14 CET 2010
each tag generates a new instance of the class
you can add a property (that all objects have) called InstanceName
<option instancename="blabla">something</option>
using the instance name the class factory can differentiate from other
instances (factory.instance['blabla'] retrieves the correct instance,
or, factory.dotnotation['roottag.nexttag.blabla'] retrieves by dotted
notation..
or
if you dont specify an instance name the factory will generate one randonly...
and actually i prefer to setup properties of objects using xml
properties instead of xml text
<tcpserver ip="192.168.1.1" port="80"/> instead of
<tcpserver><ip>192.168.1.1</ip><port>80</port></tcpserver>
2010/1/28 Graeme Geldenhuys <graemeg.lists at gmail.com>:
> On 28 January 2010 16:10, Jorge Aldo G. de F. Junior <jagfj80 at gmail.com> wrote:
>>
>> Whenever the xml loader finds a <mytag something="test"/> it will
>> create an instance of TMyClass and set the published properties
>> accordingly (Using RTTI)...
>
> I like that idea, but how flexible is? By that I mean, I have nested
> tags (using the same element name) that I need to load. Something like
> a dependency tree. My custom object model can handle this without
> problems, but I'm still curious about your solution.
>
> Example XML, and there isn't a limit to the nesting of options.
>
> <install>
> <option>Option 1</option>
> <option>Base database support
> <option>Firebird drivers
> <option>Windows</option>
> <option>Linux</option>
> </option>
> <option>MySQL drivers</option>
> </option>
> </install>
>
>
> --
> Regards,
> - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list