Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=IK), | intent(in) | :: | unit | file unit number (if parsing from a file) |
||
character(kind=CK,len=*), | intent(in) | :: | str | JSON string (if parsing from a string) |
||
character(kind=CK,len=*), | intent(in) | :: | chars | the string to check for. |
Core parsing routine.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=IK), | public | :: | i | ||||
integer(kind=IK), | public | :: | length | ||||
logical(kind=LK), | public | :: | eof | ||||
character(kind=CK,len=1), | public | :: | c |
subroutine parse_for_chars(unit, str, chars)
implicit none
integer(IK),intent(in) :: unit !! file unit number (if parsing from a file)
character(kind=CK,len=*),intent(in) :: str !! JSON string (if parsing from a string)
character(kind=CK,len=*),intent(in) :: chars !! the string to check for.
integer(IK) :: i, length
logical(LK) :: eof
character(kind=CK,len=1) :: c
if (.not. exception_thrown) then
length = len_trim(chars)
do i = 1, length
c = pop_char(unit, str=str, eof = eof, skip_ws = .true.)
if (eof) then
call throw_exception('Error in parse_for_chars:'//&
' Unexpected end of file while parsing array.')
return
else if (c /= chars(i:i)) then
call throw_exception('Error in parse_for_chars:'//&
' Unexpected character.: "'//c//'" '//chars(i:i))
return
end if
end do
end if
end subroutine parse_for_chars