stringify Function

private pure function stringify(self, is_indented, is_content_indented, only_start, only_content, only_end, linearize) result(stringed)

Convert the whole tag into a string.

Type Bound

xml_tag

Arguments

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

XML tag.

logical, intent(in), optional :: is_indented

Activate content indentation.

logical, intent(in), optional :: is_content_indented

Activate content indentation.

logical, intent(in), optional :: only_start

Write only start tag.

logical, intent(in), optional :: only_content

Write only content.

logical, intent(in), optional :: only_end

Write only end tag.

logical, intent(in), optional :: linearize

Return a "linearized" string of tags without the XML hieararchy.

Return Value character(len=:), allocatable

Output string containing the whole tag.


Calls

proc~~stringify~~CallsGraph proc~stringify xml_tag%stringify chars chars proc~stringify->chars is_allocated is_allocated proc~stringify->is_allocated proc~end_tag xml_tag%end_tag proc~stringify->proc~end_tag 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

Called by

proc~~stringify~~CalledByGraph proc~stringify xml_tag%stringify proc~create_tag_nested create_tag_nested proc~create_tag_nested->proc~stringify proc~stringify_recursive xml_file%stringify_recursive proc~stringify_recursive->proc~stringify proc~stringify_recursive->proc~stringify_recursive proc~stringify~2 xml_file%stringify proc~stringify~2->proc~stringify proc~stringify~2->proc~stringify_recursive proc~write_tag xml_tag%write_tag proc~write_tag->proc~stringify program~foxy_test_add_attributes foxy_test_add_attributes program~foxy_test_add_attributes->proc~stringify program~foxy_test_create_tag foxy_test_create_tag program~foxy_test_create_tag->proc~stringify program~foxy_test_delete_attributes foxy_test_delete_attributes program~foxy_test_delete_attributes->proc~stringify program~foxy_test_delete_content foxy_test_delete_content program~foxy_test_delete_content->proc~stringify program~foxy_test_indent_tag foxy_test_indent_tag program~foxy_test_indent_tag->proc~stringify interface~xml_tag xml_tag interface~xml_tag->proc~create_tag_nested 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, is_indented, is_content_indented, only_start, only_content, only_end, linearize) result(stringed)
   !< Convert the whole tag into a string.
   class(xml_tag), intent(in)           :: self                 !< XML tag.
   logical,        intent(in), optional :: is_indented          !< Activate content indentation.
   logical,        intent(in), optional :: is_content_indented  !< Activate content indentation.
   logical,        intent(in), optional :: only_start           !< Write only start tag.
   logical,        intent(in), optional :: only_content         !< Write only content.
   logical,        intent(in), optional :: only_end             !< Write only end tag.
   logical,        intent(in), optional :: linearize            !< Return a "linearized" string of tags without the XML hieararchy.
   logical                              :: linearize_           !< Linearize sentinel, local var.
   character(len=:), allocatable        :: stringed             !< Output string containing the whole tag.
   logical                              :: is_content_indented_ !< Activate content indentation.
   logical                              :: only_start_          !< Write only start tag.
   logical                              :: only_content_        !< Write only content.
   logical                              :: only_end_            !< Write only end tag.

   linearize_ = .false. ; if (present(linearize)) linearize_ = linearize
   if (linearize_) then
      stringed = ''
                                    stringed = stringed//'name:            "'//self%tag_name                  //'"'//new_line('a')
      if (self%attributes_number>0) stringed = stringed//'attributes:      "'//self%attributes()              //'"'//new_line('a')
                                    stringed = stringed//'char pos indexes:"'//trim(str(self%pos))            //'"'//new_line('a')
                                    stringed = stringed//'content:         "'//self%tag_content               //'"'//new_line('a')
                                    stringed = stringed//'indent:          "'//trim(str(self%indent))         //'"'//new_line('a')
                                    stringed = stringed//'is self closing: "'//trim(str(self%is_self_closing))//'"'//new_line('a')
                                    stringed = stringed//'level:           "'//trim(str(self%level))          //'"'//new_line('a')
                                    stringed = stringed//'id:              "'//trim(str(self%id))             //'"'//new_line('a')
                                    stringed = stringed//'parent id:       "'//trim(str(self%parent_id))      //'"'//new_line('a')
                                    stringed = stringed//'children number: "'//trim(str(self%children_number))//'"'//new_line('a')
      if (allocated(self%child_id)) stringed = stringed//'children ids:    "'//trim(str(self%child_id))       //'"'//new_line('a')
   else
      is_content_indented_ = .false. ; if (present(is_content_indented)) is_content_indented_ = is_content_indented
      only_start_ = .false. ; if (present(only_start)) only_start_ = only_start
      only_content_ = .false. ; if (present(only_content)) only_content_ = only_content
      only_end_ = .false. ; if (present(only_end)) only_end_ = only_end
      if (only_start_) then
         stringed = self%start_tag(is_indented=is_indented)
      elseif (only_content_) then
         if (self%tag_content%is_allocated()) then
           if (is_content_indented_) then
              stringed = repeat(' ', self%indent+2)//self%tag_content
           else
              stringed = self%tag_content%chars()
           endif
         endif
      elseif (only_end_) then
         stringed = self%end_tag(is_indented=is_indented)
      else
         stringed = ''
         if (self%tag_name%is_allocated()) then
            if (self%is_self_closing) then
               stringed = self%self_closing_tag(is_indented=is_indented)
            else
               stringed = self%start_tag(is_indented=is_indented)
               if (self%tag_content%is_allocated()) then
                  if (is_content_indented_) then
                     stringed = stringed//new_line('a')//repeat(' ', self%indent+2)//&
                                self%tag_content//new_line('a')//repeat(' ', self%indent)
                  else
                     stringed = stringed//self%tag_content
                  endif
               endif
               stringed = stringed//self%end_tag()
            endif
         endif
      endif
   endif
   endfunction stringify