ManagingFileReader_t Derived Type

type, public, extends(FileReader_t) :: ManagingFileReader_t

A class for tokenized reading of lines, that manages the file access.

An instance of this class holds the only reference to the file handle.


Constructor

public interface ManagingFileReader_t

  • public function construct_ManagingFileReader_t(file_name, echo_lines, err) result(res)

    Construct a ManagingFileReader_t

    If the argument echo_lines is present, then the read lines are echoed to the unit echo_lines. If the argument is not present, the echoing is switched off.

    If err is not present, all errors will lead to a stop of the program. Otherwise this argument contains the error code.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: file_name
    integer, intent(in), optional :: echo_lines
    integer, intent(out), optional :: err

    Return Value type(ManagingFileReader_t)


Type-Bound Procedures

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

procedure, public :: is_open

  • private elemental function is_open(this)

    Return if a file is open.

    Arguments

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

    Return Value logical