xml_file Derived Type

type, public :: xml_file


Inherits

type~~xml_file~~InheritsGraph type~xml_file xml_file type~xml_tag xml_tag type~xml_file->type~xml_tag tag type~string string type~xml_tag->type~string tag_name, tag_content, attribute

Components

Type Visibility Attributes Name Initial
type(xml_tag), private, allocatable :: tag(:)
integer(kind=I4P), private :: nt = 0_I4P

Finalization Procedures

final :: finalize

  • private subroutine finalize(self)

    Arguments

    Type IntentOptional Attributes Name
    type(xml_file), intent(inout) :: self

Type-Bound Procedures

procedure, public, pass(self) :: add_tag

  • private elemental subroutine add_tag(self, tag)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(inout) :: self
    type(xml_tag), intent(in) :: tag

procedure, public, pass(self) :: content

  • private pure function content(self, name)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(in) :: self
    character(len=*), intent(in) :: name

    Return Value character(len=:), allocatable

procedure, public, pass(self) :: delete_tag

  • private elemental subroutine delete_tag(self, name)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(inout) :: self
    character(len=*), intent(in) :: name

procedure, public, pass(self) :: free

  • private elemental subroutine free(self)

    Arguments

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

procedure, public, pass(self) :: parse

  • private subroutine parse(self, string, filename)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(inout) :: self
    character(len=*), intent(in), optional :: string
    character(len=*), intent(in), optional :: filename

procedure, public, pass(self) :: stringify

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

    Arguments

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

    Return Value character(len=:), allocatable

procedure, private, pass(self) :: add_child

  • private pure subroutine add_child(self, parent_id, child_id)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(inout) :: self
    integer(kind=I4P), intent(in) :: parent_id
    integer(kind=I4P), intent(in) :: child_id

procedure, private, pass(self) :: parse_from_string

  • private pure subroutine parse_from_string(self, source_string)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(inout) :: self
    character(len=*), intent(in) :: source_string

procedure, private, pass(self) :: stringify_recursive

  • private pure recursive subroutine stringify_recursive(self, tag, is_done, tag_string)

    Arguments

    Type IntentOptional Attributes Name
    class(xml_file), intent(in) :: self
    type(xml_tag), intent(in) :: tag
    logical, intent(inout) :: is_done(:)
    character(len=:), intent(inout), allocatable :: tag_string

Source Code

type, public:: xml_file
   !< XML file class.
   private
   type(xml_tag), allocatable :: tag(:)   !< XML tags array.
   integer(I4P)               :: nt=0_I4P !< Number of XML tags.
   contains
      ! public methods
      procedure, pass(self) :: add_tag    !< Add tag to XML file.
      procedure, pass(self) :: content    !< Return tag content of tag named *name*.
      procedure, pass(self) :: delete_tag !< Add tag from XML file.
      procedure, pass(self) :: free       !< Free dynamic memory.
      procedure, pass(self) :: parse      !< Parse xml file.
      procedure, pass(self) :: stringify  !< Convert the whole file data into a string.
      ! private methods
      procedure, pass(self), private :: add_child           !< Add child ID to tag children list.
      procedure, pass(self), private :: parse_from_string   !< Parse xml data from string.
      procedure, pass(self), private :: stringify_recursive !< Convert recursively tags with children into a string.
      ! operators
      final :: finalize !< Free dynamic memory when finalizing.
endtype xml_file