This module acts as a proxy to the toml-f
public Fortran API and allows
to selectively expose components from the library to fpm
.
The interaction with toml-f
data types outside of this module should be
limited to tables, arrays and key-lists, most of the necessary interactions
are implemented in the building interface with the get_value
and set_value
procedures.
This module allows to implement features necessary for fpm
, which are
not yet available in upstream toml-f
.
For more details on the library used see the TOML-Fortran developer pages.
add_table: fpm interface
Function wrapper to add a toml table and return an fpm error
Nullify pointer
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
Table key |
||
type(toml_table), | intent(out), | pointer | :: | ptr |
The character variable |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
get_value: fpm interface
Function wrapper to get a logical variable from a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
logical, | intent(inout) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to get a default integer variable from a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
integer, | intent(inout) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to get a integer(int64) variable from a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
integer(kind=int64), | intent(inout) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to set a character(len=:), allocatable variable to a toml table
Check the key is not empty
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
List of keys to check. |
||
character(len=*), | intent(in), | optional | :: | var |
The character variable |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to set a character(len=:), allocatable variable to a toml table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
List of keys to check. |
||
type(string_t), | intent(in) | :: | var |
The character variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
set_value: fpm interface
Function wrapper to set a logical variable to a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
logical, | intent(in) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to set a default integer variable to a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
integer, | intent(in) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
Function wrapper to set a default integer variable to a toml table, returning an fpm error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
The key |
||
integer(kind=int64), | intent(in) | :: | var |
The variable |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
|
character(len=*), | intent(in), | optional | :: | whereAt |
Optional description |
An abstract interface for any fpm class that should be fully serializable to/from TOML/JSON
generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit | |
procedure(to_toml), public, deferred :: dump_to_toml | ../../ Dump to TOML table, unit, file |
generic, public :: load => load_from_toml, load_from_file, load_from_unit | |
procedure(from_toml), public, deferred :: load_from_toml | ../../ Load from TOML table, unit, file |
generic, public :: operator(==) => serializable_is_same | |
procedure(is_equal), public, deferred :: serializable_is_same | ../../ Serializable entities need a way to check that they’re equal |
procedure, public, non_overridable :: test_serialization | ../../ Test load/write roundtrip |
Check if an instance of the TOML data structure contains a list
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
Key to read from |
Choose between JSON or TOML based on a file name
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Check if table contains only keys that are part of the list. If a key is found that is not part of the list, an error is allocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | valid_keys(:) |
List of keys to check. |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the TOML data structure |
||
character(len=*), | intent(in) | :: | key |
Key to read from |
||
type(string_t), | intent(out), | allocatable | :: | list(:) |
List of strings to read |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |
Process the configuration file to a TOML data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(out), | allocatable | :: | table |
TOML data structure |
|
character(len=*), | intent(in) | :: | manifest |
Name of the package configuration file |
||
type(error_t), | intent(out), | allocatable | :: | error |
Error status of the operation |
Set no key if array is not present
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(inout) | :: | table |
Instance of the toml table |
||
character(len=*), | intent(in) | :: | key |
Key to save to |
||
type(string_t), | intent(in), | allocatable | :: | list(:) |
Instance of the string array |
|
type(error_t), | intent(out), | allocatable | :: | error |
Error handling |