Skip to content

Commit 1cfc389

Browse files
committed
documentation updates. also renamed some internal routines.
1 parent 1ba5d31 commit 1cfc389

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

robodoc.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ keywords:
124124
integer
125125
real
126126
logical
127-
none
127+
none
128+
trim

src/json_module.f90

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ module json_module
223223

224224
private
225225

226-
type(json_value), pointer :: p => null() !the JSON structure read from the file
226+
!the JSON structure read from the file:
227+
type(json_value), pointer :: p => null()
227228

228229
contains
229230

@@ -281,9 +282,9 @@ end subroutine array_callback_func
281282
! Get a child, either by index or name string.
282283
!
283284
! SOURCE
284-
interface json_value_get !consider renaming this json_value_get_child
285-
module procedure get_by_index
286-
module procedure get_by_name_chars
285+
interface json_value_get !consider renaming this json_value_get_child
286+
module procedure json_value_get_by_index
287+
module procedure json_value_get_by_name_chars
287288
end interface json_value_get
288289
!*************************************************************************************
289290

@@ -413,9 +414,7 @@ end subroutine array_callback_func
413414
! json_remove
414415
!
415416
! DESCRIPTION
416-
! Remove and destroy a json_value (and all its children)
417-
! from a linked-list structure.
418-
! The rest of the structure is preserved.
417+
! Remove a json_value from a linked-list structure.
419418
!
420419
! SOURCE
421420
interface json_remove
@@ -1078,7 +1077,7 @@ end subroutine json_clear_exceptions
10781077
!*****************************************************************************************
10791078

10801079
!*****************************************************************************************
1081-
!****f* json_module/throw_exception
1080+
!****if* json_module/throw_exception
10821081
!
10831082
! NAME
10841083
! throw_exception
@@ -1269,9 +1268,9 @@ recursive subroutine json_value_destroy(this)
12691268

12701269
call this%data%destroy()
12711270

1272-
if (associated(this%children)) call json_value_destroy(this%children)
1271+
if (associated(this%children)) call json_value_destroy(this%children)
12731272

1274-
if (associated(this%next)) call json_value_destroy(this%next)
1273+
if (associated(this%next)) call json_value_destroy(this%next)
12751274

12761275
deallocate(this)
12771276

@@ -1290,25 +1289,25 @@ end subroutine json_value_destroy
12901289
!
12911290
! DESCRIPTION
12921291
! Remove a json_value (and all its children)
1293-
! from a linked-list structure, preserving the rest of the structure.
1294-
!
1292+
! from a linked-list structure, preserving the rest of the structure.
12951293
! If destroy is not present, it is also destroyed.
1294+
! If destroy is present and true, it is destroyed.
12961295
! If destroy is present and false, it is not destroyed.
12971296
!
12981297
! EXAMPLE
12991298
!
13001299
! !to extract an object from one json structure, and add it to another:
13011300
! type(json_value),pointer :: json1,json2,p
13021301
! logical :: found
1303-
! ...create json1 and json2
1302+
! [create and populate json1 and json2]
13041303
! call json_get(json1,'name',p,found) ! get pointer to name element of json1
13051304
! call json_remove(p,destroy=.false.) ! remove it from json1 (don't destroy)
13061305
! call json_value_add(json2,p) ! add it to json2
13071306
!
13081307
! !to remove an object from a json structure (and destroy it)
13091308
! type(json_value),pointer :: json1,p
13101309
! logical :: found
1311-
! ...create json1
1310+
! [create and populate json1]
13121311
! call json_get(json1,'name',p,found) ! get pointer to name element of json1
13131312
! call json_remove(p) ! remove and destroy it
13141313
!
@@ -2128,17 +2127,17 @@ end function json_value_count
21282127
!*****************************************************************************************
21292128

21302129
!*****************************************************************************************
2131-
!****f* json_module/get_by_index
2130+
!****f* json_module/json_value_get_by_index
21322131
!
21332132
! NAME
2134-
! get_by_index
2133+
! json_value_get_by_index
21352134
!
21362135
! DESCRIPTION
21372136
! Returns a child in the object given the index.
21382137
!
21392138
! SOURCE
21402139

2141-
subroutine get_by_index(this, idx, p)
2140+
subroutine json_value_get_by_index(this, idx, p)
21422141

21432142
implicit none
21442143

@@ -2161,7 +2160,7 @@ subroutine get_by_index(this, idx, p)
21612160
if (associated(p%next)) then
21622161
p => p%next
21632162
else
2164-
call throw_exception('Error in get_by_index:'//&
2163+
call throw_exception('Error in json_value_get_by_index:'//&
21652164
' p%next is not associated.')
21662165
return
21672166
end if
@@ -2170,28 +2169,28 @@ subroutine get_by_index(this, idx, p)
21702169

21712170
else
21722171

2173-
call throw_exception('Error in get_by_index:'//&
2172+
call throw_exception('Error in json_value_get_by_index:'//&
21742173
' this%children is not associated.')
21752174

21762175
end if
21772176

21782177
end if
21792178

2180-
end subroutine get_by_index
2179+
end subroutine json_value_get_by_index
21812180
!*****************************************************************************************
21822181

21832182
!*****************************************************************************************
2184-
!****f* json_module/get_by_name_chars
2183+
!****f* json_module/json_value_get_by_name_chars
21852184
!
21862185
! NAME
2187-
! get_by_name_chars
2186+
! json_value_get_by_name_chars
21882187
!
21892188
! DESCRIPTION
21902189
! Returns a child in the object given the name string.
21912190
!
21922191
! SOURCE
21932192

2194-
subroutine get_by_name_chars(this, name, p)
2193+
subroutine json_value_get_by_name_chars(this, name, p)
21952194

21962195
implicit none
21972196

@@ -2220,12 +2219,13 @@ subroutine get_by_name_chars(this, name, p)
22202219
nullify(p)
22212220

22222221
else
2223-
call throw_exception('Error in get_by_name_chars: pointer is not associated.')
2222+
call throw_exception('Error in json_value_get_by_name_chars: '//&
2223+
'pointer is not associated.')
22242224
end if
22252225

22262226
end if
22272227

2228-
end subroutine get_by_name_chars
2228+
end subroutine json_value_get_by_name_chars
22292229
!*****************************************************************************************
22302230

22312231
!*****************************************************************************************
@@ -3491,9 +3491,11 @@ end subroutine json_get_char_vec
34913491
! json_get_array
34923492
!
34933493
! DESCRIPTION
3494-
! Get an array from a json_value.
34953494
! This routine calls the user-supplied array_callback subroutine
34963495
! for each element in the array.
3496+
! Note: for integer, double, logical, and character arrays,
3497+
! a higher-level routine is provided (see json_get), so
3498+
! this routine does not have to be used for those cases.
34973499
!
34983500
! SOURCE
34993501

@@ -3537,7 +3539,8 @@ subroutine json_get_array(this, path, array_callback, found)
35373539
end do
35383540
case default
35393541
call throw_exception('Error in json_get_array:'//&
3540-
' Resolved value is not an array. '//trim(path))
3542+
' Resolved value is not an array. '//&
3543+
trim(path))
35413544
end select
35423545
!end associate
35433546

0 commit comments

Comments
 (0)