Module for loading Lua-based configuration files.
The following configuration file myapp.conf
is given as an example for
a program myapp
:
-- myapp.conf
myapp = {
database = "observ.sqlite",
node = "dummy-node",
verbose = true
}
In Fortran, open the configuration file and read the settings with
subroutine dm_config_get()
:
character(len=:), allocatable :: database, node
integer :: rc
logical :: verbose
type(config_type) :: config
rc = dm_config_open(config, 'myapp.conf', 'myapp')
if (dm_is_ok(rc)) then
call dm_config_get(config, 'database', database)
call dm_config_get(config, 'node', node)
call dm_config_get(config, 'verbose', verbose)
end if
call dm_config_close(config)
Generic interface to return configuration value by name.
Returns configuration values as 4-byte integer array in values
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
integer(kind=i4), | intent(out), | allocatable | :: | values(:) |
Setting values. |
|
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration values as 8-byte integer array in values
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
integer(kind=i8), | intent(out), | allocatable | :: | values(:) |
Setting values. |
|
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration values as string array in values
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
character(len=*), | intent(inout), | allocatable | :: | values(:) |
Setting values. |
|
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as 4-byte integer in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
integer(kind=i4), | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as 8-byte integer in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
integer(kind=i8), | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as job list in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
type(job_list_type), | intent(out) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
|
logical, | intent(in), | optional | :: | field |
Read from table field. |
Returns configuration value as logical in value
(if 0 or 1).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
logical, | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as 4-byte real in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
real(kind=r4), | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as 8-byte real in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
real(kind=r8), | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Returns configuration value as report in value
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
type(report_type), | intent(out) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
|
logical, | intent(in), | optional | :: | field |
Read from table field. |
Returns configuration value as character string in value
. The
string is unescaped by default (\\
is converted to \
).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
||
character(len=*), | intent(inout) | :: | value |
Setting value. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Opaque file configuration type.
Loads field value on to Lua stack.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | name |
Setting name. |
Opens configuration file and optionally loads the table of the given name if the argument has been passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
||
character(len=*), | intent(in) | :: | path |
Path to config file. |
||
character(len=*), | intent(in), | optional | :: | name |
Name of table. Passed name implies table loading. |
|
logical, | intent(in), | optional | :: | geocom |
Register GeoCOM API for Lua. |
Returns size of configuration table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
Closes configuration file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |
Removes last stack element.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(config_type), | intent(inout) | :: | config |
Config type. |