[Lazarus] Why was XML format chosen for storing settings in Lazarus IDE?
Alexander Klenin
klenin at gmail.com
Fri Jun 18 13:21:44 CEST 2010
On Fri, Jun 18, 2010 at 22:07, Alexander Klenin <klenin at gmail.com> wrote:
> 4) reading/writing code is ugly and full of duplication -- but this is
> a problem of Lazaurs, not intrinsic to XML itself
[skip]
> Benefits of LFM vs. XML:
> 3) can be read/written directly to the object via RTTI, thus
> drastically simplifying read/write code
> (I estimate a few thousands lines of code might be eliminated from Lazarus).
>
To illustrate, here is a snipped of Lazarus code reading the compiler options:
{ Linking }
p:=Path+'Linking/';
GenerateDebugInfo :=
XMLConfigFile.GetValue(p+'Debugging/GenerateDebugInfo/Value', false);
UseLineInfoUnit :=
XMLConfigFile.GetValue(p+'Debugging/UseLineInfoUnit/Value', true);
GenerateDwarf :=
XMLConfigFile.GetValue(p+'Debugging/GenerateDwarf/Value', false);
UseHeaptrc := XMLConfigFile.GetValue(p+'Debugging/UseHeaptrc/Value', false);
UseValgrind := XMLConfigFile.GetValue(p+'Debugging/UseValgrind/Value', false);
GenGProfCode :=
XMLConfigFile.GetValue(p+'Debugging/GenGProfCode/Value', false);
StripSymbols :=
XMLConfigFile.GetValue(p+'Debugging/StripSymbols/Value', false);
and here is the corresponding code to write them:
{ Linking }
p:=Path+'Linking/';
XMLConfigFile.SetDeleteValue(p+'Debugging/GenerateDebugInfo/Value',
GenerateDebugInfo,false);
XMLConfigFile.SetDeleteValue(p+'Debugging/UseLineInfoUnit/Value',
UseLineInfoUnit,true);
XMLConfigFile.SetDeleteValue(p+'Debugging/GenerateDwarf/Value',
GenerateDwarf, false);
XMLConfigFile.SetDeleteValue(p+'Debugging/UseHeaptrc/Value',
UseHeaptrc,false);
XMLConfigFile.SetDeleteValue(p+'Debugging/UseValgrind/Value',
UseValgrind,false);
XMLConfigFile.SetDeleteValue(p+'Debugging/GenGProfCode/Value',
GenGProfCode,false);
XMLConfigFile.SetDeleteValue(p+'Debugging/StripSymbols/Value',
StripSymbols,false);
Clearly, those are not not the best examples of applying DRY principle ;-)
--
Alexander S. Klenin
More information about the Lazarus
mailing list