read_package_file Subroutine

public subroutine read_package_file(table, manifest, error)

Process the configuration file to a TOML data structure

Arguments

Type IntentOptional 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


Source Code

    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