fdoc

subroutineadd_valueprivate

subroutine add_value(meta, key, value, current)

Add a value for key, whose position in meta%items is returned in current.

Arguments

NameTypeIntentAttributesDescription
metatype(metadata_t)inout

the metadata

keycharacter(len=*)in

the key

valuecharacter(len=*)in

the value

currentintegerout

the item for key

Calls

Source

Show the code
subroutine add_value(meta, key, value, current)
    type(metadata_t), intent(inout) :: meta !! the metadata
    character(len=*), intent(in) :: key     !! the key
    character(len=*), intent(in) :: value   !! the value
    integer, intent(out) :: current         !! the item for `key`
    type(meta_item_t), allocatable :: items(:)
    integer :: k

    do k = 1, size(meta%items)
        if (meta%items(k)%key == key) then
            current = k
            call push(meta%items(k)%values, value)
            return
        end if
    end do
    allocate (items(size(meta%items) + 1))
    do k = 1, size(meta%items)
        call move_alloc(meta%items(k)%key, items(k)%key)
        call move_alloc(meta%items(k)%values, items(k)%values)
    end do
    current = size(items)
    items(current)%key = key
    call push(items(current)%values, value)
    call move_alloc(items, meta%items)
end subroutine add_value

Graphs

Calls

Called by