Process the configuration file to a TOML data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(out), | allocatable | :: | table |
TOML data structure |
|
character(len=*), | intent(in) | :: | manifest |
Name of the package configuration file |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error status of the operation |
subroutine read_package_file(table, manifest, error)
!> TOML data structure
type(toml_table), allocatable, intent(out) :: table
!> Name of the package configuration file
character(len=*), intent(in) :: manifest
!> Error status of the operation
type(error_t), allocatable, intent(out) :: error
type(toml_error), allocatable :: parse_error
integer :: unit
logical :: exist
inquire (file=manifest, exist=exist)
if (.not. exist) then
call file_not_found_error(error, manifest)
return
end if
open(file=manifest, newunit=unit)
call toml_load(table, unit, error=parse_error)
close(unit)
if (allocated(parse_error)) then
allocate (error)
call move_alloc(parse_error%message, error%message)
return
end if
end subroutine read_package_file