Core routine.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
character(kind=CK,len=1), | intent(in) | :: | c | to character to push |
subroutine push_char(json,c)
implicit none
class(json_core),intent(inout) :: json
character(kind=CK,len=1),intent(in) :: c !! to character to push
character(kind=CK,len=max_numeric_str_len) :: istr !! for error printing
if (.not. json%exception_thrown) then
if (use_unformatted_stream) then
!in this case, c is ignored, and we just
!decrement the stream position counter:
json%ipos = json%ipos - 1
else
json%pushed_index = json%pushed_index + 1
if (json%pushed_index>0 .and. json%pushed_index<=len(json%pushed_char)) then
json%pushed_char(json%pushed_index:json%pushed_index) = c
else
call integer_to_string(json%pushed_index,int_fmt,istr)
call json%throw_exception('Error in push_char: '//&
'invalid valid of pushed_index: '//trim(istr))
end if
end if
!character count in the current line
json%char_count = json%char_count - 1
end if
end subroutine push_char