AttachedFileReader_t Derived Type

type, public, extends(FileReader_t) :: AttachedFileReader_t

A class for tokenized reading of lines, that can be attached to open file handles.

There might be other reference to the the file handle.


Contents


Constructor

public interface AttachedFileReader_t

  • private function construct_AttachedFileReader_t(file_id, echo_lines, file_name, current_line) result(res)

    Construct an AttachedFileReader_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.

    Arguments

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

    Return Value type(AttachedFileReader_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.

    Note that it reads the next logical line, so if there are two lines connected by a line-continuation symbol, the two lines will be read.

    If skip_empty is true, then lines that have no tokens are automatically skipped and the next logical line is tested. Note that empty lines includes lines that are not blank, but contain only comments.

    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.

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

    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)

    This is the line that would be returned, when calling this%raw_nextline().

    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