@@ -81,6 +81,20 @@ CppJson <- R6::R6Class(
8181 }
8282 },
8383
84+ # ' @description
85+ # ' Add a scalar to the json object under the name "field_name" (with optional subfolder "subfolder_name")
86+ # ' @param field_name The name of the field to be added to json
87+ # ' @param field_value Integer value of the field to be added to json
88+ # ' @param subfolder_name (Optional) Name of the subfolder / hierarchy under which to place the value
89+ # ' @return NULL
90+ add_integer = function (field_name , field_value , subfolder_name = NULL ) {
91+ if (is.null(subfolder_name )) {
92+ json_add_integer_cpp(self $ json_ptr , field_name , field_value )
93+ } else {
94+ json_add_integer_subfolder_cpp(self $ json_ptr , subfolder_name , field_name , field_value )
95+ }
96+ },
97+
8498 # ' @description
8599 # ' Add a boolean value to the json object under the name "field_name" (with optional subfolder "subfolder_name")
86100 # ' @param field_name The name of the field to be added to json
@@ -110,7 +124,7 @@ CppJson <- R6::R6Class(
110124 },
111125
112126 # ' @description
113- # ' Add an array to the json object under the name "field_name" (with optional subfolder "subfolder_name")
127+ # ' Add a vector to the json object under the name "field_name" (with optional subfolder "subfolder_name")
114128 # ' @param field_name The name of the field to be added to json
115129 # ' @param field_vector Vector to be stored in json
116130 # ' @param subfolder_name (Optional) Name of the subfolder / hierarchy under which to place the value
@@ -124,6 +138,21 @@ CppJson <- R6::R6Class(
124138 }
125139 },
126140
141+ # ' @description
142+ # ' Add an integer vector to the json object under the name "field_name" (with optional subfolder "subfolder_name")
143+ # ' @param field_name The name of the field to be added to json
144+ # ' @param field_vector Vector to be stored in json
145+ # ' @param subfolder_name (Optional) Name of the subfolder / hierarchy under which to place the value
146+ # ' @return NULL
147+ add_integer_vector = function (field_name , field_vector , subfolder_name = NULL ) {
148+ field_vector <- as.numeric(field_vector )
149+ if (is.null(subfolder_name )) {
150+ json_add_integer_vector_cpp(self $ json_ptr , field_name , field_vector )
151+ } else {
152+ json_add_integer_vector_subfolder_cpp(self $ json_ptr , subfolder_name , field_name , field_vector )
153+ }
154+ },
155+
127156 # ' @description
128157 # ' Add an array to the json object under the name "field_name" (with optional subfolder "subfolder_name")
129158 # ' @param field_name The name of the field to be added to json
@@ -184,6 +213,22 @@ CppJson <- R6::R6Class(
184213 return (result )
185214 },
186215
216+ # ' @description
217+ # ' Retrieve a integer value from the json object under the name "field_name" (with optional subfolder "subfolder_name")
218+ # ' @param field_name The name of the field to be accessed from json
219+ # ' @param subfolder_name (Optional) Name of the subfolder / hierarchy under which the field is stored
220+ # ' @return NULL
221+ get_integer = function (field_name , subfolder_name = NULL ) {
222+ if (is.null(subfolder_name )) {
223+ stopifnot(json_contains_field_cpp(self $ json_ptr , field_name ))
224+ result <- json_extract_integer_cpp(self $ json_ptr , field_name )
225+ } else {
226+ stopifnot(json_contains_field_subfolder_cpp(self $ json_ptr , subfolder_name , field_name ))
227+ result <- json_extract_integer_subfolder_cpp(self $ json_ptr , subfolder_name , field_name )
228+ }
229+ return (result )
230+ },
231+
187232 # ' @description
188233 # ' Retrieve a boolean value from the json object under the name "field_name" (with optional subfolder "subfolder_name")
189234 # ' @param field_name The name of the field to be accessed from json
@@ -232,6 +277,22 @@ CppJson <- R6::R6Class(
232277 return (result )
233278 },
234279
280+ # ' @description
281+ # ' Retrieve an integer vector from the json object under the name "field_name" (with optional subfolder "subfolder_name")
282+ # ' @param field_name The name of the field to be accessed from json
283+ # ' @param subfolder_name (Optional) Name of the subfolder / hierarchy under which the field is stored
284+ # ' @return NULL
285+ get_integer_vector = function (field_name , subfolder_name = NULL ) {
286+ if (is.null(subfolder_name )) {
287+ stopifnot(json_contains_field_cpp(self $ json_ptr , field_name ))
288+ result <- json_extract_integer_vector_cpp(self $ json_ptr , field_name )
289+ } else {
290+ stopifnot(json_contains_field_subfolder_cpp(self $ json_ptr , subfolder_name , field_name ))
291+ result <- json_extract_integer_vector_subfolder_cpp(self $ json_ptr , subfolder_name , field_name )
292+ }
293+ return (result )
294+ },
295+
235296 # ' @description
236297 # ' Retrieve a character vector from the json object under the name "field_name" (with optional subfolder "subfolder_name")
237298 # ' @param field_name The name of the field to be accessed from json
0 commit comments