Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
Key to read from |
||
type(string_t), | intent(out), | allocatable | :: | list(:) |
List of strings to read |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
subroutine get_list(table, key, list, error) !> Instance of the TOML data structure type(toml_table), intent(inout) :: table !> Key to read from character(len=*), intent(in) :: key !> List of strings to read type(string_t), allocatable, intent(out) :: list(:) !> Error handling type(error_t), allocatable, intent(out) :: error integer :: stat, ilist, nlist type(toml_array), pointer :: children character(len=:), allocatable :: str if (.not.table%has_key(key)) return call get_value(table, key, children, requested=.false.) if (associated(children)) then nlist = len(children) allocate (list(nlist)) do ilist = 1, nlist call get_value(children, ilist, str, stat=stat) if (stat /= toml_stat%success) then call fatal_error(error, "Entry in "//key//" field cannot be read") exit end if call move_alloc(str, list(ilist)%s) end do if (allocated(error)) return else call get_value(table, key, str, stat=stat) if (stat /= toml_stat%success) then call fatal_error(error, "Entry in "//key//" field cannot be read") return end if if (allocated(str)) then allocate (list(1)) call move_alloc(str, list(1)%s) end if end if end subroutine get_list