argument_list Derived Type

type, public :: argument_list

Argument list class


Components

Type Visibility Attributes Name Initial
type(argument), public, allocatable :: argv(:)

Array of arguments in this list

integer, public :: nargs = 0

Number of arguments

character(len=:), public, allocatable :: prog

Name of the invoked executable, if available


Constructor

public interface argument_list

Constructor for the argument list

  • private function new_argument_list(argument_counter, argument_getter) result(new)

    Constructor of the argument list

    Arguments

    Type IntentOptional Attributes Name
    procedure(argument_count_interface), optional :: argument_counter

    Argument counter interface

    procedure(get_argument_interface), optional :: argument_getter

    Argument getter interface

    Return Value type(argument_list)

    Newly created argument list


Type-Bound Procedures

procedure, public :: get

Get command line argument

  • private pure subroutine get(self, idx, arg)

    Arguments

    Type IntentOptional Attributes Name
    class(argument_list), intent(in) :: self
    integer, intent(in) :: idx
    character(len=:), intent(out), allocatable :: arg

procedure, public :: info

Display debug information on this instance

  • private subroutine info(self, unit)

    Display debug information on an argument list instance

    Arguments

    Type IntentOptional Attributes Name
    class(argument_list), intent(in) :: self

    Instance of the argument list

    integer, intent(in) :: unit

    Formatted unit for output

procedure, public :: push_back

Append a command line argument

  • private subroutine push_back(self, string)

    Append a string to the argument list

    Arguments

    Type IntentOptional Attributes Name
    class(argument_list), intent(inout) :: self

    Instance of the argument list

    character(len=*), intent(in) :: string

    String representing the argument

Source Code

   type :: argument_list
      !> Name of the invoked executable, if available
      character(len=:), allocatable :: prog
      !> Number of arguments
      integer :: nargs = 0
      !> Array of arguments in this list
      type(argument), allocatable :: argv(:)
   contains
      !> Append a command line argument
      procedure :: push_back
      !> Display debug information on this instance
      procedure :: info
      !> Get command line argument
      procedure :: get
   end type argument_list