/**
+ * @brief Determine if kv is measurable type or not.
+ * @pre kv must be a valid bundle_keyval_t object.
+ * @post None
+ * @see bundle_foreach
+ * @param[in] kv A bundle_keyval_t object
+ * @return Operation result
+ * @retval 1 kv is an measurable.
+ * @retval 0 kv is not an measurable.
+ * @remark
+ */
+API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv);
+
+
+/**
* @brief Get value and size of the value from kv of basic type.
* @pre kv must be a valid bundle_keyval_t object.
* @post val, size are set.
*/
API bundle * bundle_import_from_argv(int argc, char **argv);
-#if 0
/**
* @brief Add a string type key-value pair into bundle.
* @pre b must be a valid bundle object.
@endcode
*/
API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
-#endif
#ifdef __cplusplus
-
Name: bundle
Summary: String key-val dictionary ADT
-Version: 0.1.27
+Version: 0.1.30
Release: 1
Group: System/Libraries
License: Apache License, Version 2.0
Source0: bundle-%{version}.tar.gz
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(dlog)
-
-
%description
Simple string key-val dictionary ADT
-
-
%package devel
Summary: String key-val dictionary ADT (devel)
Group: Development/Libraries
%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-
-
+%cmake .
make %{?jobs:-j%jobs}
%install
-rm -rf %{buildroot}
%make_install
-
-
-
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
-
-
-
%files
%manifest bundle.manifest
%defattr(-,root,root,-)
}
int
+bundle_keyval_type_is_measurable(bundle_keyval_t *kv)
+{
+ return keyval_type_is_measurable(kv->type);
+}
+
+int
bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size)
{
return keyval_get_data(kv, NULL, val, size);
{
return 0;
}
-/*static int
- bundle_set_array_val(bundle *b, const char *key, const int type, const unsigned int idx, const void *val, const size_t size)
- {
+static int
+bundle_set_array_val(bundle *b, const char *key, const int type, const unsigned int idx, const void *val, const size_t size)
+{
//void **array = NULL;
-keyval_t *kv = _bundle_find_kv(b, key);
-if(NULL == kv) return -1;
+ keyval_t *kv = _bundle_find_kv(b, key);
+ if(NULL == kv) return -1;
-if(type != kv->type) {
-errno = EINVAL;
-return -1;
-}
+ if(type != kv->type) {
+ errno = EINVAL;
+ return -1;
+ }
-if(! keyval_type_is_array(kv->type)) { // TODO: Is this needed?
-errno = EINVAL;
-return -1;
-}
+ if(! keyval_type_is_array(kv->type)) { // TODO: Is this needed?
+ errno = EINVAL;
+ return -1;
+ }
-keyval_array_t *kva = (keyval_array_t *)kv;
+ keyval_array_t *kva = (keyval_array_t *)kv;
-if(! keyval_array_is_idx_valid(kva, idx)) {
-errno = EINVAL;
-return -1;
-}
+ if(! keyval_array_is_idx_valid(kva, idx)) {
+ errno = EINVAL;
+ return -1;
+ }
-if(!kva->array_val) { // NULL value test (TODO: is this needed?)
-errno = ENOMEM;
-return -1;
-}
+ if(!kva->array_val) { // NULL value test (TODO: is this needed?)
+ errno = ENOMEM;
+ return -1;
+ }
-return keyval_array_set_element(kva, idx, val, size);
-}*/
+ return keyval_array_set_element(kva, idx, val, size);
+}
int
-#if 0
int
bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val)
{
return bundle_set_array_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, idx, val, size);
}
-#endif
-