From 738833d70c8d6cca3bbf9efe0c8dd24ed0395dde Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 12 May 2021 09:19:59 -0400 Subject: Added post handling to the captain. Improved the query utilities for extracting values from a query string. Added a redirect template for html. --- captain/queryutils.f90 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'captain/queryutils.f90') diff --git a/captain/queryutils.f90 b/captain/queryutils.f90 index c6b5d83..5e97023 100644 --- a/captain/queryutils.f90 +++ b/captain/queryutils.f90 @@ -24,6 +24,10 @@ implicit none procedure :: init => query_init procedure :: destroy => query_destroy procedure :: component_count => query_component_count + procedure :: get_value_by_index => get_query_value_from_index + procedure :: get_value_by_key => get_query_value_from_key + + generic, public :: get_value => get_value_by_index, get_value_by_key end type query @@ -173,4 +177,34 @@ contains end subroutine query_destroy + function get_query_value_from_index(self, i) result(res) + implicit none + + class(query), intent(in)::self + integer, intent(in)::i + character(len=:), pointer::res + + if(i <= self%component_count()) then + res => self%components(i)%value + end if + + end function get_query_value_from_index + + function get_query_value_from_key(self, k) result(res) + implicit none + + class(query), intent(in)::self + character(len=*), intent(in)::k + character(len=:), pointer::res + + integer::i + + do i = 1, self%component_count() + if(associated(self%components(i)%key) .and. self%components(i)%key == trim(k)) then + res => get_query_value_from_index(self, i) + end if + end do + + end function get_query_value_from_key + end module query_utilities -- cgit v1.2.3