Publishing project from SPIN to public
[platform/core/convergence/remote-rsc-svc.git] / src / common / schema.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _SCHEMA_H_
19 #define _SCHEMA_H_
20
21 #include "rrs_error.h"
22 #include "rrs_main.h"
23
24 /**
25  * @ingroup     CAPI_RRS_MODULE
26  * @defgroup    CAPI_RRS_SCHEMA_MODULE Schema and data
27  *
28  * @file rrs_schema.h
29  * @brief This file contains the RRS Schema API
30  * @addtogroup CAPI_RRS_SCHEMA_MODULE
31  * @{
32  * @brief This provides APIs related to resource schema and data
33  */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39
40 /**
41  * @brief       Handle of the resource schema.
42  * @details The schema handle can be created or loaded from the schema storage.
43  * @since_tizen 3.0
44  *
45  * @remarks To release the handle use rrs_schema_destroy().
46  *
47  * @par Example
48  * @code
49  * @endcode
50  *
51  * @see rrs_schema_create()
52  * @see rrs_schema_create_from_json()
53  * @see rrs_schema_create_from_simple_json()
54  * @see rrs_schema_data_create_from_json()
55  * @see rrs_schema_load()
56  * @see rrs_schema_load_custom()
57  */
58 typedef void *rrs_schema_h;
59
60
61 /**
62  * @brief       Handle of the resource schema.
63  * @details The schema handle can be created or loaded from the schema storage.
64  * @since_tizen 3.0
65  *
66  * @remarks To release the handle use rrs_schema_destroy().
67  *
68  * @par Example
69  * @code
70  * @endcode
71  *
72  * @see rrs_schema_create_data()
73  * @see rrs_data_destroy()
74  */
75 typedef void *rrs_data_h;
76
77
78 /**
79  * @brief       Enumerations of schemas field types, supported by RRS
80  * @since_tizen 3.0
81  */
82 typedef enum _rrs_schema_type_e {
83         RRS_SCHEMA_TYPE_NONE,   /**< Indicates no type */
84         RRS_SCHEMA_TYPE_BOOL,   /**< Indicates boolean type */
85         RRS_SCHEMA_TYPE_INT,    /**< Indicates integer type */
86         RRS_SCHEMA_TYPE_DOUBLE, /**< Indicates floating point type */
87         RRS_SCHEMA_TYPE_STR,    /**< Indicates string type */
88         RRS_SCHEMA_TYPE_COMPLEX /**< Indicates complex type */
89 } RrsSchemaType;
90
91
92 /**
93  * @brief       Enumerations of schema field access types, supported by RRS
94  * @since_tizen 3.0
95  */
96 typedef enum _rrs_schema_access_e {
97         RRS_SCHEMA_ACCESS_NONE = 0,                     /**< Indicates no access */
98         RRS_SCHEMA_ACCESS_READ = 1,                     /**< Indicates read only access */
99         RRS_SCHEMA_ACCESS_WRITE = 2,            /**< Indicates write only acccess */
100         RRS_SCHEMA_ACCESS_READ_WRITE = 4,       /**< Indicates read-write access */
101         RRS_SCHEMA_ACCESS_ALL = 8                       /**< Indicates all access */
102 } RrsSchemaAccess;
103
104
105
106 /**
107  * @brief       Called when requesting fields of schema.
108  * @details This callback is invoked while iterating through the list of
109  * fields of the schema.
110  * @since_tizen 3.0
111  *
112  * @remarks @a name must not be released using free().
113  *
114  * @param[in]   index           The current index of the field
115  * @param[in]   total           The total amount of the fields
116  * @param[in]   name            The name of the field
117  * @param[in]   type            The type of the field
118  * @param[in]   access          The type of the field access, read, write,
119  * read-write
120  * @param[in]   required        The value is required
121  * @param[in]   user_data       The user data passed from
122  * rrs_schema_foreach_field()
123  * @return      @c true to continue with the next iteration of the loop, \n @c
124  * false to break out of the loop
125  *
126  * @pre rrs_schema_foreach_field() will invoke this callback.
127  *
128  * @see rrs_schema_foreach_field()
129  */
130 typedef bool (*rrs_schema_foreach_field_cb) (int index,
131                                              int total,
132                                              const char *name,
133                                              const RrsSchemaType type,
134                                              const RrsSchemaAccess access,
135                                              const bool required,
136                                              const rrs_schema_h schema,
137                                              void *user_data);
138
139
140 /**
141  * @brief       Called when requesting fields of data.
142  * @details This callback is invoked while iterating through the list of
143  * fields of the data.
144  * @since_tizen 3.0
145  *
146  * @remarks @a name must not be released using free().
147  * \n @a field must be released using free().
148  *
149  * @param[in]   index           The current index of the field
150  * @param[in]   total           The total amount of the fields
151  * @param[in]   name            The name of the field
152  * @param[in]   type            The type of the field
153  * @param[in]   access          The type of the field access, read, write,
154  * read-write
155  * @param[in]   required        The value is required
156  * @param[in]   v               The value the field
157  * @param[in]   user_data       The user data passed from
158  * rrs_data_foreach_field()
159  * @return      @c true to continue with the next iteration of the loop, \n @c
160  * false to break out of the loop
161  *
162  * @pre rrs_data_foreach_field() will invoke this callback.
163  *
164  * @see rrs_data_foreach_field()
165  */
166 typedef bool (*rrs_data_foreach_field_cb) (int index,
167                                            int total,
168                                            const char *name,
169                                            const RrsSchemaType type,
170                                            const RrsSchemaAccess access,
171                                            const bool required,
172                                            void *v,
173                                            void *user_data);
174
175
176 /**
177  * @brief       Creates an empty resource schema.
178  * @details This function creates an empty resource schema and issues a new
179  * handle for it.
180  * @since_tizen 3.0
181  * @privlevel public
182  * @privilege %http://tizen.org/privilege/healthinfo
183  *
184  * @remarks @a schema handle must be released using rrs_schema_destroy().
185  *
186  * @param[in]   rrs             The RRS handle
187  * @param[in]   name            The schema name
188  * @param[out]  schema          The handle of the newly created schema
189  * @return      0 on success, otherwise a negative error value
190  * @retval      #RRS_ERROR_NONE Successful
191  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
192  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
193  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
194  *
195  * @see rrs_schema_destroy()
196  */
197 int rrs_schema_create(const char *name, rrs_schema_h *schema);
198
199
200 /**
201  * @brief       Creates a resource schema handle from complete Json string.
202  * @details This function creates a resource schema from a complete Json schema
203  * definition and issues a new handle for it.
204  * @since_tizen 3.0
205  * @privlevel public
206  * @privilege %http://tizen.org/privilege/healthinfo
207  *
208  * @remarks @a schema handle must be released using rrs_schema_destroy().
209  *
210  * @param[in]   rrs             The RRS handle
211  * @param[in]   json_schema     The complete OIC-compatible json-formatted
212  * definition of schema
213  * @param[out]  schema          The handle of the newly created schema
214  * @return      0 on success, otherwise a negative error value
215  * @retval      #RRS_ERROR_NONE Successful
216  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
217  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
218  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
219  *
220  * @see rrs_schema_destroy()
221  */
222 int rrs_schema_create_from_json(const char *json_schema, rrs_schema_h *schema);
223
224
225 /**
226  * @brief       Creates a resource schema from simplified json string.
227  * @details This function creates a resource schema from simplified json string
228  * and issues a new handle for it.
229  * @since_tizen 3.0
230  * @privlevel public
231  * @privilege %http://tizen.org/privilege/healthinfo
232  *
233  * @remarks @a schema handle must be released using rrs_schema_destroy().
234  *
235  * @param[in]   rrs             The RRS handle
236  * @param[in]   schema_name     The schema name
237  * @param[in]   json_simplified The simplified json-formatted
238  * definition of schema
239  * @param[out]  schema          The handle of the newly created schema
240  * @return      0 on success, otherwise a negative error value
241  * @retval      #RRS_ERROR_NONE Successful
242  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
243  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
244  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
245  *
246  * @see rrs_schema_destroy()
247  */
248 int rrs_schema_create_from_simple_json(const char *schema_name,
249                                        const char *json_simplified,
250                                        rrs_schema_h *schema);
251
252
253 /**
254  * @brief       Creates both resource schema and data from simplified json
255  * string.
256  * @details This function creates both resource schema and data from simplified
257  * json-formatted string and issues new handles for results.
258  * @since_tizen 3.0
259  * @privlevel public
260  * @privilege %http://tizen.org/privilege/healthinfo
261  *
262  * @remarks @a schema handle must be released using rrs_schema_destroy().
263  *
264  * @param[in]   rrs             The RRS handle
265  * @param[in]   schema_name     The schema name
266  * @param[in]   json_simplified The simplified json-formatted
267  * definition of schema
268  * @param[out]  schema          The handle of the newly created schema
269  * @param[out]  data            The handle of the newly created data
270  * @return      0 on success, otherwise a negative error value
271  * @retval      #RRS_ERROR_NONE Successful
272  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
273  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
274  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
275  *
276  * @see rrs_schema_destroy()
277  */
278 int rrs_schema_data_create_from_json(const char *schema_name,
279                                      const char *json_simplified,
280                                      rrs_schema_h *schema,
281                                      rrs_data_h *data);
282
283
284 /**
285  * @brief       Loads a resource schema by specified schema id.
286  * @details This function loads a resource schema by specified schema id and
287  * issues a new handle for it.
288  * @since_tizen 3.0
289  * @privlevel public
290  * @privilege %http://tizen.org/privilege/healthinfo
291  *
292  * @remarks @a schema handle must be released using rrs_schema_destroy().
293  *
294  * @param[in]   rrs             The RRS handle
295  * @param[in]   resource_id     The predefined resource id
296  * @param[out]  schema          The handle of the newly created schema
297  * @return      0 on success, otherwise a negative error value
298  * @retval      #RRS_ERROR_NONE Successful
299  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
300  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
301  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
302  *
303  * @see rrs_schema_destroy()
304  */
305 int rrs_schema_load(const rrs_resource_e resource_id,
306                     rrs_schema_h *control_schema,
307                     rrs_schema_h *event_schema);
308
309
310 /**
311  * @brief       Loads a resource schema by specified schema id.
312  * @details This function loads a resource schema by specified schema id and
313  * issues a new handle for it.
314  * @since_tizen 3.0
315  * @privlevel public
316  * @privilege %http://tizen.org/privilege/healthinfo
317  *
318  * @remarks @a schema handle must be released using rrs_schema_destroy().
319  *
320  * @param[in]   rrs             The RRS handle
321  * @param[in]   resource_id     The predefined resource id
322  * @param[out]  schema          The handle of the newly created schema
323  * @return      0 on success, otherwise a negative error value
324  * @retval      #RRS_ERROR_NONE Successful
325  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
326  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
327  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
328  *
329  * @see rrs_schema_destroy()
330  */
331 int rrs_discovery_schema_load(const rrs_resource_e resource_id,
332                     rrs_schema_h *control_schema);
333
334 /**
335  * @brief       Loads a custom resource schema by schema name.
336  * @details This function loads a custom resource schema by specified schema
337  * name and issues a new handle for it.
338  * @since_tizen 3.0
339  * @privlevel public
340  * @privilege %http://tizen.org/privilege/healthinfo
341  *
342  * @remarks @a schema handle must be released using rrs_schema_destroy().
343  *
344  * @param[in]   rrs             The RRS handle
345  * @param[in]   schema_name     The custom schema name
346  * @param[out]  schema          The handle of the newly created schema
347  * @return      0 on success, otherwise a negative error value
348  * @retval      #RRS_ERROR_NONE Successful
349  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
350  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
351  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
352  *
353  * @see rrs_schema_destroy()
354  */
355 int rrs_schema_load_custom(const char *schema_name,
356                            rrs_schema_h *schema);
357
358
359 /**
360  * @brief       Saves a custom resource schema in permanent schema storage.
361  * @details This function saves a custom resource schema in a permanent
362  * system-wide schema storage.
363  * @since_tizen 3.0
364  * @privlevel public
365  * @privilege %http://tizen.org/privilege/healthinfo
366  *
367  * @remarks @a schema handle must be released using rrs_schema_destroy().
368  *
369  * @param[in]   schema          The custom schema handle
370  * @return      0 on success, otherwise a negative error value
371  * @retval      #RRS_ERROR_NONE Successful
372  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
373  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
374  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
375  *
376  * @see rrs_schema_destroy()
377  */
378 int rrs_schema_save_to_storage(const rrs_schema_h schema);
379
380
381 /**
382  * @brief       Removes a custom resource schema from permanent schema storage.
383  * @details This function removes a custom resource schema from a permanent
384  * system-wide schema storage.
385  * @since_tizen 3.0
386  * @privlevel public
387  * @privilege %http://tizen.org/privilege/healthinfo
388  *
389  * @remarks @a schema handle must be released using rrs_schema_destroy().
390  *
391  * @param[in]   schema_name     The custom schema name
392  * @return      0 on success, otherwise a negative error value
393  * @retval      #RRS_ERROR_NONE Successful
394  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
395  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
396  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
397  *
398  * @see rrs_schema_destroy()
399  */
400 int rrs_schema_delete_from_storage(const char *schema_name);
401
402
403
404 /**
405  * @brief       Destroys the schema handle.
406  * @details This function releases the resource schema handle.
407  * @since_tizen 3.0
408  * @privlevel public
409  * @privilege %http://tizen.org/privilege/healthinfo
410  *
411  * @param[in]   schema          The resource schema handle to destroy
412  * @return      0 on success, otherwise a negative error value
413  * @retval      #RRS_ERROR_NONE Successful
414  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
415  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
416  *
417  * @pre @a schema handle is created with one of create or load functions.
418  *
419  * @see rrs_schema_create()
420  */
421 int rrs_schema_destroy(rrs_schema_h schema);
422
423
424 /**
425  * @brief       Adds new field to the schema.
426  * @details This function adds a new field to the schema.
427  * @since_tizen 3.0
428  *
429  * @param[in]   schema          The schema handle
430  * @param[in]   name            The name of the added field
431  * @param[in]   type            The type of the added field
432  * @param[in]   access          The type of the field access, read, write,
433  * read-write
434  * @param[in]   required        The value is required
435  * @return      0 on success, otherwise a negative error value
436  * @retval      #RRS_ERROR_NONE Successful
437  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
438  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
439  *
440  * @pre @a schema handle is created with one of create or load functions.
441  *
442  * @see rrs_schema_create()
443  * @see #RrsSchemaType
444  */
445 int rrs_schema_add_field(rrs_schema_h schema,
446                          const char *name,
447                          const RrsSchemaType type,
448                          const RrsSchemaAccess access,
449                          const bool required,
450                          const rrs_schema_h complex_schema);
451
452
453 /**
454  * @brief       Retrieves all fields in schema.
455  * @details This function retrieves all fields in the schema.
456  * @since_tizen 3.0
457  * @remarks The fields will be delivered via rrs_schema_foreach_field_cb().
458  *
459  * @param[in]   schema          The schema handle
460  * @param[in]   callback        The callback function to retrieve fields
461  * @param[in]   user_data       The user data to be passed to the
462  * callback function
463  * @return      0 on success, otherwise a negative error value
464  * @retval      #RRS_ERROR_NONE Successful
465  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
466  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
467  *
468  * @post This function invokes rrs_schema_foreach_field_cb()
469  * repeatedly to retrieve each field.
470  *
471  * @see rrs_schema_foreach_field_cb()
472  */
473 int rrs_schema_foreach_field(rrs_schema_h schema,
474                              rrs_schema_foreach_field_cb callback,
475                              void *user_data);
476
477
478 /**
479  * @brief       Creates an instance of structured resource data.
480  * @details This function creates an instance of structured resource data and
481  * issues a new handle for it.
482  * @since_tizen 3.0
483  *
484  * @remarks @a data handle must be released using rrs_data_destroy().
485  *
486  * @param[in]   schema          The handle of schema, defining the data
487  * @param[out]  data            The handle of newly created data instance
488  * @return      0 on success, otherwise a negative error value
489  * @retval      #RRS_ERROR_NONE Successful
490  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
491  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
492  * @retval      #RRS_ERROR_PERMISSION_DENIED Permission Denied
493  *
494  * @see rrs_data_destroy()
495  */
496 int rrs_schema_create_data(const rrs_schema_h schema, rrs_data_h *data);
497
498
499 /**
500  * @brief       Destroys the data handle.
501  * @details This function releases the data handle.
502  * @since_tizen 3.0
503  * @privlevel public
504  * @privilege %http://tizen.org/privilege/healthinfo
505  *
506  * @param[in]   data            The data handle to destroy
507  * @return      0 on success, otherwise a negative error value
508  * @retval      #RRS_ERROR_NONE Successful
509  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
510  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
511  *
512  * @pre @a data handle is created with rrs_schema_create_data() functions.
513  *
514  * @see rrs_schema_create_data()
515  */
516 int rrs_data_destroy(rrs_data_h data);
517
518
519 /**
520  * @brief       Clones the data handle.
521  * @details This function clones the structured data handle @a origin.
522  * @since_tizen 3.0
523  *
524  * @remarks @a cloned must be released using rrs_data_destroy().
525  *
526  * @param[in]   origin          The original data handle
527  * @param[out]  cloned          A cloned data handle
528  * @return      0 on success, otherwise a negative error data
529  * @retval      #RRS_ERROR_NONE Successful
530  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
531  * @retval      #RRS_ERROR_OUT_OF_MEMORY Out of memory
532  *
533  * @see rrs_data_destroy()
534  */
535 int rrs_data_clone(const rrs_data_h origin, rrs_data_h *cloned);
536
537
538 /**
539  * @brief       Extracts event data from resource state data.
540  * @details This function extracts the event data from the remote resource state data.
541  * @since_tizen 3.0
542  */
543 int rrs_convert_control_to_event_data(const rrs_data_h control_data, rrs_data_h *event_data);
544
545
546 /**
547  * @brief       Set boolean field value.
548  * @details This function set the boolean field value.
549  * @since_tizen 3.0
550  *
551  * @param[in]   data            The data handle
552  * @param[in]   name            The name of the field
553  * @param[in]   v               The value of the field
554  * @return      0 on success, otherwise a negative error value
555  * @retval      #RRS_ERROR_NONE Successful
556  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
557  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
558  *
559  * @pre @a data handle is created with rrs_schema_create_data() functions.
560  *
561  * @see rrs_schema_create_data()
562  */
563 int rrs_data_set_bool(rrs_data_h data,
564                             const char *name,
565                             const bool v);
566
567
568 /**
569  * @brief       Set integer field value.
570  * @details This function set the integer field value.
571  * @since_tizen 3.0
572  *
573  * @param[in]   data            The data handle
574  * @param[in]   name            The name of the field
575  * @param[in]   v               The value of the field
576  * @return      0 on success, otherwise a negative error value
577  * @retval      #RRS_ERROR_NONE Successful
578  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
579  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
580  *
581  * @pre @a data handle is created with rrs_schema_create_data() functions.
582  *
583  * @see rrs_schema_create_data()
584  */
585 int rrs_data_set_int(rrs_data_h data,
586                            const char *name,
587                            const int v);
588
589
590 /**
591  * @brief       Set floating point field value.
592  * @details This function set the floating point field value.
593  * @since_tizen 3.0
594  *
595  * @param[in]   data            The data handle
596  * @param[in]   name            The name of the field
597  * @param[in]   v               The value of the field
598  * @return      0 on success, otherwise a negative error value
599  * @retval      #RRS_ERROR_NONE Successful
600  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
601  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
602  *
603  * @pre @a data handle is created with rrs_schema_create_data() functions.
604  *
605  * @see rrs_schema_create_data()
606  */
607 int rrs_data_set_double(rrs_data_h data,
608                               const char *name,
609                               const double v);
610
611
612 /**
613  * @brief       Set string field value.
614  * @details This function set the string field value.
615  * @since_tizen 3.0
616  *
617  * @param[in]   data            The data handle
618  * @param[in]   name            The name of the field
619  * @param[in]   v               The value of the field
620  * @return      0 on success, otherwise a negative error value
621  * @retval      #RRS_ERROR_NONE Successful
622  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
623  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
624  *
625  * @pre @a data handle is created with rrs_schema_create_data() functions.
626  *
627  * @see rrs_schema_create_data()
628  */
629 int rrs_data_set_string(rrs_data_h data,
630                               const char *name,
631                               const char *v);
632
633
634 /**
635  * @brief       Get boolean field value.
636  * @details This function get the boolean field value.
637  * @since_tizen 3.0
638  *
639  * @param[in]   data            The data handle
640  * @param[in]   name            The name of the field
641  * @param[in]   v               The pointer to bool in which to store the
642  * value of the field
643  * @return      0 on success, otherwise a negative error value
644  * @retval      #RRS_ERROR_NONE Successful
645  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
646  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
647  *
648  * @pre @a data handle is created with rrs_schema_create_data() functions.
649  *
650  * @see rrs_schema_create_data()
651  */
652 int rrs_data_get_bool(const rrs_data_h data,
653                             const char *name,
654                             bool *v);
655
656
657 /**
658  * @brief       Get integer field value.
659  * @details This function get the integer field value.
660  * @since_tizen 3.0
661  *
662  * @param[in]   data            The data handle
663  * @param[in]   name            The name of the field
664  * @param[in]   v               The pointer to int in which to store the
665  * value of the field
666  * @return      0 on success, otherwise a negative error value
667  * @retval      #RRS_ERROR_NONE Successful
668  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
669  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
670  *
671  * @pre @a data handle is created with rrs_schema_create_data() functions.
672  *
673  * @see rrs_schema_create_data()
674  */
675 int rrs_data_get_int(const rrs_data_h data,
676                            const char *name,
677                            int *v);
678
679
680 /**
681  * @brief       Get floating point field value.
682  * @details This function get the floating point field value.
683  * @since_tizen 3.0
684  *
685  * @param[in]   data            The data handle
686  * @param[in]   name            The name of the field
687  * @param[in]   v               The pointer to double in which to store the
688  * value of the field
689  * @return      0 on success, otherwise a negative error value
690  * @retval      #RRS_ERROR_NONE Successful
691  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
692  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
693  *
694  * @pre @a data handle is created with rrs_schema_create_data() functions.
695  *
696  * @see rrs_schema_create_data()
697  */
698 int rrs_data_get_double(const rrs_data_h data,
699                               const char *name,
700                               double *v);
701
702
703 /**
704  * @brief       Get string field value.
705  * @details This function get the sting field value.
706  * @since_tizen 3.0
707  *
708  * @remarks Release the value @a v using free.
709  *
710  * @param[in]   data            The data handle
711  * @param[in]   name            The name of the field
712  * @param[in]   v               The pointer to char * in which to store the
713  * value of the field
714  * @return      0 on success, otherwise a negative error value
715  * @retval      #RRS_ERROR_NONE Successful
716  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
717  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
718  *
719  * @pre @a data handle is created with rrs_schema_create_data() functions.
720  *
721  * @see rrs_schema_create_data()
722  */
723 int rrs_data_get_string(const rrs_data_h data,
724                               const char *name,
725                               char **v);
726
727
728 /**
729  * @brief       Retrieves all fields of structured data.
730  * @details This function retrieves all fields of the structured data.
731  * @since_tizen 3.0
732  *
733  * @remarks The fields will be delivered via rrs_data_foreach_field_cb().
734  *
735  * @param[in]   data            The data handle
736  * @param[in]   callback        The callback function to retrieve fields
737  * @param[in]   user_data       The user data to be passed to the
738  * callback function
739  * @return      0 on success, otherwise a negative error value
740  * @retval      #RRS_ERROR_NONE Successful
741  * @retval      #RRS_ERROR_INVALID_PARAMETER Invalid parameter
742  * @retval      #RRS_ERROR_NOT_SUPPORTED Not supported
743  *
744  * @post This function invokes rrs_data_foreach_field_cb()
745  * repeatedly to retrieve each field.
746  *
747  * @see rrs_data_foreach_field_cb()
748  */
749 int rrs_data_foreach_field(const rrs_data_h data,
750                            const rrs_schema_h schema,
751                            rrs_data_foreach_field_cb callback,
752                            void *user_data);
753
754
755 #ifdef __cplusplus
756 }
757 #endif
758 /**
759  * @}
760  */
761 #endif  /* _SCHEMA_H_ */