@@ -278,21 +278,21 @@ module json_value_module
278
278
json_value_add_string_vec_val_ascii
279
279
#endif
280
280
281
- procedure ,private :: json_value_add_member
282
- procedure ,private :: MAYBEWRAP(json_value_add_integer)
283
- procedure ,private :: MAYBEWRAP(json_value_add_null)
284
- procedure ,private :: MAYBEWRAP(json_value_add_integer_vec)
285
- procedure ,private :: MAYBEWRAP(json_value_add_double)
286
- procedure ,private :: MAYBEWRAP(json_value_add_double_vec)
287
- procedure ,private :: MAYBEWRAP(json_value_add_logical)
288
- procedure ,private :: MAYBEWRAP(json_value_add_logical_vec)
289
- procedure ,private :: MAYBEWRAP(json_value_add_string)
290
- procedure ,private :: MAYBEWRAP(json_value_add_string_vec)
281
+ procedure ,private :: json_value_add_member
282
+ procedure ,private :: MAYBEWRAP(json_value_add_integer)
283
+ procedure ,private :: MAYBEWRAP(json_value_add_null)
284
+ procedure ,private :: MAYBEWRAP(json_value_add_integer_vec)
285
+ procedure ,private :: MAYBEWRAP(json_value_add_double)
286
+ procedure ,private :: MAYBEWRAP(json_value_add_double_vec)
287
+ procedure ,private :: MAYBEWRAP(json_value_add_logical)
288
+ procedure ,private :: MAYBEWRAP(json_value_add_logical_vec)
289
+ procedure ,private :: MAYBEWRAP(json_value_add_string)
290
+ procedure ,private :: MAYBEWRAP(json_value_add_string_vec)
291
291
#ifdef USE_UCS4
292
- procedure ,private :: json_value_add_string_name_ascii
293
- procedure ,private :: json_value_add_string_val_ascii
294
- procedure ,private :: json_value_add_string_vec_name_ascii
295
- procedure ,private :: json_value_add_string_vec_val_ascii
292
+ procedure ,private :: json_value_add_string_name_ascii
293
+ procedure ,private :: json_value_add_string_val_ascii
294
+ procedure ,private :: json_value_add_string_vec_name_ascii
295
+ procedure ,private :: json_value_add_string_vec_val_ascii
296
296
#endif
297
297
298
298
! >
@@ -625,8 +625,16 @@ module json_value_module
625
625
626
626
! >
627
627
! Rename a [[json_value]] variable.
628
- generic,public :: rename = > MAYBEWRAP(json_value_rename)
628
+ generic,public :: rename = > MAYBEWRAP(json_value_rename),&
629
+ MAYBEWRAP(json_rename_by_path)
629
630
procedure :: MAYBEWRAP(json_value_rename)
631
+ procedure :: MAYBEWRAP(json_rename_by_path)
632
+ #ifdef USE_UCS4
633
+ generic,public :: rename = > json_rename_by_path_name_ascii,&
634
+ json_rename_by_path_path_ascii
635
+ procedure :: json_rename_by_path_name_ascii
636
+ procedure :: json_rename_by_path_path_ascii
637
+ #endif
630
638
631
639
! >
632
640
! get info about a [[json_value]]
@@ -5678,6 +5686,107 @@ subroutine wrap_json_create_by_path(json,me,path,p,found,was_created)
5678
5686
end subroutine wrap_json_create_by_path
5679
5687
! *****************************************************************************************
5680
5688
5689
+ ! *****************************************************************************************
5690
+ ! >
5691
+ ! Rename a [[json_value]], given the path.
5692
+
5693
+ subroutine json_rename_by_path (json , me , path , name , found )
5694
+
5695
+ implicit none
5696
+
5697
+ class(json_core),intent (inout ) :: json
5698
+ type (json_value),pointer ,intent (in ) :: me
5699
+ character (kind= CK,len=* ),intent (in ) :: path
5700
+ character (kind= CK,len=* ),intent (in ) :: name ! ! the new name
5701
+ logical (LK),intent (out ),optional :: found
5702
+
5703
+ type (json_value),pointer :: p
5704
+
5705
+ if ( json% exception_thrown ) then
5706
+ if ( present (found) ) found = .false.
5707
+ return
5708
+ end if
5709
+
5710
+ nullify(p)
5711
+ call json% get(me= me, path= path, p= p)
5712
+
5713
+ if (.not. associated (p)) then
5714
+ call json% throw_exception(' Error in json_rename_by_path:' // &
5715
+ ' Unable to resolve path: ' // trim (path))
5716
+ else
5717
+ call json% rename(p,name)
5718
+ nullify(p)
5719
+ end if
5720
+
5721
+ if (json% exception_thrown) then
5722
+ if (present (found)) then
5723
+ found = .false.
5724
+ call json% clear_exceptions()
5725
+ end if
5726
+ else
5727
+ if (present (found)) found = .true.
5728
+ end if
5729
+
5730
+ end subroutine json_rename_by_path
5731
+ ! *****************************************************************************************
5732
+
5733
+ ! *****************************************************************************************
5734
+ ! >
5735
+ ! Alternate version of [[json_rename_by_path]], where "path" and "name" are kind=CDK
5736
+
5737
+ subroutine wrap_json_rename_by_path (json , me , path , name , found )
5738
+
5739
+ implicit none
5740
+
5741
+ class(json_core),intent (inout ) :: json
5742
+ type (json_value),pointer ,intent (in ) :: me
5743
+ character (kind= CDK,len=* ),intent (in ) :: path
5744
+ character (kind= CDK,len=* ),intent (in ) :: name
5745
+ logical (LK),intent (out ),optional :: found
5746
+
5747
+ call json% rename(me,to_unicode(path),to_unicode(name),found)
5748
+
5749
+ end subroutine wrap_json_rename_by_path
5750
+ ! *****************************************************************************************
5751
+
5752
+ ! *****************************************************************************************
5753
+ ! >
5754
+ ! Alternate version of [[json_rename_by_path]], where "name" is kind=CDK
5755
+
5756
+ subroutine json_rename_by_path_name_ascii (json , me , path , name , found )
5757
+
5758
+ implicit none
5759
+
5760
+ class(json_core),intent (inout ) :: json
5761
+ type (json_value),pointer ,intent (in ) :: me
5762
+ character (kind= CK,len=* ),intent (in ) :: path
5763
+ character (kind= CDK,len=* ),intent (in ) :: name
5764
+ logical (LK),intent (out ),optional :: found
5765
+
5766
+ call json% rename(me,path,to_unicode(name),found)
5767
+
5768
+ end subroutine json_rename_by_path_name_ascii
5769
+ ! *****************************************************************************************
5770
+
5771
+ ! *****************************************************************************************
5772
+ ! >
5773
+ ! Alternate version of [[json_rename_by_path]], where "path" is kind=CDK
5774
+
5775
+ subroutine json_rename_by_path_path_ascii (json , me , path , name , found )
5776
+
5777
+ implicit none
5778
+
5779
+ class(json_core),intent (inout ) :: json
5780
+ type (json_value),pointer ,intent (in ) :: me
5781
+ character (kind= CDK,len=* ),intent (in ) :: path
5782
+ character (kind= CK,len=* ),intent (in ) :: name
5783
+ logical (LK),intent (out ),optional :: found
5784
+
5785
+ call json% rename(me,to_unicode(path),name,found)
5786
+
5787
+ end subroutine json_rename_by_path_path_ascii
5788
+ ! *****************************************************************************************
5789
+
5681
5790
! *****************************************************************************************
5682
5791
! >
5683
5792
! Returns the [[json_value]] pointer given the path string.
0 commit comments