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.

Type Bound

json_core

Arguments

Type IntentOptional Attributes Name
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 json_core%push_char none~throw_exception json_core%throw_exception proc~push_char->none~throw_exception proc~integer_to_string integer_to_string proc~push_char->proc~integer_to_string proc~json_throw_exception json_core%json_throw_exception none~throw_exception->proc~json_throw_exception

Called by

proc~~push_char~~CalledByGraph proc~push_char json_core%push_char proc~parse_number json_core%parse_number proc~parse_number->proc~push_char proc~parse_value_nonrecursive parse_value_nonrecursive proc~parse_value_nonrecursive->proc~push_char proc~parse_value_nonrecursive->proc~parse_number proc~parse_value_recursive parse_value_recursive proc~parse_value_recursive->proc~push_char proc~parse_value_recursive->proc~parse_number

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
            json%ichunk = json%ichunk - 1

        else

            json%pushed_index = json%pushed_index + 1

            if (json%pushed_index>0 .and. json%pushed_index<=pushed_char_size) 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 value 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