Skip to content

foxy_xml_file

FoXy XML file class.

Source: src/lib/foxy_xml_file.f90

Dependencies

Contents

Derived Types

xml_file

XML file class.

Components

NameTypeAttributesDescription
tagtype(xml_tag)allocatableXML tags array.
ntinteger(kind=I4P)Number of XML tags.

Type-Bound Procedures

NameAttributesDescription
add_tagpass(self)Add tag to XML file.
contentpass(self)Return tag content of tag named name.
delete_tagpass(self)Add tag from XML file.
freepass(self)Free dynamic memory.
parsepass(self)Parse xml file.
stringifypass(self)Convert the whole file data into a string.
add_childpass(self)Add child ID to tag children list.
parse_from_stringpass(self)Parse xml data from string.
stringify_recursivepass(self)Convert recursively tags with children into a string.

Subroutines

add_tag

Add tag to XML file.

Attributes: elemental

fortran
subroutine add_tag(self, tag)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file.
tagtype(xml_tag)inXML tag.

Call graph

delete_tag

Delete tag from XML file.

Attributes: elemental

fortran
subroutine delete_tag(self, name)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file.
namecharacter(len=*)inXML tag name.

Call graph

free

Free dynamic memory.

Attributes: elemental

fortran
subroutine free(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file.

parse

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

@note Self data are free before trying to parse new xml data: all previously parsed data are lost.

fortran
subroutine parse(self, string, filename)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file.
stringcharacter(len=*)inoptionalString containing xml data.
filenamecharacter(len=*)inoptionalFile name containing xml data.

Call graph

add_child

Add child ID to tag children list.

Attributes: pure

fortran
subroutine add_child(self, parent_id, child_id)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file handler.
parent_idinteger(kind=I4P)inParent ID.
child_idinteger(kind=I4P)inChild ID.

Call graph

parse_from_string

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

Attributes: pure

fortran
subroutine parse_from_string(self, source_string)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inoutXML file handler.
source_stringcharacter(len=*)inString containing xml data.

Call graph

stringify_recursive

Convert recursively tags with children into a string.

Attributes: pure, recursive

fortran
subroutine stringify_recursive(self, tag, is_done, tag_string)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inXML file.
tagtype(xml_tag)inXML tag with children.
is_donelogicalinoutList of stringified tags.
tag_stringcharacter(len=:)inoutallocatableOutput string containing the current tag.

Call graph

finalize

Free dynamic memory when finalizing.

fortran
subroutine finalize(self)

Arguments

NameTypeIntentAttributesDescription
selftype(xml_file)inoutXML file.

find_matching_end_tag

Attributes: pure

fortran
subroutine find_matching_end_tag(source, start_pos, tag_name, end_pos)

Arguments

NameTypeIntentAttributesDescription
sourcecharacter(len=*)inSource containing tag content.
start_posinteger(kind=I4P)inStart tag content position.
tag_namecharacter(len=*)inTag name.
end_posinteger(kind=I4P)outEnd tag position.

Call graph

get_tag_content

Get tag content.

Attributes: pure

fortran
subroutine get_tag_content(source, tag_name, start_pos, content, end_pos)

Arguments

NameTypeIntentAttributesDescription
sourcecharacter(len=*)inSource containing tag content.
tag_namecharacter(len=*)inTag name.
start_posintegerinStart tag content position.
contentcharacter(len=:)outallocatableExtracted tag content.
end_posinteger(kind=I4P)outoptionalEnd tag content position.

Call graph

parse_tag_name

Parse current tag, only name and attributes.

Attributes: pure

fortran
subroutine parse_tag_name(tag_str, tag_name, attributes_str, is_closing, is_self_closing)

Arguments

NameTypeIntentAttributesDescription
tag_strcharacter(len=*)inTag string.
tag_namecharacter(len=:)outallocatableParsed tag name.
attributes_strcharacter(len=:)outallocatableParsed attributes list.
is_closinglogicaloutSentinel for closing tag.
is_self_closinglogicaloutSentinel for self closing tag.

Call graph

Functions

content

Return tag content of tag named name.

@note If there is no value, the tag_content string is returned empty, but allocated.

Attributes: pure

Returns: character(len=:)

fortran
function content(self, name)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inXML file.
namecharacter(len=*)inTag name.

Call graph

stringify

Convert the whole file data into a string.

Attributes: pure

Returns: character(len=:)

fortran
function stringify(self, linearize) result(string)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_file)inXML file.
linearizelogicalinoptionalReturn a "linearized" string of tags without the XML hieararchy.

Call graph

load_file_as_stream

Load file contents and store as single characters stream.

Returns: character(len=:)

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

Arguments

NameTypeIntentAttributesDescription
filenamecharacter(len=*)inFile name.
delimiter_startcharacter(len=*)inoptionalDelimiter from which start the stream.
delimiter_endcharacter(len=*)inoptionalDelimiter to which end the stream.
fast_readlogicalinoptionalFlag for activating efficient reading with one single read.
iostatinteger(kind=I4P)outoptionalIO error.
iomsgcharacter(len=*)outoptionalIO error message.

Call graph