dm_config Module

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)

Uses

  • module~~dm_config~~UsesGraph module~dm_config dm_config module~dm_error dm_error module~dm_config->module~dm_error module~dm_id dm_id module~dm_config->module~dm_id module~dm_kind dm_kind module~dm_config->module~dm_kind module~dm_lua dm_lua module~dm_config->module~dm_lua module~dm_string dm_string module~dm_config->module~dm_string module~dm_error->module~dm_kind module~dm_ascii dm_ascii module~dm_error->module~dm_ascii iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_lua->module~dm_error module~dm_lua->module~dm_kind module~dm_lua->module~dm_string iso_c_binding iso_c_binding module~dm_lua->iso_c_binding lua lua module~dm_lua->lua module~dm_file dm_file module~dm_lua->module~dm_file module~dm_util dm_util module~dm_lua->module~dm_util module~dm_string->module~dm_error module~dm_string->module~dm_kind module~dm_file->module~dm_error module~dm_file->module~dm_kind module~dm_util->module~dm_error module~dm_util->module~dm_kind

Used by

  • module~~dm_config~~UsedByGraph module~dm_config dm_config module~dmpack dmpack module~dmpack->module~dm_config

Interfaces

public interface dm_config_get

Generic interface to return configuration value by name.

  • private subroutine config_get_array_int32(config, name, values, error)

    Returns configuration values as 4-byte integer array in values.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_array_int64(config, name, values, error)

    Returns configuration values as 8-byte integer array in values.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_array_string(config, name, values, error)

    Returns configuration values as string array in values.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_int32(config, name, value, error)

    Returns configuration value as 4-byte integer in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_int64(config, name, value, error)

    Returns configuration value as 8-byte integer in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_job_list(config, name, value, error, field)

    Returns configuration value as job list in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_logical(config, name, value, error)

    Returns configuration value as logical in value (if 0 or 1).

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_real32(config, name, value, error)

    Returns configuration value as 4-byte real in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_real64(config, name, value, error)

    Returns configuration value as 8-byte real in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_report(config, name, value, error, field)

    Returns configuration value as report in value.

    Arguments

    Type IntentOptional 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.

  • private subroutine config_get_string(config, name, value, error)

    Returns configuration value as character string in value. The string is unescaped by default (\\ is converted to \).

    Arguments

    Type IntentOptional 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.


Derived Types

type, public ::  config_type

Opaque file configuration type.


Functions

public function dm_config_field(config, name) result(rc)

Loads field value on to Lua stack.

Arguments

Type IntentOptional Attributes Name
type(config_type), intent(inout) :: config

Config type.

character(len=*), intent(in) :: name

Setting name.

Return Value integer

public function dm_config_open(config, path, name, geocom) result(rc)

Opens configuration file and optionally loads the table of the given name if the argument has been passed.

Read more…

Arguments

Type IntentOptional 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.

Return Value integer

public function dm_config_size(config) result(n)

Returns size of configuration table.

Arguments

Type IntentOptional Attributes Name
type(config_type), intent(inout) :: config

Config type.

Return Value integer


Subroutines

public subroutine dm_config_close(config)

Closes configuration file.

Arguments

Type IntentOptional Attributes Name
type(config_type), intent(inout) :: config

Config type.

public subroutine dm_config_remove(config)

Removes last stack element.

Arguments

Type IntentOptional Attributes Name
type(config_type), intent(inout) :: config

Config type.