cable_yaml_node_t Derived Type

type, public :: cable_yaml_node_t

A node of a parsed YAML document.


Components

Type Visibility Attributes Name Initial
integer, public :: node_kind = CABLE_YAML_UNDEFINED

One of the CABLE_YAML_* kind constants.

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

The mapping key this node was found under. Unallocated for the root node and for sequence items.

character(len=:), public, allocatable :: text

The scalar value as text. Only allocated for scalar nodes.

type(cable_yaml_node_t), public, allocatable :: children(:)

Mapping values (in file order) or sequence items.


Type-Bound Procedures

procedure, public :: copy_node

generic, public :: assignment(=) => copy_node

procedure, public :: is_scalar => node_is_scalar

  • private pure function node_is_scalar(this)

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value logical

procedure, public :: is_mapping => node_is_mapping

procedure, public :: is_sequence => node_is_sequence

procedure, public :: size => node_size

  • private pure function node_size(this)

    Number of children of a mapping or sequence. Zero for scalars.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value integer

procedure, public :: has => node_has

  • private pure function node_has(this, key)

    Whether this node is a mapping containing key.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value logical

procedure, public :: get => node_get

  • private function node_get(this, key) result(child)

    The value stored under key. Aborts if this node has no such key.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value type(cable_yaml_node_t)

procedure, public :: at => node_at

  • private function node_at(this, child_index) result(child)

    The child_index-th child (1-based) of a mapping or sequence.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    integer, intent(in) :: child_index

    Return Value type(cable_yaml_node_t)

procedure, public :: as_string => node_as_string

  • private function node_as_string(this) result(text)

    The text of a scalar node. Aborts for mappings and sequences.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value character(len=:), allocatable

procedure, public :: as_integer => node_as_integer

  • private function node_as_integer(this) result(value)

    The scalar value as an integer. Aborts if it is not one.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value integer

procedure, public :: as_real => node_as_real

  • private function node_as_real(this) result(value)

    The scalar value as a real. Aborts if it is not one.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value real

procedure, public :: as_logical => node_as_logical

  • private function node_as_logical(this) result(value)

    The scalar value as a logical (true or false). Aborts otherwise.

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this

    Return Value logical

procedure, public :: get_string => node_get_string

  • private function node_get_string(this, key) result(text)

    Shorthand for this%get(key)%as_string().

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value character(len=:), allocatable

procedure, public :: get_integer => node_get_integer

  • private function node_get_integer(this, key) result(value)

    Shorthand for this%get(key)%as_integer().

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value integer

procedure, public :: get_real => node_get_real

  • private function node_get_real(this, key) result(value)

    Shorthand for this%get(key)%as_real().

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value real

procedure, public :: get_logical => node_get_logical

  • private function node_get_logical(this, key) result(value)

    Shorthand for this%get(key)%as_logical().

    Arguments

    Type IntentOptional Attributes Name
    class(cable_yaml_node_t), intent(in) :: this
    character(len=*), intent(in) :: key

    Return Value logical