Differences
This shows you the differences between two versions of the page.
simple_configuration_file_reader_-_using_a_generic [2012/01/02 21:43] thomaslocke created |
simple_configuration_file_reader_-_using_a_generic [2012/04/15 07:03] (current) thomaslocke [src/config_file_parser.adb] |
||
---|---|---|---|
Line 11: | Line 11: | ||
git://github.com/ThomasLocke/Simple_Config.git | git://github.com/ThomasLocke/Simple_Config.git | ||
- | Git is available for all Linux distros. The commands to clone Simple_Config using Git and then compile it are: | + | Git is available for all Linux distros. The commands to clone //Simple_Config// and then compile it are: |
$ git clone git://github.com/ThomasLocke/Simple_Config.git | $ git clone git://github.com/ThomasLocke/Simple_Config.git | ||
Line 19: | Line 19: | ||
The executable can now be found in the //exe/// folder. | The executable can now be found in the //exe/// folder. | ||
- | If you don't feel like using Git, the full source code can be copied from below. I will of course do my best to make sure that the code on this page matches the code in the Git repository, but since this is a Wiki where anybody can make changes, I cannot guarantee the safety of running the code on this page. So use with caution. | + | If you don't feel like using Git, the full source code can be copied from below. I will of course do my best to make sure that the code on this page matches the code in the Git repository, but since this is a wiki where anybody can make changes, I cannot guarantee the safety of running the code on this page. So use with caution. |
===== exe/config_one.ini and exe/config_two.ini ===== | ===== exe/config_one.ini and exe/config_two.ini ===== | ||
Line 27: | Line 27: | ||
**config_one.ini** | **config_one.ini** | ||
<code> | <code> | ||
- | - This is a comment. | + | # This is a comment. |
- | -- This is also a comment. Both # and -- are valid for comments. | + | -- This is also a comment. |
+ | ; And a third comment. Lines starting with #, -- and ; are treated as comments. | ||
- | - This config file only changes the Foo_Boolean parameter. For the remaining | + | # This config file only changes the Foo_Boolean parameter. For the remaining |
- | - parameters, the default values are used. | + | # parameters, the default values are used. |
Foo_Boolean True | Foo_Boolean True | ||
</code> | </code> | ||
Line 39: | Line 40: | ||
**config_two.ini** | **config_two.ini** | ||
<code> | <code> | ||
- | - This is a comment. | + | # This is a comment. |
- | -- This is also a comment. Both # and -- are valid for comments. | + | -- This is also a comment. |
+ | ; And a third comment. Lines starting with #, -- and ; are treated as comments. | ||
- | - This config file only changes the Foo_Boolean parameter. For the remaining | + | # This config file only changes the Foo_Boolean parameter. For the remaining |
- | - parameters, the default values are used. | + | # parameters, the default values are used. |
Foo_Boolean True | Foo_Boolean True | ||
</code> | </code> | ||
Line 85: | Line 87: | ||
package Ide is | package Ide is | ||
- | for Compiler_Command ("ada") use "/usr/gnat/bin/gnatmake"; | + | for Compiler_Command ("ada") use "gnatmake"; |
end Ide; | end Ide; | ||
Line 101: | Line 103: | ||
end Compiler; | end Compiler; | ||
end Simple_Config; | end Simple_Config; | ||
- | </source> | + | </code> |
===== simple_config.adb ===== | ===== simple_config.adb ===== | ||
Line 185: | Line 187: | ||
New_Line; | New_Line; | ||
end Simple_Config; | end Simple_Config; | ||
- | </source> | + | </code> |
===== src/config_file_parser.ads ===== | ===== src/config_file_parser.ads ===== | ||
Line 496: | Line 498: | ||
if Line /= "" | if Line /= "" | ||
and then Line (1 .. 1) /= "#" | and then Line (1 .. 1) /= "#" | ||
+ | and then Line (1 .. 1) /= ";" | ||
and then Line (1 .. 2) /= "--" then | and then Line (1 .. 2) /= "--" then | ||
-- Note that if a valid key is found in the file, and it has no | -- Note that if a valid key is found in the file, and it has no |