foxy_xml_file Module

FoXy XML file class.


Uses

  • module~~foxy_xml_file~~UsesGraph module~foxy_xml_file foxy_xml_file module~foxy_xml_tag foxy_xml_tag module~foxy_xml_file->module~foxy_xml_tag penf penf module~foxy_xml_file->penf module~foxy_xml_tag->penf stringifor stringifor module~foxy_xml_tag->stringifor

Used by

  • module~~foxy_xml_file~~UsedByGraph module~foxy_xml_file foxy_xml_file module~foxy foxy module~foxy->module~foxy_xml_file program~foxy_test_add_attributes foxy_test_add_attributes program~foxy_test_add_attributes->module~foxy program~foxy_test_add_tag foxy_test_add_tag program~foxy_test_add_tag->module~foxy program~foxy_test_create_tag foxy_test_create_tag program~foxy_test_create_tag->module~foxy program~foxy_test_delete_attributes foxy_test_delete_attributes program~foxy_test_delete_attributes->module~foxy program~foxy_test_delete_content foxy_test_delete_content program~foxy_test_delete_content->module~foxy program~foxy_test_delete_tag foxy_test_delete_tag program~foxy_test_delete_tag->module~foxy program~foxy_test_indent_tag foxy_test_indent_tag program~foxy_test_indent_tag->module~foxy program~foxy_test_parse_file_simple foxy_test_parse_file_simple program~foxy_test_parse_file_simple->module~foxy program~foxy_test_parse_string_nested_tags foxy_test_parse_string_nested_tags program~foxy_test_parse_string_nested_tags->module~foxy program~foxy_test_parse_string_simple foxy_test_parse_string_simple program~foxy_test_parse_string_simple->module~foxy program~foxy_test_write_tag foxy_test_write_tag program~foxy_test_write_tag->module~foxy

Derived Types

type, public ::  xml_file

XML file class.

Components

Type Visibility Attributes Name Initial
type(xml_tag), private, allocatable :: tag(:)

XML tags array.

integer(kind=I4P), private :: nt = 0_I4P

Number of XML tags.

Finalizations Procedures

final :: finalize

Free dynamic memory when finalizing.

Type-Bound Procedures

procedure, public, pass(self) :: add_tag

Add tag to XML file.

procedure, public, pass(self) :: content

Return tag content of tag named name.

procedure, public, pass(self) :: delete_tag

Add tag from XML file.

procedure, public, pass(self) :: free

Free dynamic memory.

procedure, public, pass(self) :: parse

Parse xml file.

procedure, public, pass(self) :: stringify

Convert the whole file data into a string.

procedure, private, pass(self) :: add_child

Add child ID to tag children list.

procedure, private, pass(self) :: parse_from_string

Parse xml data from string.

procedure, private, pass(self) :: stringify_recursive

Convert recursively tags with children into a string.


Functions

private pure function content(self, name)

Return tag content of tag named name.

Read more…

Arguments

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

XML file.

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

Tag name.

Return Value character(len=:), allocatable

Tag content.

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

Convert the whole file data into a string.

Arguments

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

XML file.

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 xml file.

private function load_file_as_stream(filename, delimiter_start, delimiter_end, fast_read, iostat, iomsg) result(stream)

Load file contents and store as single characters stream.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename

File name.

character(len=*), intent(in), optional :: delimiter_start

Delimiter from which start the stream.

character(len=*), intent(in), optional :: delimiter_end

Delimiter to which end the stream.

logical, intent(in), optional :: fast_read

Flag for activating efficient reading with one single read.

integer(kind=I4P), intent(out), optional :: iostat

IO error.

character(len=*), intent(out), optional :: iomsg

IO error message.

Return Value character(len=:), allocatable

Output string containing the file data as a single stream.


Subroutines

private elemental subroutine add_tag(self, tag)

Add tag to XML file.

Arguments

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

XML file.

type(xml_tag), intent(in) :: tag

XML tag.

private elemental subroutine delete_tag(self, name)

Delete tag from XML file.

Arguments

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

XML file.

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

XML tag name.

private elemental subroutine free(self)

Free dynamic memory.

Arguments

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

XML file.

private subroutine parse(self, string, filename)

Parse xml data from string or file. XML data is linearized, a DOM structured is used.

Read more…

Arguments

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

XML file.

character(len=*), intent(in), optional :: string

String containing xml data.

character(len=*), intent(in), optional :: filename

File name containing xml data.

private pure subroutine add_child(self, parent_id, child_id)

Add child ID to tag children list.

Arguments

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

XML file handler.

integer(kind=I4P), intent(in) :: parent_id

Parent ID.

integer(kind=I4P), intent(in) :: child_id

Child ID.

private pure subroutine parse_from_string(self, source_string)

Parse xml data from a chunk of source string (file stringified for IO on device).

Arguments

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

XML file handler.

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

String containing xml data.

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

Convert recursively tags with children into a string.

Arguments

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

XML file.

type(xml_tag), intent(in) :: tag

XML tag with children.

logical, intent(inout) :: is_done(:)

List of stringified tags.

character(len=:), intent(inout), allocatable :: tag_string

Output string containing the current tag.

private subroutine finalize(self)

Free dynamic memory when finalizing.

Arguments

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

XML file.

private pure subroutine find_matching_end_tag(source, start_pos, tag_name, end_pos)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: source

Source containing tag content.

integer(kind=I4P), intent(in) :: start_pos

Start tag content position.

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

Tag name.

integer(kind=I4P), intent(out) :: end_pos

End tag position.

private pure subroutine get_tag_content(source, tag_name, start_pos, content, end_pos)

Get tag content.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: source

Source containing tag content.

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

Tag name.

integer, intent(in) :: start_pos

Start tag content position.

character(len=:), intent(out), allocatable :: content

Extracted tag content.

integer(kind=I4P), intent(out), optional :: end_pos

End tag content position.

private pure subroutine parse_tag_name(tag_str, tag_name, attributes_str, is_closing, is_self_closing)

Parse current tag, only name and attributes.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: tag_str

Tag string.

character(len=:), intent(out), allocatable :: tag_name

Parsed tag name.

character(len=:), intent(out), allocatable :: attributes_str

Parsed attributes list.

logical, intent(out) :: is_closing

Sentinel for closing tag.

logical, intent(out) :: is_self_closing

Sentinel for self closing tag.