delete_single_attribute Subroutine

private pure subroutine delete_single_attribute(self, name)

Delete one attribute name/value pair.

Type Bound

xml_tag

Arguments

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

XML tag.

character(len=*), intent(in) :: name

Attribute name.


Called by

proc~~delete_single_attribute~~CalledByGraph proc~delete_single_attribute xml_tag%delete_single_attribute none~delete_attributes xml_tag%delete_attributes none~delete_attributes->proc~delete_single_attribute proc~delete_multiple_attributes xml_tag%delete_multiple_attributes none~delete_attributes->proc~delete_multiple_attributes proc~delete_multiple_attributes->proc~delete_single_attribute program~foxy_test_delete_attributes foxy_test_delete_attributes program~foxy_test_delete_attributes->none~delete_attributes

Source Code

   pure subroutine delete_single_attribute(self, name)
   !< Delete one attribute name/value pair.
   class(xml_tag), intent(inout) :: self               !< XML tag.
   character(*),   intent(in)    :: name               !< Attribute name.
   type(string), allocatable     :: new_attribute(:,:) !< Temporary storage for attributes.
   integer(I4P)                  :: a                  !< Counter.

   if (self%attributes_number>0) then
      search_tag: do a=1, self%attributes_number
         if (self%attribute(1, a)==name) then
            if (self%attributes_number>1) then
               allocate(new_attribute(1:2, 1:self%attributes_number-1))
               if (a==1) then
                  new_attribute(:, a:) = self%attribute(:, a+1:)
               elseif (a==self%attributes_number) then
                  new_attribute(:, :a-1) = self%attribute(:, :a-1)
               else
                  new_attribute(:, :a-1) = self%attribute(:, :a-1)
                  new_attribute(:, a:) = self%attribute(:, a+1:)
               endif
               call move_alloc(from=new_attribute, to=self%attribute)
            else
               call self%attribute%free
               deallocate(self%attribute)
            endif
            self%attributes_number = self%attributes_number - 1
            exit search_tag
         endif
      enddo search_tag
   endif
   endsubroutine delete_single_attribute