push_char Subroutine

private subroutine push_char(json, c)

Core routine.

See also

History

  • Jacob Williams : 5/3/2015 : replaced original version of this routine.

Arguments

Type IntentOptional AttributesName
class(json_core), intent(inout) :: json
character(kind=CK,len=1), intent(in) :: c

to character to push


Calls

proc~~push_char~~CallsGraph proc~push_char push_char proc~integer_to_string integer_to_string proc~push_char->proc~integer_to_string

Contents

Source Code


Source Code

    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