subroutinearray_valuesprivate
subroutine array_values(array, values, stat, errmsg)
The items of a TOML array as text. An array of tables is taken to be extra_filetypes.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| array | type(toml_array) | inout | the array | |
| values | type(string_t) | inout | allocatabledimension(:) | the items |
| stat | integer | inout | nonzero on failure | |
| errmsg | character(len=:) | out | allocatable | what is wrong |
Calls
Source
Show the code
subroutine array_values(array, values, stat, errmsg)
type(toml_array), intent(inout) :: array !! the array
type(string_t), allocatable, intent(inout) :: values(:) !! the items
integer, intent(inout) :: stat !! nonzero on failure
character(len=:), allocatable, intent(out) :: errmsg !! what is wrong
type(toml_table), pointer :: item
character(len=:), allocatable :: text, part
integer :: k, ios
do k = 1, len(array)
call get_value(array, k, text, stat=ios)
if (ios == 0 .and. allocated(text)) then
call push(values, text)
cycle
end if
call get_value(array, k, item, stat=ios)
if (ios /= 0 .or. .not. associated(item)) then
stat = 1
errmsg = 'expected strings or tables in an array'
return
end if
text = ''
call get_value(item, 'extension', part, '')
text = part
call get_value(item, 'comment', part, '')
text = text//' '//part
call get_value(item, 'lexer', part, '')
if (part /= '') text = text//' '//part
call push(values, text)
end do
end subroutine array_values