merge_array Subroutine

public recursive subroutine merge_array(lhs, rhs)

Append values from one TOML array to another

Arguments

Type IntentOptional Attributes Name
class(toml_array), intent(inout) :: lhs

Instance of array to merge into

class(toml_array), intent(inout) :: rhs

Instance of array to be merged


Source Code

recursive subroutine merge_array(lhs, rhs)

   !> Instance of array to merge into
   class(toml_array), intent(inout) :: lhs

   !> Instance of array to be merged
   class(toml_array), intent(inout) :: rhs

   class(toml_value), pointer :: ptr
   class(toml_value), allocatable :: tmp
   integer :: n, i, stat

   n = len(rhs)

   do i = 1, n
      call rhs%get(i, ptr)
      if (allocated(tmp)) deallocate(tmp)
      allocate(tmp, source=ptr)
      call lhs%push_back(tmp, stat)
   end do

end subroutine merge_array