SimpleTextColumn.F90 Source File


This file depends on

sourcefile~~simpletextcolumn.f90~~EfferentGraph sourcefile~simpletextcolumn.f90 SimpleTextColumn.F90 sourcefile~abstractmeternode.f90 AbstractMeterNode.F90 sourcefile~simpletextcolumn.f90->sourcefile~abstractmeternode.f90 sourcefile~textcolumn.f90 TextColumn.F90 sourcefile~simpletextcolumn.f90->sourcefile~textcolumn.f90 sourcefile~abstractmeter.f90 AbstractMeter.F90 sourcefile~abstractmeternode.f90->sourcefile~abstractmeter.f90 sourcefile~textcolumn.f90->sourcefile~abstractmeternode.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~abstractmeter.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90

Files dependent on this one

sourcefile~~simpletextcolumn.f90~~AfferentGraph sourcefile~simpletextcolumn.f90 SimpleTextColumn.F90 sourcefile~mapl_profiler.f90 MAPL_Profiler.F90 sourcefile~mapl_profiler.f90->sourcefile~simpletextcolumn.f90 sourcefile~namecolumn.f90 NameColumn.F90 sourcefile~namecolumn.f90->sourcefile~simpletextcolumn.f90 sourcefile~separatorcolumn.f90 SeparatorColumn.F90 sourcefile~separatorcolumn.f90->sourcefile~simpletextcolumn.f90

Source Code

module MAPL_SimpleTextColumn
   use MAPL_TextColumn
   use MAPL_AbstractMeterNode
   implicit none
   private

   public :: SimpleTextColumn

   type, abstract, extends(TextColumn) :: SimpleTextColumn
      private
   contains
      procedure :: get_rows_range
      procedure :: get_rows
      procedure(i_get_row), deferred :: get_row
   end type SimpleTextColumn

   abstract interface

      function i_get_row(this, node) result(row)
         use MAPL_AbstractMeterNode
         import SimpleTextColumn
         character(:), allocatable :: row
         class (SimpleTextColumn), intent(in) :: this
         class (AbstractMeterNode), intent(in) :: node
      end function i_get_row

   end interface


contains


   ! Using subroutines instead of functions as a workaround for gfortran 8.2
   ! Reproducer being submitted by Damian Rouson (10/12/2018)
   subroutine get_rows_range(this, begin, end, rows)
      class (SimpleTextColumn), target, intent(in) :: this
      class (AbstractMeterNodeIterator), intent(in) :: begin
      class (AbstractMeterNodeIterator), intent(in) :: end
      character(:), allocatable, intent(inout) :: rows(:)

      class (AbstractMeterNodeIterator), allocatable :: iter
      integer :: i
      integer :: width
      class (AbstractMeterNode), pointer :: subnode

      ! count_nodes
      iter = begin
      i = 0
      do while (iter /= end)
         i = i + 1
         call iter%next()
      end do

      width = this%get_width()
      allocate(character(width) :: rows(i))

      ! Fill rows
      iter = begin
      i = 0
      do while (iter /= end)
         i = i + 1
         subnode => iter%get()
         rows(i) = this%get_row(subnode)
         call iter%next()
      end do
      
   end subroutine get_rows_range


  subroutine get_rows(this, node, rows)
      class (SimpleTextColumn), intent(in) :: this
      class (AbstractMeterNode), target, intent(in) :: node
      character(:), allocatable, intent(out) :: rows(:)

      class (AbstractMeterNodeIterator), allocatable :: b, e

      b = node%begin()
      e = node%end()

      call this%get_rows_range(b, e, rows)

   end subroutine get_rows
   
end module MAPL_SimpleTextColumn