Release version 0.9.10
[platform/core/base/bundle.git] / include / bundle.h
old mode 100755 (executable)
new mode 100644 (file)
index 9ace22d..0c9d29e
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 extern "C" {
 # endif
 
-#define API __attribute__((visibility("default")))
-#define likely(x) __builtin_expect(x, 1)
-#define unlikely(x) __builtin_expect(x, 0)
-
 /**
  * @brief Enumeration for error codes of Bundle.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
@@ -118,10 +114,10 @@ typedef void (*bundle_iterator_t) (const char *key, const int type, const bundle
  * @brief Creates a bundle object.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
- * @return The bundle object
- * @retval @c NULL - Failure
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ * @return The bundle object,
+ *         @c NULL - Failure
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
  * @see bundle_free()
  *
  * @code
@@ -130,7 +126,7 @@ typedef void (*bundle_iterator_t) (const char *key, const int type, const bundle
  bundle_free(b); // Free the bundle
  * @endcode
  */
-API bundle *bundle_create(void);
+bundle *bundle_create(void);
 
 
 /**
@@ -138,8 +134,8 @@ API bundle *bundle_create(void);
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] b The bundle object to be freed
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a b must be a valid bundle object.
  * @see bundle_create()
  *
@@ -149,7 +145,7 @@ API bundle *bundle_create(void);
  bundle_free(b); // Free the bundle
  * @endcode
  */
-API int bundle_free(bundle *b);
+int bundle_free(bundle *b);
 
 
 /**
@@ -160,10 +156,10 @@ API int bundle_free(bundle *b);
  * @param[in] str_array The string type value; if @c NULL, an empty array is created; you can change an item with
  * @param[in] len The length of the array
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_EXISTS Key already exists
- * @retval BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_EXISTS Key already exists
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
  * @pre @a b must be a valid bundle object.
  * @see bundle_get_str_array()
  *
@@ -175,7 +171,7 @@ API int bundle_free(bundle *b);
  bundle_free(b);
  * @endcode
  */
-API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len);
+int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len);
 
 
 /**
@@ -184,9 +180,9 @@ API int bundle_add_str_array(bundle *b, const char *key, const char **str_array,
  * @param[in] b The bundle object
  * @param[in] key The given key
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
  * @pre @a b must be a valid bundle object.
  *
  * @code
@@ -198,7 +194,7 @@ API int bundle_add_str_array(bundle *b, const char *key, const char **str_array,
  bundle_free(b);
  * @endcode
  */
-API int bundle_del(bundle *b, const char *key);
+int bundle_del(bundle *b, const char *key);
 
 
 /**
@@ -209,11 +205,11 @@ API int bundle_del(bundle *b, const char *key);
  * @param[in] b The bundle object
  * @param[in] key The key
  * @param[out] len The array length
- * @return The pointer to the array of strings
- * @retval @c NULL - Key not found
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @return The pointer to the array of strings,
+ *         @c NULL - Key not found
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
  * @pre @a b must be a valid bundle object.
  * @see bundle_add_str_array()
  *
@@ -232,7 +228,7 @@ API int bundle_del(bundle *b, const char *key);
  bundle_free(b);
  * @endcode
  */
-API const char **bundle_get_str_array(bundle *b, const char *key, int *len);
+const char **bundle_get_str_array(bundle *b, const char *key, int *len);
 
 
 /**
@@ -253,7 +249,7 @@ API const char **bundle_get_str_array(bundle *b, const char *key, int *len);
  bundle_free(b);
  * @endcode
  */
-API int bundle_get_count(bundle *b);
+int bundle_get_count(bundle *b);
 
 
 /**
@@ -263,25 +259,26 @@ API int bundle_get_count(bundle *b);
  * @param[in] b A bundle
  * @param[in] key A key in the bundle
  * @return The type of a key in @a b
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @exception BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
  * @pre @a b must be a valid bundle object.
- * @see bundle_type_t
+ * @see bundle_type
  */
