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

Contents

Source Code


Components

TypeVisibilityAttributesNameInitial
integer(kind=I4P), private :: Nt =0
type(xml_tag), private, allocatable:: tag(:)

Finalization Procedures

final :: finalize

  • private subroutine finalize(file)

    Arguments

    TypeIntentOptionalAttributesName
    type(xml_file), intent(inout) :: file

Type-Bound Procedures

procedure, public :: free

  • private elemental subroutine free(self)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(inout) :: self

procedure, public :: parse

  • private subroutine parse(self, string, filename)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(inout) :: self
    character, intent(in), optional :: string
    character, intent(in), optional :: filename

procedure, public :: content

  • private pure function content(self, name)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(in) :: self
    character, intent(in) :: name

    Return Value character(len=:),allocatable

procedure, public :: stringify

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

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(in) :: self

    Return Value character(len=:),allocatable

procedure, public :: add_tag

  • private elemental subroutine add_tag(self, tag)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(inout) :: self
    type(xml_tag), intent(in) :: tag

procedure, public :: delete_tag

  • private elemental subroutine delete_tag(self, name)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(inout) :: self
    character, intent(in) :: name

procedure, private :: parse_from_string

  • private subroutine parse_from_string(self, source_string)

    Arguments

    TypeIntentOptionalAttributesName
    class(xml_file), intent(inout) :: self
    character, intent(in) :: source_string

Source Code

type, public:: xml_file
  !< XML file class.
  !<
  !< @todo The "delete" facility is incomplete: nested tags are not taken into account. Better support will with the
  !< "dom" facility.
  private
  integer(I4P)               :: Nt = 0 !< Number of XML tags.
  type(xml_tag), allocatable :: tag(:) !< XML tags array.
  contains
    ! public methods
    procedure :: free       !< Free dynamic memory.
    procedure :: parse      !< Parse xml data from string or file.
    procedure :: content    !< Return tag content of tag named *name*.
    procedure :: stringify  !< Convert the whole file data into a string.
    procedure :: add_tag    !< Add tag to XML file.
    procedure :: delete_tag !< Add tag from XML file.
    final     :: finalize   !< Free dynamic memory when finalizing.
    ! private methods
    procedure, private :: parse_from_string !< Parse xml data from string.
endtype xml_file