Skip to content

Commit 99479cf

Browse files
committed
added get/set routines for the json_core in a json_file
core no longer public in json_file (reverts change made in previous commit)
1 parent 6b426df commit 99479cf

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed

src/json_file_module.F90

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ module json_file_module
6161

6262
private
6363

64-
type(json_core),public :: core !! The instance of the [[json_core]]
65-
!! factory used for this file.
66-
!! Note that this is public, so it can
67-
!! also be used by the user.
68-
64+
type(json_core) :: core !! The instance of the [[json_core]] factory used for this file.
6965
type(json_value),pointer :: p => null() !! the JSON structure read from the file
7066

7167
contains
7268

73-
procedure,public :: initialize => initialize_json_core_in_file
69+
generic,public :: initialize => initialize_json_core_in_file,&
70+
set_json_core_in_file
71+
72+
procedure,public :: get_core => get_json_core_in_file
7473

7574
procedure,public :: load_file => json_file_load
7675

@@ -112,9 +111,20 @@ module json_file_module
112111
json_file_update_string_val_ascii
113112
#endif
114113

114+
!traverse
115+
procedure,public :: traverse => json_file_traverse
116+
117+
! ***************************************************
118+
! private routines
119+
! ***************************************************
120+
115121
!load from string:
116122
procedure :: MAYBEWRAP(json_file_load_from_string)
117123

124+
!initialize
125+
procedure :: initialize_json_core_in_file
126+
procedure :: set_json_core_in_file
127+
118128
!git info:
119129
procedure :: MAYBEWRAP(json_file_variable_info)
120130

@@ -145,9 +155,6 @@ module json_file_module
145155
procedure :: json_file_print_1
146156
procedure :: json_file_print_2
147157

148-
!traverse
149-
procedure,public :: traverse => json_file_traverse
150-
151158
end type json_file
152159
!*********************************************************
153160

@@ -289,6 +296,44 @@ subroutine initialize_json_core_in_file(me,verbose,compact_reals,&
289296
end subroutine initialize_json_core_in_file
290297
!*****************************************************************************************
291298

299+
!*****************************************************************************************
300+
!>
301+
! Set the [[json_core]] for this [[json_file]].
302+
!
303+
!@note: This does not destroy the data in the file.
304+
!
305+
!@note: This one is used if you want to initialize the file with
306+
! an already-existing [[json_core]] (presumably, this was already
307+
! initialized by a call to [[initialize_json_core]] or similar).
308+
309+
subroutine set_json_core_in_file(me,core)
310+
311+
implicit none
312+
313+
class(json_file),intent(inout) :: me
314+
type(json_core),intent(in) :: core
315+
316+
me%core = core
317+
318+
end subroutine set_json_core_in_file
319+
!*****************************************************************************************
320+
321+
!*****************************************************************************************
322+
!>
323+
! Get a copy of the [[json_core]] in this [[json_file]].
324+
325+
subroutine get_json_core_in_file(me,core)
326+
327+
implicit none
328+
329+
class(json_file),intent(in) :: me
330+
type(json_core),intent(out) :: core
331+
332+
core = me%core
333+
334+
end subroutine get_json_core_in_file
335+
!*****************************************************************************************
336+
292337
!*****************************************************************************************
293338
!> author: Izaak Beekman
294339
! date: 07/23/2015

0 commit comments

Comments
 (0)