-API int bundle_get_type(bundle *b, const char *key);
+int bundle_get_type(bundle *b, const char *key);
 
 
 /**
  * @brief Duplicates a given bundle object.
  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ *          The returned value should be released using bundle_free().
  * @param[in] b_from The bundle object to be duplicated
- * @return The new bundle object
- * @retval @c NULL - Failure
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre @a b must be a valid bundle object.
+ * @return The new bundle object,
+ *         @c NULL - Failure
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre @a b_from must be a valid bundle object.
  *
  * @code
  #include <bundle.h>
@@ -293,7 +290,7 @@ API int bundle_get_type(bundle *b, const char *key);
  bundle_free(b_dup);
  * @endcode
  */
-API bundle *bundle_dup(bundle *b_from);
+bundle *bundle_dup(bundle *b_from);
 
 
 /**
@@ -305,8 +302,8 @@ API bundle *bundle_dup(bundle *b_from);
  * @param[in] b The bundle object
  * @param[in] iter The iteration callback function
  * @param[in] user_data The data for the callback function
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a b must be a valid bundle object.
  * @see bundle_keyval_get_type()
  * @see bundle_keyval_type_is_array()
@@ -349,7 +346,7 @@ API bundle *bundle_dup(bundle *b_from);
  }
  * @endcode
  */
-API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
+void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
 
 
 /**
@@ -357,14 +354,14 @@ API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
  * @param[in] kv A bundle_keyval_t object
- * @return The type of @a kv
- * @retval @c -1 - Failure
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return The type of @a kv,
+ *         @c -1 - Failure
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a kv must be a valid bundle_keyval_t object.
  * @see bundle_foreach()
  */
-API int bundle_keyval_get_type(bundle_keyval_t *kv);
+int bundle_keyval_get_type(bundle_keyval_t *kv);
 
 
 /**
@@ -373,14 +370,14 @@ API int bundle_keyval_get_type(bundle_keyval_t *kv);
  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
  * @param[in] kv A bundle_keyval_t object
  * @return The operation result
- * @retval @c 1 - @a kv is an array
- * @retval @c 0 - @a kv is not an array
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ *         @c 1 - @a kv is an array
+ *         @c 0 - @a kv is not an array
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a kv must be a valid bundle_keyval_t object.
  * @see bundle_foreach()
  */
-API int bundle_keyval_type_is_array(bundle_keyval_t *kv);
+int bundle_keyval_type_is_array(bundle_keyval_t *kv);
 
 
 /**
@@ -391,13 +388,13 @@ API int bundle_keyval_type_is_array(bundle_keyval_t *kv);
  * @param[out] val The value
  * @param[out] size The size of @a val
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a kv must be a valid bundle_keyval_t object.
  * @post @a val and @a size are set.
  * @see bundle_foreach()
  */
-API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size);
+int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size);
 
 
 /**
@@ -408,13 +405,13 @@ API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *siz
  * @param[out] array_len The length of @a array_val
  * @param[out] array_element_size The array of size of each array element
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a kv must be a valid bundle_keyval_t object.
- * @post @a array_val, @a array_len, @a array_item_size are set.
+ * @post @a array_val, @a array_len, @a array_element_size are set.
  * @see bundle_foreach()
  */
-API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size);
+int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size);
 
 
 /**
@@ -425,8 +422,8 @@ API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsi
  *               @a r MUST BE FREED by free(r)
  * @param[out] len The size of @a r (in bytes)
  * @return The size of the raw data
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
  * @pre @a b must be a valid bundle object.
  *
  * @code
@@ -440,20 +437,21 @@ API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsi
  bundle_free(b);
  * @endcode
  */
-API int bundle_encode(bundle *b, bundle_raw **r, int *len);
+int bundle_encode(bundle *b, bundle_raw **r, int *len);
 
 
 /**
  * @brief Deserializes bundle_raw and gets the bundle object.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ *          The returned value should be released using bundle_free().
  * @param[in] r The bundle_raw data to be converted to bundle object
  * @param[in] len The size of @a r
- * @return The bundle object
- * @retval @c NULL - Failure
- * @exception BUNDLE_ERROR_NONE Success
- * @exception BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre @a b must be a valid bundle object.
+ * @return The bundle object,
+ *         @c NULL - Failure
+ * @exception #BUNDLE_ERROR_NONE Success
+ * @exception #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre @a r must be a valid bundle object.
  *
  * @code
  #include <bundle.h>
@@ -472,7 +470,7 @@ API int bundle_encode(bundle *b, bundle_raw **r, int *len);
  bundle_free(b_dup);
  * @endcode
  */
