parse_int Interface

public interface parse_int

Parse a string into an integer, reporting failures through error_t.

The accepted grammar is optional surrounding whitespace, an optional + or - sign and one or more decimal digits, with nothing else. An empty or blank string, a missing digit, any stray character (including trailing junk such as "12abc") and a value too large for the requested kind all set ERROR_PARSE and leave value at zero.

Specific procedures exist for int32 and int64, so an argument declared integer(default_int) resolves correctly in both the default and the USE_INT8 build.

Calls

interface~~parse_int~~CallsGraph interface~parse_int parse_int proc~parse_int_int32_char parse_int_int32_char 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_int64_char parse_int_int64_char interface~parse_int->proc~parse_int_int64_char proc~parse_int_int64_string parse_int_int64_string interface~parse_int->proc~parse_int_int64_string 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~parse_int_int32_string->proc~parse_int_int32_char proc~parse_int_int64_char->proc~parse_integer_wide proc~parse_int_int64_string->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

interface~~parse_int~~CalledByGraph interface~parse_int parse_int 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

Module Procedures

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

private pure subroutine parse_int_int32_string(str, value, err)

Parse a string_type into a 32 bit integer.

Arguments

Type IntentOptional Attributes Name
type(string_type), intent(in) :: str
integer(kind=int32), intent(out) :: value
type(error_t), intent(out) :: err

private pure subroutine parse_int_int64_char(str, value, err)

Parse a character string into a 64 bit integer.

Arguments

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

Fixed width on purpose: this is the widest integer the parser accumulates in, and the narrower specific procedure range checks against it.

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

private pure subroutine parse_int_int64_string(str, value, err)

Parse a string_type into a 64 bit integer.

Arguments

Type IntentOptional Attributes Name
type(string_type), intent(in) :: str
integer(kind=int64), intent(out) :: value
type(error_t), intent(out) :: err