[gtkada] configuration files
Stephen Leake
stephen_leake at acm.org
Wed May 29 02:17:08 CEST 2002
Preben Randhol <randhol at pvv.org> writes:
> Jacob Sparre Andersen <sparre at nbi.dk> wrote on 28/05/2002 (13:44) :
> > It looks reasonable execept for a few details:
> >
> > * I would like to have the option of reading the settings
> > from a prioritised list of configuration files, and not
> > just a single named file.
>
> Do you want the pacakge to search through the files over and over again
> to find the value you want?
Hmm, interesting point. I would assume that the search would just be
for a file, and the first file found would be used after that.
> > * It would be practical to include a function for reading
> > the configuration file(s) into a suitable data structure,
> > so the files only need to be read once during the
> > execution of a program.
>
> Why do we need to do it some complicated? This sounds like XML.
XML is a file format, not an in-memory format. Ah, I guess you mean
the object model used by XML parsers. Yes, it does start to sound like
that. We don't want to go too far in that direction.
I see no need to make the in-memory format visible to clients of the
config file package.
> First settings files change from version to version of the program.
> So the first thing we need to do is to
>
> 1) Find out that this is a config file for this program
> 2) Which version of the program
This can be handled by making one of the keys be "version". I don't
think we need to standardize this behavior.
Although I guess it could influence the search path. That can be
handled by having the application set the search path before looking
for the file.
> procedure Read_Settings
> (Version : Float)
> is
> -- ...
> begin
> if Version <= 1.0 then
> Read ("Directory.Help", Help_Directory);
> Read ("Directory.Graphics", Graphics_Directory);
> Read ("Entry.Max_Value", Max_Value);
> elsif Version > 1.0 and Version <= 2.0 then
> Read ("Directory.Help", Help_Directory);
> Read ("Directory.Graphics", Graphics_Directory);
> Read ("Directory.Data", Data_Directory);
> Read ("Entry.Max_Value", Max_Value);
> -- etc
> end if;
>
> end Read_Settings;
Yes, I have code like this in my Windex applications. But I don't
think it needs to be standardized in the package.
> The program will be writing and reading the settings files so the
> programmer knows the order in which the data comes. There is no need
> to add extra dynamic. If there is a mistake in the settings file a
> Program_Error should be raised I think.
Some other exception would be more appropriate. Perhaps
Config_Files.Configuration_Error?
--
-- Stephe
More information about the gtkada
mailing list