parse_int_int32_char Subroutine

private pure subroutine parse_int_int32_char(str, value, err)

Parse a character string into a 32 bit integer.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: str
integer(kind=int32), intent(out) :: value

Fixed width on purpose: the narrow specific procedure of the generic.

type(error_t), intent(out) :: err

Calls

proc~~parse_int_int32_char~~CallsGraph proc~parse_int_int32_char parse_int_int32_char interface~strip strip proc~parse_int_int32_char->interface~strip proc~error_has_error error_t%error_has_error proc~parse_int_int32_char->proc~error_has_error proc~error_set error_t%error_set proc~parse_int_int32_char->proc~error_set proc~parse_integer_wide parse_integer_wide proc~parse_int_int32_char->proc~parse_integer_wide proc~strip_char strip_char interface~strip->proc~strip_char proc~strip_string strip_string interface~strip->proc~strip_string proc~parse_integer_wide->interface~strip proc~parse_integer_wide->proc~error_set proc~strip_string->interface~strip

Called by

proc~~parse_int_int32_char~~CalledByGraph proc~parse_int_int32_char parse_int_int32_char interface~parse_int parse_int interface~parse_int->proc~parse_int_int32_char proc~parse_int_int32_string parse_int_int32_string interface~parse_int->proc~parse_int_int32_string proc~parse_int_int32_string->proc~parse_int_int32_char proc~cli_get_int32 cli_t%cli_get_int32 proc~cli_get_int32->interface~parse_int proc~cli_get_int64 cli_t%cli_get_int64 proc~cli_get_int64->interface~parse_int

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private :: wide

Source Code

   pure subroutine parse_int_int32_char(str, value, err)
      !! Parse a character string into a 32 bit integer.
      character(len=*), intent(in) :: str
      integer(int32), intent(out) :: value
         !! Fixed width on purpose: the narrow specific procedure of the
         !! generic.
      type(error_t), intent(out) :: err

      integer(int64) :: wide

      value = 0_int32
      call parse_integer_wide(str, wide, err)
      if (err%has_error()) return

      if (wide > int(huge(value), int64) .or. wide < -int(huge(value), int64) - 1_int64) then
         call err%set(ERROR_PARSE, "integer out of range for a 32 bit integer: '"//strip(str)//"'")
         return
      end if
      value = int(wide, int32)

   end subroutine parse_int_int32_char