Parse a character string into a 32 bit integer.
| Type | Intent | Optional | 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 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | private | :: | wide |
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