Skip to content

Commit a8a6d9b

Browse files
committed
feat(string_t): add get_string_with_character_key
This commit adds a specific type-bound procedure for the string_t get_json_value generic binding. This procedure finishes out the possible combinations of a string_t or character key with a string_t or character mold/result-value.
1 parent 5048c3d commit a8a6d9b

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

src/julienne/julienne_string_m.f90

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ module julienne_string_m
2626
generic :: operator(/=) => string_t_ne_string_t, string_t_ne_character, character_ne_string_t
2727
generic :: operator(==) => string_t_eq_string_t, string_t_eq_character, character_eq_string_t
2828
generic :: assignment(= ) => assign_string_t_to_character, assign_character_to_string_t
29-
generic :: get_json_value => get_string, get_string_t_array_with_character_key, get_string_t_array_with_string_t_key &
29+
generic :: get_json_value => get_string_with_string_key &
30+
,get_character_with_string_key, get_character_with_character_key &
31+
,get_string_t_array_with_character_key, get_string_t_array_with_string_t_key &
3032
,get_real, get_real_with_character_key &
31-
,get_character, get_character_with_character_key &
3233
,get_logical, get_logical_with_character_key &
3334
,get_real_array ,get_real_array_with_character_key &
3435
,get_integer_array, get_integer_array_with_character_key &
3536
,get_integer, get_integer_with_character_key &
3637
,get_double_precision, get_double_precision_with_character_key &
3738
,get_double_precision_array, get_double_precision_array_with_character_key
39+
procedure, private :: get_string_with_string_key
40+
procedure, private :: get_character_with_string_key, get_character_with_character_key
41+
procedure, private :: get_string_t_array_with_character_key, get_string_t_array_with_string_t_key
3842
procedure, private :: get_real, get_real_with_character_key
39-
procedure, private :: get_string, get_string_t_array_with_character_key, get_string_t_array_with_string_t_key
4043
procedure, private :: get_logical, get_logical_with_character_key
4144
procedure, private :: get_integer, get_integer_with_character_key
4245
procedure, private :: get_real_array, get_real_array_with_character_key
4346
procedure, private :: get_integer_array, get_integer_array_with_character_key
44-
procedure, private :: get_character, get_character_with_character_key
4547
procedure, private :: get_double_precision, get_double_precision_with_character_key
4648
procedure, private :: get_double_precision_array, get_double_precision_array_with_character_key
4749
procedure, private :: string_t_ne_string_t, string_t_ne_character
@@ -250,7 +252,7 @@ pure module function get_double_precision_array_with_character_key(self, key, mo
250252
double precision, allocatable :: value_(:)
251253
end function
252254

253-
pure module function get_character(self, key, mold) result(value_)
255+
pure module function get_character_with_string_key(self, key, mold) result(value_)
254256
implicit none
255257
class(string_t), intent(in) :: self, key
256258
character(len=*), intent(in) :: mold
@@ -264,12 +266,19 @@ pure module function get_character_with_character_key(self, key, mold) result(va
264266
character(len=:), allocatable :: value_
265267
end function
266268

267-
elemental module function get_string(self, key, mold) result(value_)
269+
elemental module function get_string_with_string_key(self, key, mold) result(value_)
268270
implicit none
269271
class(string_t), intent(in) :: self, key, mold
270272
type(string_t) :: value_
271273
end function
272274

275+
elemental module function get_string_with_character_key(self, key, mold) result(value_)
276+
implicit none
277+
class(string_t), intent(in) :: self, mold
278+
character(len=*), intent(in) :: key
279+
type(string_t) :: value_
280+
end function
281+
273282
pure module function get_string_t_array_with_string_t_key(self, key, mold) result(value_)
274283
implicit none
275284
class(string_t), intent(in) :: self

src/julienne/julienne_string_s.F90

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,20 @@
220220

221221
end procedure
222222

223-
module procedure get_character
224-
associate(string_value => self%get_string(key, string_t(mold)))
223+
module procedure get_character_with_string_key
224+
associate(string_value => self%get_string_with_string_key(key, string_t(mold)))
225225
value_ = string_value%string()
226226
end associate
227227
end procedure
228228

229229
module procedure get_character_with_character_key
230-
associate(string_value => self%get_string(string_t(key), string_t(mold)))
230+
associate(string_value => self%get_string_with_string_key(string_t(key), string_t(mold)))
231+
value_ = string_value%string()
232+
end associate
233+
end procedure
234+
235+
module procedure get_string_with_character_key
236+
associate(string_value => self%get_string_with_string_key(string_t(key), mold))
231237
value_ = string_value%string()
232238
end associate
233239
end procedure
@@ -265,7 +271,7 @@
265271
end associate
266272
end procedure
267273

268-
module procedure get_string
274+
module procedure get_string_with_string_key
269275

270276
character(len=:), allocatable :: raw_line
271277

test/modules/string_test_m.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function results() result(test_results)
7878
#else
7979
! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
8080
procedure(diagnosis_function_i), pointer :: &
81-
,check_allocation_ptr => check_allocation &
81+
check_allocation_ptr => check_allocation &
8282
,extracts_key_ptr => extracts_key &
8383
,extracts_double_precision_value_ptr => extracts_double_precision_value &
8484
,extracts_real_value_ptr => extracts_real_value &

0 commit comments

Comments
 (0)