functionscalar_textprivate
character(len=:) function scalar_text(table, key, kind) result(text)
A string, integer or logical value of table as text.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| table | type(toml_table) | inout | the table | |
| key | character(len=*) | in | the key | |
| kind | integer | in | the value's |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| text | character(len=:) | privateallocatable |
Source
Show the code
function scalar_text(table, key, kind) result(text)
type(toml_table), intent(inout) :: table !! the table
character(len=*), intent(in) :: key !! the key
integer, intent(in) :: kind !! the value's `toml_type`
character(len=:), allocatable :: text
integer :: i
logical :: flag
text = ''
if (kind == toml_type%string) then
call get_value(table, key, text)
else if (kind == toml_type%int) then
call get_value(table, key, i)
text = to_s(i)
else if (kind == toml_type%boolean) then
call get_value(table, key, flag)
text = trim(merge('true ', 'false', flag))
end if
end function scalar_text