mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-01-07 15:30:14 +01:00
properties: Add get count API
This API returns the count of the number of properties or items.
This commit is contained in:
parent
8b97b40c44
commit
f032ac00cf
3 changed files with 23 additions and 0 deletions
|
|
@ -928,6 +928,21 @@ wp_properties_iterator_item_get_value (const GValue * item)
|
|||
return wp_properties_item_get_value (pi);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief gets the number of items
|
||||
* \ingroup wpproperties
|
||||
* \param self a properties object
|
||||
*/
|
||||
guint
|
||||
wp_properties_get_count (WpProperties * self)
|
||||
{
|
||||
const struct spa_dict *dict = wp_properties_peek_dict(self);
|
||||
g_return_val_if_fail (dict != NULL, 0);
|
||||
|
||||
return dict->n_items;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Sorts the keys in alphabetical order
|
||||
* \ingroup wpproperties
|
||||
|
|
|
|||
|
|
@ -165,6 +165,12 @@ WP_API
|
|||
G_DEPRECATED_FOR(wp_properties_item_get_value)
|
||||
const gchar * wp_properties_iterator_item_get_value (const GValue * item);
|
||||
|
||||
/* count */
|
||||
|
||||
WP_API
|
||||
guint wp_properties_get_count (WpProperties * self);
|
||||
|
||||
|
||||
/* sort */
|
||||
|
||||
WP_API
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ test_properties_wrap_dict (void)
|
|||
p = wp_properties_new_wrap_dict (&dict);
|
||||
g_assert_nonnull (p);
|
||||
|
||||
g_assert_cmpint (wp_properties_get_count (p), ==,
|
||||
SPA_N_ELEMENTS (dict_items));
|
||||
g_assert_cmpstr (wp_properties_get (p, "key1"), ==, "value1");
|
||||
g_assert_cmpstr (wp_properties_get (p, "key2"), ==, "value2");
|
||||
g_assert_cmpstr (wp_properties_get (p, "key3"), ==, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue