@@ -61,16 +61,15 @@ module json_file_module
61
61
62
62
private
63
63
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.
69
65
type (json_value),pointer :: p = > null () ! ! the JSON structure read from the file
70
66
71
67
contains
72
68
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
74
73
75
74
procedure ,public :: load_file = > json_file_load
76
75
@@ -112,9 +111,20 @@ module json_file_module
112
111
json_file_update_string_val_ascii
113
112
#endif
114
113
114
+ ! traverse
115
+ procedure ,public :: traverse = > json_file_traverse
116
+
117
+ ! ***************************************************
118
+ ! private routines
119
+ ! ***************************************************
120
+
115
121
! load from string:
116
122
procedure :: MAYBEWRAP(json_file_load_from_string)
117
123
124
+ ! initialize
125
+ procedure :: initialize_json_core_in_file
126
+ procedure :: set_json_core_in_file
127
+
118
128
! git info:
119
129
procedure :: MAYBEWRAP(json_file_variable_info)
120
130
@@ -145,9 +155,6 @@ module json_file_module
145
155
procedure :: json_file_print_1
146
156
procedure :: json_file_print_2
147
157
148
- ! traverse
149
- procedure ,public :: traverse = > json_file_traverse
150
-
151
158
end type json_file
152
159
! *********************************************************
153
160
@@ -289,6 +296,44 @@ subroutine initialize_json_core_in_file(me,verbose,compact_reals,&
289
296
end subroutine initialize_json_core_in_file
290
297
! *****************************************************************************************
291
298
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
+
292
337
! *****************************************************************************************
293
338
! > author: Izaak Beekman
294
339
! date: 07/23/2015
0 commit comments