Set no key if array is not present
Check the key is not empty String array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the toml table |
||
character(len=*), | intent(in) | :: | key |
Key to save to |
||
type(string_t), | intent(in), | allocatable | :: | list(:) |
Instance of the string array |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
subroutine set_list(table, key, list, error) !> Instance of the string array type(string_t), allocatable, intent(in) :: list(:) !> Key to save to character(len=*), intent(in) :: key !> Instance of the toml table type(toml_table), intent(inout) :: table !> Error handling type(error_t), allocatable, intent(out) :: error !> Local variables integer :: stat, ilist type(toml_array), pointer :: children character(len=:), allocatable :: str !> Set no key if array is not present if (.not.allocated(list)) return !> Check the key is not empty if (len_trim(key)<=0) then call fatal_error(error, 'key is empty dumping string array to TOML table') return end if if (size(list)/=1) then ! includes empty list case !> String array call add_array(table, key, children, stat) if (stat /= toml_stat%success) then call fatal_error(error, "Cannot set array table in "//key//" field") return end if do ilist = 1, size(list) call set_value(children, ilist, list(ilist)%s, stat=stat) if (stat /= toml_stat%success) then call fatal_error(error, "Cannot store array entry in "//key//" field") return end if end do else ! Single value: set string call set_value(table, key, list(1)%s, stat=stat) if (stat /= toml_stat%success) & call fatal_error(error, "Cannot store entry in "//key//" field") return end if end subroutine set_list