toml_keyval Derived Type

type, public, extends(toml_value) :: toml_keyval

TOML key-value pair


Components

Type Visibility Attributes Name Initial
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

integer, public :: origin_value = 0

Origin of value

class(generic_value), public, allocatable :: val

Actual TOML value


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 key-value pair

  • private subroutine destroy(self)

    Deconstructor to cleanup allocations (optional)

    Arguments

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

    Instance of the TOML key-value pair

generic, public :: get => get_float, get_integer, get_boolean, get_datetime, get_string

Get the value stored in the key-value pair

  • private subroutine get_float(self, val)

    Obtain real value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    real(kind=tfr), intent(out), pointer :: val

    Value to be assigned

  • private subroutine get_integer(self, val)

    Obtain integer value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    integer(kind=tfi), intent(out), pointer :: val

    Value to be assigned

  • private subroutine get_boolean(self, val)

    Obtain boolean value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    logical, intent(out), pointer :: val

    Value to be assigned

  • private subroutine get_datetime(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    type(toml_datetime), intent(out), pointer :: val

    Value to be assigned

  • private subroutine get_string(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    character(kind=tfc, len=:), intent(out), pointer :: val

    Value to be assigned

procedure, public :: get_boolean

  • private subroutine get_boolean(self, val)

    Obtain boolean value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    logical, intent(out), pointer :: val

    Value to be assigned

procedure, public :: get_datetime

  • private subroutine get_datetime(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    type(toml_datetime), intent(out), pointer :: val

    Value to be assigned

procedure, public :: get_float

  • private subroutine get_float(self, val)

    Obtain real value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    real(kind=tfr), intent(out), pointer :: val

    Value to be assigned

procedure, public :: get_integer

  • private subroutine get_integer(self, val)

    Obtain integer value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    integer(kind=tfi), intent(out), pointer :: val

    Value to be assigned

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_string

  • private subroutine get_string(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    character(kind=tfc, len=:), intent(out), pointer :: val

    Value to be assigned

procedure, public :: get_type

Get the type of the value stored in the key-value pair

  • private pure function get_type(self) result(value_type)

    Get the type of the value stored in the key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    Return Value integer

    Value type

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

generic, public :: set => set_float, set_integer, set_boolean, set_datetime, set_string

Set the value for the key-value pair

  • private subroutine set_float(self, val)

    Obtain real value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    real(kind=tfr), intent(in) :: val

    Value to be assigned

  • private subroutine set_integer(self, val)

    Obtain integer value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    integer(kind=tfi), intent(in) :: val

    Value to be assigned

  • private subroutine set_boolean(self, val)

    Obtain boolean value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    logical, intent(in) :: val

    Value to be assigned

  • private subroutine set_datetime(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    type(toml_datetime), intent(in) :: val

    Value to be assigned

  • private subroutine set_string(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

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

    Value to be assigned

procedure, public :: set_boolean

  • private subroutine set_boolean(self, val)

    Obtain boolean value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    logical, intent(in) :: val

    Value to be assigned

procedure, public :: set_datetime

  • private subroutine set_datetime(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    type(toml_datetime), intent(in) :: val

    Value to be assigned

procedure, public :: set_float

  • private subroutine set_float(self, val)

    Obtain real value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    real(kind=tfr), intent(in) :: val

    Value to be assigned

procedure, public :: set_integer

  • private subroutine set_integer(self, val)

    Obtain integer value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

    integer(kind=tfi), intent(in) :: val

    Value to be assigned

procedure, public :: set_string

  • private subroutine set_string(self, val)

    Obtain datetime value from TOML key-value pair

    Arguments

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

    Instance of the TOML key-value pair

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

    Value to be assigned

Source Code

   type, extends(toml_value) :: toml_keyval

      !> Actual TOML value
      class(generic_value), allocatable :: val

      !> Origin of value
      integer :: origin_value = 0

   contains

      !> Get the value stored in the key-value pair
      generic :: get => get_float, get_integer, get_boolean, get_datetime, get_string
      procedure :: get_float
      procedure :: get_integer
      procedure :: get_boolean
      procedure :: get_datetime
      procedure :: get_string

      !> Set the value for the key-value pair
      generic :: set => set_float, set_integer, set_boolean, set_datetime, set_string
      procedure :: set_float
      procedure :: set_integer
      procedure :: set_boolean
      procedure :: set_datetime
      procedure :: set_string

      !> Get the type of the value stored in the key-value pair
      procedure :: get_type

      !> Release allocation hold by TOML key-value pair
      procedure :: destroy

   end type toml_keyval