to_integer_I4P Function

private elemental function to_integer_I4P(self, kind) result(to_number)

Arguments

TypeIntentOptionalAttributesName
class(string), intent(in) :: self
integer(kind=I4P), intent(in) :: kind

Return Value integer(kind=I4P)


Contents

Source Code


Source Code

   elemental function to_integer_I4P(self, kind) result(to_number)
   !< Cast string to integer (I4P).
   !<
   !<```fortran
   !< use penf
   !< type(string) :: astring
   !< integer(I4P) :: integer_
   !< logical      :: test_passed(1)
   !< astring = '127'
   !< integer_ = astring%to_number(kind=1_I4P)
   !< test_passed(1) = integer_==127_I4P
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   class(string), intent(in) :: self      !< The string.
   integer(I4P),  intent(in) :: kind      !< Mold parameter for kind detection.
   integer(I4P)              :: to_number !< The number into the string.

   if (allocated(self%raw)) then
     if (self%is_integer()) read(self%raw, *) to_number
   endif
   endfunction to_integer_I4P