FileReader_t Derived Type

type, public, abstract :: FileReader_t

An abstract class that supports tokenized reading of lines.


Components

Type Visibility Attributes Name Initial
integer, private :: file_id
integer, private, allocatable :: echo_lines
character(len=:), private, allocatable :: file_name

The file name of the open file (if available).

integer, private, allocatable :: current_line

The current line (if available). The number refers to the line just returned from raw_nextline.


Type-Bound Procedures

procedure, private :: raw_nextline

  • private function raw_nextline(this, line)

    Return if the next line can be read and return it

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(inout) :: this
    character(len=:), intent(out), allocatable :: line

    Return Value logical

procedure, public :: close => my_close

  • private impure elemental subroutine my_close(this, delete)

    Close the file.

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(inout) :: this
    logical, intent(in), optional :: delete

procedure, public :: nextline

  • private function nextline(this, tokenized_line, skip_empty) result(can_still_read)

    Return if the next line can be read. It is written to the out-argument.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(inout) :: this
    type(TokenIterator_t), intent(out) :: tokenized_line
    logical, intent(in) :: skip_empty

    Return Value logical

procedure, public :: rewind => my_rewind

  • private subroutine my_rewind(this)

    Rewind the file

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(inout) :: this

procedure, public :: set_echo_lines

  • private subroutine set_echo_lines(this, echo_lines)

    Set the unit where to echo lines.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(inout) :: this
    integer, intent(in), optional :: echo_lines

procedure, public :: get_current_line

  • private elemental function get_current_line(this) result(res)

    Return the current line (if defined)

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(in) :: this

    Return Value integer

procedure, public :: get_file_name

  • private pure function get_file_name(this) result(res)

    Return the file name (if defined)

    Arguments

    Type IntentOptional Attributes Name
    class(FileReader_t), intent(in) :: this

    Return Value character(len=:), allocatable