toml_table Derived Type

type, public, extends(toml_value) :: toml_table

TOML table


Components

Type Visibility Attributes Name Initial
logical, public :: implicit = .false.

Table was implictly created

logical, public :: inline = .false.

Is an inline table and is therefore non-extendable

character(kind=tfc, len=:), public, allocatable :: key

Raw representation of the key to the TOML value

integer, public :: origin = 0

Original source of the value


Constructor

public interface toml_table

Create standard constructor

  • private function new_table_func() result(self)

    Default constructor for TOML table type

    Arguments

    None

    Return Value type(toml_table)

    Instance of the TOML table


Type-Bound Procedures

procedure, public :: accept

Accept a visitor to transverse the data structure

  • private recursive subroutine accept(self, visitor)

    Accept a visitor to transverse the data structure

    Arguments

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

    Instance of the TOML value

    class(toml_visitor), intent(inout) :: visitor

    Visitor for this value

procedure, public :: delete

Delete TOML value at a given key

  • private subroutine delete(self, key)

    Delete TOML value at a given key

    Arguments

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

    Instance of the TOML table

    character(kind=tfc, len=*), intent(in) :: key

    Key to the TOML value

procedure, public :: destroy

Release allocation hold by TOML table

  • private subroutine destroy(self)

    Deconstructor to cleanup allocations (optional)

    Arguments

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

    Instance of the TOML table

procedure, public :: get

Get the TOML value associated with the respective key

  • private subroutine get(self, key, ptr)

    Get the TOML value associated with the respective key

    Arguments

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

    Instance of the TOML table

    character(kind=tfc, len=*), intent(in) :: key

    Key to the TOML value

    class(toml_value), intent(out), pointer :: ptr

    Pointer to the TOML value

procedure, public :: get_key

Get escaped key to TOML value

  • private subroutine get_key(self, key)

    Get escaped key to TOML value

    Arguments

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

    TOML value instance.

    character(kind=tfc, len=:), allocatable :: key

    Contains valid TOML key on exit

procedure, public :: get_keys

Get list of all keys in this table

  • private subroutine get_keys(self, list)

    Get list of all keys in this table

    Arguments

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

    Instance of the TOML table

    type(toml_key), intent(out), allocatable :: list(:)

    List of all keys

procedure, public :: has_key

Check if key is already present in this table instance

  • private function has_key(self, key) result(found)

    Check if a key is present in the table

    Arguments

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

    Instance of the TOML table

    character(kind=tfc, len=*), intent(in) :: key

    Key to the TOML value

    Return Value logical

    TOML value is present in table

procedure, public :: match_key

Compare raw key of TOML value to input key

  • private pure function match_key(self, key) result(match)

    Compare raw key of TOML value to input key

    Arguments

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

    TOML value instance.

    character(kind=tfc, len=*), intent(in) :: key

    TOML raw key to compare to

    Return Value logical

procedure, public :: pop

Remove TOML value at a given key and return it

  • private subroutine pop(self, key, val)

    Remove TOML value at a given key and return it

    Arguments

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

    Instance of the TOML table

    character(kind=tfc, len=*), intent(in) :: key

    Key to the TOML value

    class(toml_value), intent(out), allocatable :: val

    Removed TOML value to return

procedure, public :: push_back

Append value to table (checks automatically for key)

  • private subroutine push_back(self, val, stat)

    Push back a TOML value to the table

    Arguments

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

    Instance of the TOML table

    class(toml_value), intent(inout), allocatable :: val

    TOML value to append to table

    integer, intent(out) :: stat

    Status of operation

Source Code

   type, extends(toml_value) :: toml_table

      !> Table was implictly created
      logical :: implicit = .false.

      !> Is an inline table and is therefore non-extendable
      logical :: inline = .false.

      !> Storage unit for TOML values of this table
      class(toml_map_structure), allocatable, private :: map

   contains

      !> Get the TOML value associated with the respective key
      procedure :: get

      !> Get list of all keys in this table
      procedure :: get_keys

      !> Check if key is already present in this table instance
      procedure :: has_key

      !> Append value to table (checks automatically for key)
      procedure :: push_back

      !> Remove TOML value at a given key and return it
      procedure :: pop

      !> Delete TOML value at a given key
      procedure :: delete

      !> Release allocation hold by TOML table
      procedure :: destroy

   end type toml_table