foxy_xml_values
FoXy typed values: conversion of attribute values and tag contents into numbers and logicals.
A text is a list of tokens separated by XML blanks. Each token is converted by StringiFor (string%read_number: correctly rounded, exact range checks, no read statement, the same results with every compiler). An integer token must also be digits with an optional sign, as an XML integer: StringiFor would read 1e3 as 1000.
Logical values are the XML Schema ones: true, false, 1, 0.
Source: src/lib/foxy_xml_values.f90
Dependencies
Contents
- to_value
- to_values
- to_text
- report
- to_value_logical
- to_value_I1P
- to_value_I2P
- to_value_I4P
- to_value_I8P
- to_value_R4P
- to_value_R8P
- to_values_I1P
- to_values_I2P
- to_values_I4P
- to_values_I8P
- to_values_R4P
- to_values_R8P
- to_text_I1P
- to_text_I2P
- to_text_I4P
- to_text_I8P
- to_text_R4P
- to_text_R8P
- to_text_logical
- to_text_I1P_1
- to_text_I2P_1
- to_text_I4P_1
- to_text_I8P_1
- to_text_R4P_1
- to_text_R8P_1
- fail
- next_token
- excerpt
- tokens_number
- is_overflow
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
XML_NOT_FOUND | integer(kind=I4P) | parameter | iostat of a missing tag or attribute. |
XML_BAD_VALUE | integer(kind=I4P) | parameter | iostat of a value that is not of the requested type. |
EXCERPT_LEN | integer(kind=I8P) | parameter | Max length of a token quoted in a message. |
BLANKS | character(len=*) | parameter | XML blanks: space, tab, new line, CR. |
FORMATTED_LEN | integer | parameter | Length of the buffer of a value formatted by fmt. |
INTEGER_CHARS | character(len=*) | parameter | Characters of integer tokens (XML integers). |
Interfaces
to_value
Convert a text holding one value.
Module procedures: to_value_I1P, to_value_I2P, to_value_I4P, to_value_I8P, to_value_R4P, to_value_R8P, to_value_logical
to_values
Convert a text holding a list of values.
Module procedures: to_values_I1P, to_values_I2P, to_values_I4P, to_values_I8P, to_values_R4P, to_values_R8P
to_text
Convert a value, or a list of values, into text.
Module procedures: to_text_I1P, to_text_I2P, to_text_I4P, to_text_I8P, to_text_R4P, to_text_R8P, to_text_logical, to_text_I1P_1, to_text_I2P_1, to_text_I4P_1, to_text_I8P_1, to_text_R4P_1, to_text_R8P_1
Subroutines
report
Report a status (local variables) through the optional iostat and iomsg of a public procedure; the context of a value not converted (e.g. the attribute name) is appended to its message.
@note iomsg is left unchanged on success.
Attributes: pure
subroutine report(iostat_, iomsg_, iostat, iomsg, context)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
iostat_ | integer(kind=I4P) | in | IO status, local variable. | |
iomsg_ | character(len=*) | in | IO message, local variable. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
context | character(len=*) | in | optional | Context of the converted value. |
Call graph
to_value_logical
Convert a text holding one logical value (true, false, 1, 0, blanks around); value is unchanged on error.
Attributes: pure
subroutine to_value_logical(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | logical | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_I1P
Convert a text holding one integer(I1P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_I1P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | integer(kind=I1P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_I2P
Convert a text holding one integer(I2P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_I2P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | integer(kind=I2P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_I4P
Convert a text holding one integer(I4P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_I4P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | integer(kind=I4P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_I8P
Convert a text holding one integer(I8P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_I8P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | integer(kind=I8P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_R4P
Convert a text holding one real(R4P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_R4P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | real(kind=R4P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_value_R8P
Convert a text holding one real(R8P) value; value is unchanged on error.
Attributes: pure
subroutine to_value_R8P(text, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
value | real(kind=R8P) | inout | Value. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_I1P
Convert a text holding a list of integer(I1P) values; values is empty on error.
Attributes: pure
subroutine to_values_I1P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | integer(kind=I1P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_I2P
Convert a text holding a list of integer(I2P) values; values is empty on error.
Attributes: pure
subroutine to_values_I2P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | integer(kind=I2P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_I4P
Convert a text holding a list of integer(I4P) values; values is empty on error.
Attributes: pure
subroutine to_values_I4P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | integer(kind=I4P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_I8P
Convert a text holding a list of integer(I8P) values; values is empty on error.
Attributes: pure
subroutine to_values_I8P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | integer(kind=I8P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_R4P
Convert a text holding a list of real(R4P) values; values is empty on error.
Attributes: pure
subroutine to_values_R4P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | real(kind=R4P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_values_R8P
Convert a text holding a list of real(R8P) values; values is empty on error.
Attributes: pure
subroutine to_values_R8P(text, values, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
values | real(kind=R8P) | out | allocatable | Values. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I1P
Convert an integer(I1P) value into text: its digits, with a sign only if negative, or as formatted by fmt.
Attributes: pure
subroutine to_text_I1P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I1P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I2P
Convert an integer(I2P) value into text: its digits, with a sign only if negative, or as formatted by fmt.
Attributes: pure
subroutine to_text_I2P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I2P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I4P
Convert an integer(I4P) value into text: its digits, with a sign only if negative, or as formatted by fmt.
Attributes: pure
subroutine to_text_I4P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I4P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I8P
Convert an integer(I8P) value into text: its digits, with a sign only if negative, or as formatted by fmt.
Attributes: pure
subroutine to_text_I8P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I8P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_R4P
Convert a real(R4P) value into text: the shortest one that reads back exactly (StringiFor shortest), or as formatted by fmt.
Attributes: pure
subroutine to_text_R4P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | real(kind=R4P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_R8P
Convert a real(R8P) value into text: the shortest one that reads back exactly (StringiFor shortest), or as formatted by fmt.
Attributes: pure
subroutine to_text_R8P(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | real(kind=R8P) | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_logical
Convert a logical value into text: true or false.
Attributes: pure
subroutine to_text_logical(value, text, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | logical | in | Value. | |
text | character(len=:) | out | allocatable | Text. |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
to_text_I1P_1
Convert a list of integer(I1P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_I1P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I1P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I2P_1
Convert a list of integer(I2P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_I2P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I2P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I4P_1
Convert a list of integer(I4P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_I4P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I4P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_I8P_1
Convert a list of integer(I8P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_I8P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | integer(kind=I8P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_R4P_1
Convert a list of real(R4P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_R4P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | real(kind=R4P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
to_text_R8P_1
Convert a list of real(R8P) values into text, separated by one space (each as to_text of a scalar).
Attributes: pure
subroutine to_text_R8P_1(value, text, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
value | real(kind=R8P) | in | Values. | |
text | character(len=:) | out | allocatable | Text. |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
fail
Report a token that is not a value: its first character not allowed, or the whole token.
Attributes: pure
subroutine fail(text, what, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Token. | |
what | character(len=*) | in | Kind of value, integer or real. | |
iostat | integer(kind=I4P) | out | IO status. | |
iomsg | character(len=:) | out | allocatable | IO message. |
Call graph
next_token
Find the next token of a text after the position last: first and last are its positions, first is 0 if there are no more tokens.
Attributes: pure
subroutine next_token(text, last, first)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
last | integer(kind=I8P) | inout | Last position of the previous token on input, of the next token on output. | |
first | integer(kind=I8P) | out | First position of the next token, 0 if none. |
Call graph
Functions
excerpt
Return a token, cut to EXCERPT_LEN characters, to quote it in a message.
Attributes: pure
Returns: character(len=:)
function excerpt(token) result(quoted)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
token | character(len=*) | in | Token. |
Call graph
tokens_number
Return the number of blank-separated tokens of a text.
Attributes: pure
Returns: integer(kind=I8P)
function tokens_number(text) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
Call graph
is_overflow
Return true if a formatted value is all asterisks: the value does not fit the field of the format.
Attributes: pure
Returns: logical
function is_overflow(buffer) result(is_over)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
buffer | character(len=*) | in | Formatted value. |
Call graph