BUNDLE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
BUNDLE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
BUNDLE_ERROR_KEY_NOT_AVAILABLE = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Required key not available */
- BUNDLE_ERROR_KEY_EXISTS = TIZEN_ERROR_BUNDLE | 0x01 /**< Key exists */
+ BUNDLE_ERROR_KEY_EXISTS = TIZEN_ERROR_BUNDLE | 0x01, /**< Key exists */
+ BUNDLE_ERROR_ARRAY_INDEX_OUT_OF_BOUNDS = TIZEN_ERROR_BUNDLE | 0x02 /**< The index is out of bounds of the array */
} bundle_error_e;
/**
- * @brief Adds a byte type key-value pair into a bundle.
+ * @brief Adds a byte sequence type key-value pair into a bundle.
+ * @details The bundle will contain a copy of the added byte sequence.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] b The bundle object
* @param[in] key The key
- * @param[in] byte The string type value
- * @param[in] size The size of @a byte
+ * @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
bundle_free(b);
* @endcode
*/
-API int bundle_add_byte(bundle *b, const char *key, const void *byte, const size_t size);
+API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size);
/**
/**
- * @brief Gets the byte value with the given key.
+ * @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.
* @param[in] b The bundle object
* @param[in] key The key
- * @param[out] byte The returned value
- * @param[out] size The size of the byte
+ * @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
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 **byte, size_t *size);
+API 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.
+ * @since_tizen 5.5
+ * @remarks To set the value of the byte array element, you should use bundle_set_byte_array_element().
+ * This function is only for creating a buffer of the byte array.
+ *
+ * @param[in] b The bundle object
+ * @param[in] key The key
+ * @param[in] len The length of the array to be created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #BUNDLE_ERROR_NONE Successful
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_EXISTS Key already exists
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @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);
+
+/**
+ * @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.
+ *
+ * @param[in] b The bundle object
+ * @param[in] key The key
+ * @param[in] idx The index of the array element to be changed
+ * @param[in] bytes The byte sequence
+ * @param[in] size The byte sequence size in bytes
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #BUNDLE_ERROR_NONE Successful
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #BUNDLE_ERROR_ARRAY_INDEX_OUT_OF_BOUNDS The index is out of bounds of the array
+ *
+ * @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);
+
+/**
+ * @brief Gets the array of byte sequences with the given key.
+ * @since_tizen 5.5
+ * @remarks You should not release @a byte_array, @a len and @a array_element_size.
+ * @a byte_array, @a len and @a array_element_size will be released when the bundle containing them is released with bundle_free().
+ *
+ * @param[in] b The bundle object
+ * @param[in] key The key
+ * @param[out] byte_array The array pointer of the byte value
+ * @param[out] len The array length
+ * @param[out] array_element_size An array of sizes of each @a byte_array element
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #BUNDLE_ERROR_NONE Successful
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_NOT_AVAILABLE Key not available
+ *
+ * @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);
#ifdef __cplusplus
}
API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val);
/**
- * @brief Adds a byte array type key-value pair into a bundle.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] b The bundle object
- * @param[in] key The key
- * @param[in] byte_array Not used
- * @param[in] len The length of the array to be created
- * @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
- * @pre @a b must be a valid bundle object.
- * @see bundle_get_byte_array()
- * @see bundle_set_byte_array_element()
- @code
- #include <bundle_internal.h>
- bundle *b = bundle_create();
- bundle_add_byte_array(b, "foo", NULL, 3); // add a byte-array with length 3
-
- bundle_set_byte_array_element(b, "foo", 0, "aaa\0", 4); array[0] = "aaa\0"
- bundle_set_byte_array_element(b, "foo", 1, "bbb\0", 4); array[1] = "bbb\0"
- bundle_set_byte_array_element(b, "foo", 2, "ccc\0", 4); array[2] = "ccc\0"
-
- bundle_free(b);
- @endcode
- */
-API int bundle_add_byte_array(bundle *b, const char *key, void **byte_array, const unsigned int len);
-
-/**
- * @brief Sets the value of the byte array element.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] b The bundle object
- * @param[in] key The key
- * @param[in] idx The index of the array element to be changed
- * @param[in] val The string type value; if @c NULL, an empty array is created; you can change an item with
- * @param[in] size The size of the value in bytes
- * @return Operation result
- * @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_array()
- * @see bundle_get_byte_array()
- @code
- #include <bundle_internal.h>
- bundle *b = bundle_create();
- bundle_add_byte_array(b, "foo", NULL, 3); // add a key-val pair
-
- bundle_set_byte_array_element(b, "foo", 0, "aaa\0", 4);
- bundle_set_byte_array_element(b, "foo", 1, "bbb\0", 4);
- bundle_set_byte_array_element(b, "foo", 2, "ccc\0", 4);
-
- unsigned char **byte_array = NULL;
- int len_byte_array = 0;
-
- bundle_get_byte_array(b, "foo", &byte_array, &len_byte_array, &size_byte_array);
- // byte_array = { "aaa\0", "bbb\0", "ccc\0" }, and len_byte_array = 3
-
- bundle_free(b);
- @endcode
- */
-API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *val, const size_t size);
-
-/**
- * @brief Gets the byte array value with the given key.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks You must not free str!
- * @param[in] b The bundle object
- * @param[in] key The key
- * @param[out] byte_array The returned value
- * @param[out] len The array length
- * @param[out] array_element_size an array of sizes of each @a byte_array element
- * @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
- * @pre @a b must be a valid bundle object.
- * @see bundle_add_byte_array()
- * @see bundle_set_byte_array_element()
- @code
- #include <bundle_internal.h>
- bundle *b = bundle_create();
- bundle_add_byte_array(b, "foo", NULL, 3);
- bundle_set_byte_array_element(b, "foo", 0, "aaa\0", 4);
- bundle_set_byte_array_element(b, "foo", 1, "bbb\0", 4);
- bundle_set_byte_array_element(b, "foo", 2, "ccc\0", 4);
-
- char **byte_array = NULL;
- int len_byte_array = 0;
- size_t *size_byte_array = NULL;
-
- bundle_get_byte_array(b, "foo", &byte_array, &len_byte_array, &size_byte_array);
- // byte_array = { "aaa\0", "bbb\0", "ccc\0" }, len_byte_array = 3, and size_byte_array = { 4, 4, 4 }
-
- bundle_free(b);
- @endcode
- */
-API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
-
-/**
* @brief Creates a json data from bundle.
* @since_tizen 3.0
* @remarks This API only supports the string type and the string array type.
kva = (keyval_array_t *)kv;
if (!keyval_array_is_idx_valid(kva, idx))
- return BUNDLE_ERROR_INVALID_PARAMETER;
+ return BUNDLE_ERROR_ARRAY_INDEX_OUT_OF_BOUNDS;
/* NULL value test (TODO: is this needed?) */
if (!kva->array_val)
idx, val, strlen(val) + 1);
}
-int bundle_add_byte(bundle *b, const char *key, const void *byte,
+int bundle_add_byte(bundle *b, const char *key, const void *bytes,
const size_t size)
{
- return _bundle_add_kv(b, key, byte, size, BUNDLE_TYPE_BYTE, 1);
+ return _bundle_add_kv(b, key, bytes, size, BUNDLE_TYPE_BYTE, 1);
}
-int bundle_get_byte(bundle *b, const char *key, void **byte, size_t *size)
+int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size)
{
- return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE, (void **)byte,
+ return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE, (void **)bytes,
size, NULL, NULL);
}
-int bundle_add_byte_array(bundle *b, const char *key, void **byte_array,
- const unsigned int len)
+int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len)
{
- return _bundle_add_kv(b, key, byte_array, 0,
- BUNDLE_TYPE_BYTE_ARRAY, len);
+ return bundle_init_byte_array(b, key, len);
}
int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len)
}
int bundle_set_byte_array_element(bundle *b, const char *key,
- const unsigned int idx, const void *val, const size_t size)
+ const unsigned int idx, const void *bytes, const size_t size)
{
return bundle_set_array_val(b, key, BUNDLE_TYPE_BYTE_ARRAY,
- idx, val, size);
+ idx, bytes, size);
}