-API bundle *bundle_decode(const bundle_raw *r, const int len);
+bundle *bundle_decode(const bundle_raw *r, const int len);
 
 
 /**
@@ -482,10 +480,10 @@ API bundle *bundle_decode(const bundle_raw *r, const int len);
  * @param[in] key The key
  * @param[in] str The string type value
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_EXISTS Key already exists
- * @retval BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_EXISTS Key already exists
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
  * @pre @a b must be a valid bundle object.
  * @see bundle_get_str()
  * @code
@@ -496,7 +494,7 @@ API bundle *bundle_decode(const bundle_raw *r, const int len);
  bundle_free(b);
  * @endcode
  */
-API int bundle_add_str(bundle *b, const char *key, const char *str);
+int bundle_add_str(bundle *b, const char *key, const char *str);
 
 
 /**
@@ -508,10 +506,10 @@ API int bundle_add_str(bundle *b, const char *key, const char *str);
  * @param[in] bytes The byte sequence
  * @param[in] size The byte sequence size in bytes
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_EXISTS Key already exists
- * @retval BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_EXISTS Key already exists
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
  * @pre @a b must be a valid bundle object.
  * @see bundle_get_byte()
  *
@@ -526,7 +524,7 @@ API int bundle_add_str(bundle *b, const char *key, const char *str);
  bundle_free(b);
  * @endcode
  */
-API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size);
+int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size);
 
 
 /**
@@ -537,9 +535,9 @@ API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const siz
  * @param[in] key The key
  * @param[out] str The returned value
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
  * @pre @a b must be a valid bundle object.
  * @see bundle_add_str()
  *
@@ -555,21 +553,21 @@ API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const siz
  v = NULL;
  * @endcode
  */
-API int bundle_get_str(bundle *b, const char *key, char **str);
+int bundle_get_str(bundle *b, const char *key, char **str);
 
 
 /**
  * @brief Gets the byte sequence with the given key.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks You must not free @a byte.
+ * @remarks You must not free @a bytes.
  * @param[in] b The bundle object
  * @param[in] key The key
  * @param[out] bytes The byte sequence
  * @param[out] size The byte sequence size in bytes
  * @return The operation result
- * @retval BUNDLE_ERROR_NONE Success
- * @retval BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @retval #BUNDLE_ERROR_NONE Success
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
  * @pre @a b must be a valid bundle object.
  * @see bundle_add_byte()
  *
@@ -590,7 +588,7 @@ API int bundle_get_str(bundle *b, const char *key, char **str);
  bundle_free(b); // After freeing b, v and n become a dangling pointer
  * @endcode
  */
-API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size);
+int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size);
 
 /**
  * @brief Adds an 'array of byte sequences' type key-value pair into a bundle.
@@ -611,12 +609,12 @@ API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size);
  * @see bundle_get_byte_array()
  * @see bundle_set_byte_array_element()
  */
-API int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len);
+int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len);
 
 /**
  * @brief Sets an element of an array of byte sequences.
- * @since_tizen 5.5
  * @details The array will contain its own copy of the added value.
+ * @since_tizen 5.5
  *
  * @param[in]   b                       The bundle object
  * @param[in]   key                     The key
@@ -634,7 +632,7 @@ API int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len
  * @see bundle_add_byte_array()
  * @see bundle_get_byte_array()
  */
-API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size);
+int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size);
 
 /**
  * @brief Gets the array of byte sequences with the given key.
@@ -656,7 +654,7 @@ API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned
  * @see bundle_add_byte_array()
  * @see bundle_set_byte_array_element()
 */
-API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
+int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
 
 #ifdef __cplusplus
 }