cli_find Function

private pure function cli_find(this, name) result(idx)

Index of the entry with this long name, or 0.

A linear walk over the registration array. A command line has tens of options, not thousands, and at that size a scan beats hashing while needing no map to allocate, copy or free.

Type Bound

cli_t

Arguments

Type IntentOptional Attributes Name
class(cli_t), intent(in) :: this
character(len=*), intent(in) :: name

Long name to look for, without dashes.

Return Value integer(kind=default_int)


Called by

proc~~cli_find~~CalledByGraph proc~cli_find cli_t%cli_find proc~cli_get_int32 cli_t%cli_get_int32 proc~cli_get_int32->proc~cli_find proc~cli_get_string cli_t%cli_get_string proc~cli_get_int32->proc~cli_get_string proc~cli_get_int64 cli_t%cli_get_int64 proc~cli_get_int64->proc~cli_find proc~cli_get_int64->proc~cli_get_string proc~cli_get_logical cli_t%cli_get_logical proc~cli_get_logical->proc~cli_find proc~cli_get_logical->proc~cli_get_string proc~cli_get_real_dp cli_t%cli_get_real_dp proc~cli_get_real_dp->proc~cli_find proc~cli_get_real_dp->proc~cli_get_string proc~cli_get_real_sp cli_t%cli_get_real_sp proc~cli_get_real_sp->proc~cli_find proc~cli_get_real_sp->proc~cli_get_string proc~cli_get_string->proc~cli_find proc~cli_has cli_t%cli_has proc~cli_has->proc~cli_find proc~cli_is_set cli_t%cli_is_set proc~cli_is_set->proc~cli_find proc~cli_occurrences cli_t%cli_occurrences proc~cli_occurrences->proc~cli_find proc~cli_parse_args cli_t%cli_parse_args proc~cli_parse_args->proc~cli_find proc~cli_get_char cli_t%cli_get_char proc~cli_get_char->proc~cli_get_string proc~cli_parse cli_t%cli_parse proc~cli_parse->proc~cli_parse_args

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: i

Source Code

   pure function cli_find(this, name) result(idx)
      !! Index of the entry with this long name, or 0.
      !!
      !! A linear walk over the registration array. A command line has tens of
      !! options, not thousands, and at that size a scan beats hashing while
      !! needing no map to allocate, copy or free.
      class(cli_t), intent(in) :: this
      character(len=*), intent(in) :: name
         !! Long name to look for, without dashes.
      integer(default_int) :: idx

      integer(default_int) :: i

      idx = 0_default_int
      do i = 1_default_int, this%count
         if (char(this%entries(i)%name) == name) then
            idx = i
            return
         end if
      end do
   end function cli_find