write_lines Subroutine

private subroutine write_lines(self, unit, form, iostat, iomsg)

Write lines (records) to a connected unit.

This method checks if self contains more than one line (records) and writes them as lines (records).

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

integer, intent(in) :: unit

Logical unit.

character(len=*), intent(in), optional :: form

Format of unit.

integer, intent(out), optional :: iostat

IO status code.

character(len=*), intent(inout), optional :: iomsg

IO status message.


Calls

proc~~write_lines~2~~CallsGraph proc~write_lines~2 stringifor_string_t::string%write_lines proc~split stringifor_string_t::string%split proc~write_lines~2->proc~split proc~partition stringifor_string_t::string%partition proc~split->proc~partition proc~unique stringifor_string_t::string%unique proc~split->proc~unique raw raw proc~partition->raw proc~replace stringifor_string_t::string%replace proc~unique->proc~replace proc~replace_one_occurrence stringifor_string_t::string%replace_one_occurrence proc~replace->proc~replace_one_occurrence

Called by

proc~~write_lines~2~~CalledByGraph proc~write_lines~2 stringifor_string_t::string%write_lines proc~write_file~2 stringifor_string_t::string%write_file proc~write_file~2->proc~write_lines~2

Contents

Source Code


Source Code

   subroutine write_lines(self, unit, form, iostat, iomsg)
   !< Write lines (records) to a connected unit.
   !<
   !< This method checks if self contains more than one line (records) and writes them as lines (records).
   !<
   !< @note If the connected unit is unformatted a `new_line()` character is added at the end (if necessary) to mark the end of line.
   !<
   !< @note There is no doctests, this being tested by means of [[string:write_file]] doctests.
   class(string),    intent(in)              :: self     !< The string.
   integer,          intent(in)              :: unit     !< Logical unit.
   character(len=*), intent(in),    optional :: form     !< Format of unit.
   integer,          intent(out),   optional :: iostat   !< IO status code.
   character(len=*), intent(inout), optional :: iomsg    !< IO status message.
   type(string), allocatable                 :: lines(:) !< Lines.
   integer                                   :: l        !< Counter.

   if (allocated(self%raw)) then
      call self%split(tokens=lines, sep=new_line('a'))
      do l=1, size(lines, dim=1)
         call lines(l)%write_line(unit=unit, form=form, iostat=iostat, iomsg=iomsg)
      enddo
   endif
   endsubroutine write_lines