subroutineapply_tableprivate
subroutine apply_table(table, s, stat, errmsg)
Apply the keys of TOML table as options.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| table | type(toml_table) | inout | the table | |
| s | type(settings_t) | inout | the settings | |
| stat | integer | out | nonzero on failure | |
| errmsg | character(len=:) | out | allocatable | what is wrong |
Calls
Source
Show the code
subroutine apply_table(table, s, stat, errmsg)
type(toml_table), intent(inout) :: table !! the table
type(settings_t), intent(inout) :: s !! the settings
integer, intent(out) :: stat !! nonzero on failure
character(len=:), allocatable, intent(out) :: errmsg !! what is wrong
type(toml_key), allocatable :: keys(:)
class(toml_value), pointer :: v
type(string_t), allocatable :: values(:)
character(len=:), allocatable :: key
integer :: k
stat = 0
call table%get_keys(keys)
do k = 1, size(keys)
key = keys(k)%key
if (key == 'front_page' .or. key == 'front_page_file') cycle
if (.not. is_option(key)) then
call warn("Ignoring unknown Ford option '"//key//"'")
cycle
end if
call table%get(key, v)
allocate (values(0))
select type (v)
type is (toml_keyval)
call push(values, scalar_text(table, key, v%get_type()))
type is (toml_array)
call array_values(v, values, stat, errmsg)
type is (toml_table)
call map_values(v, merge(':', '=', key == 'extra_mods'), values)
class default
stat = 1
errmsg = "unexpected value for option '"//key//"'"
end select
if (stat == 0) call set_option(s, key, values, stat, errmsg)
deallocate (values)
if (stat /= 0) return
end do
end subroutine apply_table