stringify Function

private pure function stringify(self, linearize) result(string)

Type Bound

xml_file

Arguments

Type IntentOptional Attributes Name
class(xml_file), intent(in) :: self
logical, intent(in), optional :: linearize

Return Value character(len=:), allocatable


Calls

proc~~stringify~2~~CallsGraph proc~stringify~2 xml_file%stringify proc~stringify xml_tag%stringify proc~stringify~2->proc~stringify proc~stringify_recursive xml_file%stringify_recursive proc~stringify~2->proc~stringify_recursive interface~str str proc~stringify->interface~str proc~attributes xml_tag%attributes proc~stringify->proc~attributes proc~chars string%chars proc~stringify->proc~chars proc~end_tag xml_tag%end_tag proc~stringify->proc~end_tag proc~is_allocated string%is_allocated proc~stringify->proc~is_allocated proc~self_closing_tag xml_tag%self_closing_tag proc~stringify->proc~self_closing_tag proc~start_tag xml_tag%start_tag proc~stringify->proc~start_tag proc~stringify_recursive->proc~stringify proc~stringify_recursive->proc~stringify_recursive proc~str_a_i1p str_a_I1P interface~str->proc~str_a_i1p proc~str_a_i2p str_a_I2P interface~str->proc~str_a_i2p proc~str_a_i4p str_a_I4P interface~str->proc~str_a_i4p proc~str_a_i8p str_a_I8P interface~str->proc~str_a_i8p proc~str_a_r4p str_a_R4P interface~str->proc~str_a_r4p proc~str_a_r8p str_a_R8P interface~str->proc~str_a_r8p proc~str_bol str_bol interface~str->proc~str_bol proc~str_i1p str_I1P interface~str->proc~str_i1p proc~str_i2p str_I2P interface~str->proc~str_i2p proc~str_i4p str_I4P interface~str->proc~str_i4p proc~str_i8p str_I8P interface~str->proc~str_i8p proc~str_r4p str_R4P interface~str->proc~str_r4p proc~str_r8p str_R8P interface~str->proc~str_r8p proc~strf_i1p strf_I1P interface~str->proc~strf_i1p proc~strf_i2p strf_I2P interface~str->proc~strf_i2p proc~strf_i4p strf_I4P interface~str->proc~strf_i4p proc~strf_i8p strf_I8P interface~str->proc~strf_i8p proc~strf_r4p strf_R4P interface~str->proc~strf_r4p proc~strf_r8p strf_R8P interface~str->proc~strf_r8p proc~self_closing_tag->proc~attributes proc~start_tag->proc~attributes proc~str_a_i1p->proc~str_i1p proc~str_a_i2p->proc~str_i2p proc~str_a_i4p->proc~str_i4p proc~str_a_i8p->proc~str_i8p proc~str_a_r4p->proc~str_r4p proc~str_a_r8p->proc~str_r8p proc~compact_real_string compact_real_string proc~str_r4p->proc~compact_real_string proc~str_r8p->proc~compact_real_string

Called by

proc~~stringify~2~~CalledByGraph proc~stringify~2 xml_file%stringify program~foxy_test_add_tag foxy_test_add_tag program~foxy_test_add_tag->proc~stringify~2 program~foxy_test_delete_tag foxy_test_delete_tag program~foxy_test_delete_tag->proc~stringify~2 program~foxy_test_parse_file_simple foxy_test_parse_file_simple program~foxy_test_parse_file_simple->proc~stringify~2 program~foxy_test_parse_string_nested_tags foxy_test_parse_string_nested_tags program~foxy_test_parse_string_nested_tags->proc~stringify~2 program~foxy_test_parse_string_simple foxy_test_parse_string_simple program~foxy_test_parse_string_simple->proc~stringify~2 program~foxy_test_write_tag foxy_test_write_tag program~foxy_test_write_tag->proc~stringify~2

Source Code

   pure function stringify(self, linearize) result(string)
   !< Convert the whole file data into a string.
   class(xml_file), intent(in)           :: self       !< XML file.
   logical,         intent(in), optional :: linearize  !< Return a "linearized" string of tags without the XML hieararchy.
   logical                               :: linearize_ !< Linearize sentinel, local var.
   character(len=:), allocatable         :: string     !< Output string containing the whole xml file.
   character(len=:), allocatable         :: tag_string !< Output string containing the current tag.
   integer(I4P)                          :: t          !< Counter.
   logical, allocatable                  :: is_done(:) !< List of stringified tags.

   linearize_ = .false. ; if (present(linearize)) linearize_ = linearize
   string = ''
   if (linearize_) then
      if (self%nt>0) then
         do t=1, self%nt
            string = string//self%tag(t)%stringify(linearize=.true.)//new_line('a')
         enddo
      endif
   else
      if (self%nt>0) then
         allocate(is_done(self%nt)) ; is_done = .false.
         do t=1, self%nt
            if (is_done(t)) cycle
            if (self%tag(t)%children_number>0) then
               tag_string = ''
               call self%stringify_recursive(tag=self%tag(t), is_done=is_done, tag_string=tag_string)
               if (tag_string(1:1)==new_line('a')) tag_string = tag_string(2:)
            else
               tag_string = self%tag(t)%stringify(is_indented=.true.)
            endif
            string = string//tag_string//new_line('a')
            is_done(t) = .true.
         enddo
      endif
   endif
   if (string(len(string):len(string))==new_line('a')) string = string(:len(string)-1)
   endfunction stringify