load_table_from_unit Subroutine

public subroutine load_table_from_unit(table, unit, error)

Load a TOML table from a formatted unit as toml_load does, without the re-open (see read_unit_text). Parse errors name the unit’s file.

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(out), allocatable :: table

TOML table read

integer, intent(in) :: unit

Formatted unit to read

type(error_t), intent(out), allocatable :: error

Error handling


Source Code

    subroutine load_table_from_unit(table, unit, error)

        !> TOML table read
        type(toml_table), allocatable, intent(out) :: table

        !> Formatted unit to read
        integer, intent(in) :: unit

        !> Error handling
        type(error_t), allocatable, intent(out) :: error

        character(len=:), allocatable :: text
        character(len=4096) :: name

        call read_unit_text(unit, text, error)
        if (allocated(error)) return

        inquire(unit=unit, name=name)
        call load_table_from_text(table, text, trim(name), error)

    end subroutine load_table_from_unit