toml_array Derived Type

type, public, extends(toml_value) :: toml_array

TOML array


Components

Type Visibility Attributes Name Initial
logical, public :: inline = .true.

Is an inline array rather than an array of tables

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_array

Create standard constructor

  • private function new_array_func() result(self)

    Default constructor for TOML array type

    Arguments

    None

    Return Value type(toml_array)

    Instance of the TOML array


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 :: destroy

Release allocation hold by TOML array

  • private subroutine destroy(self)

    Deconstructor to cleanup allocations (optional)

    Arguments

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

    Instance of the TOML array

procedure, public :: get

Get the TOML value at a given index

  • private subroutine get(self, idx, ptr)

    Get the TOML value at the respective index

    Arguments

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

    Instance of the TOML array

    integer, intent(in) :: idx

    Index 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 :: 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 the last element from the array

  • private subroutine pop(self, val)

    Remove the last element from the data structure

    Arguments

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

    Instance of the TOML array

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

    TOML value to be retrieved

procedure, public :: push_back

Append value to array

  • private subroutine push_back(self, val, stat)

    Push back a TOML value to the array

    Arguments

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

    Instance of the TOML array

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

    TOML value to append to array

    integer, intent(out) :: stat

    Status of operation

procedure, public :: shift

Remove the first element from the array

  • private subroutine shift(self, val)

    Remove the first element from the data structure

    Arguments

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

    Instance of the TOML array

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

    TOML value to be retrieved

Source Code

   type, extends(toml_value) :: toml_array

      !> Is an inline array rather than an array of tables
      logical :: inline = .true.

      !> Storage unit for TOML values of this array
      class(toml_list_structure), allocatable, private :: list

   contains

      !> Get the TOML value at a given index
      procedure :: get

      !> Append value to array
      procedure :: push_back

      !> Remove the first element from the array
      procedure :: shift

      !> Remove the last element from the array
      procedure :: pop

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

   end type toml_array