| 1 |
/* WirePlumber |
| 2 |
* |
| 3 |
* Copyright © 2019 Collabora Ltd. |
| 4 |
* @author George Kiagiadakis <[email protected]> |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: MIT |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef __WIREPLUMBER_PROPERTIES_H__ |
| 10 |
#define __WIREPLUMBER_PROPERTIES_H__ |
| 11 |
|
| 12 |
#include <glib-object.h> |
| 13 |
#include "defs.h" |
| 14 |
#include "iterator.h" |
| 15 |
#include "spa-json.h" |
| 16 |
|
| 17 |
G_BEGIN_DECLS |
| 18 |
|
| 19 |
struct pw_properties; |
| 20 |
struct spa_dict; |
| 21 |
|
| 22 |
/*! |
| 23 |
* \brief The WpProperties GType |
| 24 |
* \ingroup wpproperties |
| 25 |
*/ |
| 26 |
#define WP_TYPE_PROPERTIES (wp_properties_get_type ()) |
| 27 |
WP_API |
| 28 |
GType wp_properties_get_type (void); |
| 29 |
|
| 30 |
typedef struct _WpProperties WpProperties; |
| 31 |
|
| 32 |
WP_API |
| 33 |
WpProperties * wp_properties_new_empty (void); |
| 34 |
|
| 35 |
WP_API |
| 36 |
WpProperties * wp_properties_new (const gchar * key, ...) G_GNUC_NULL_TERMINATED; |
| 37 |
|
| 38 |
WP_API |
| 39 |
WpProperties * wp_properties_new_valist (const gchar * key, va_list args); |
| 40 |
|
| 41 |
WP_API |
| 42 |
WpProperties * wp_properties_new_string (const gchar * str); |
| 43 |
|
| 44 |
WP_API |
| 45 |
WpProperties * wp_properties_new_json (const WpSpaJson * json); |
| 46 |
|
| 47 |
WP_API |
| 48 |
WpProperties * wp_properties_new_wrap (const struct pw_properties * props); |
| 49 |
|
| 50 |
WP_API |
| 51 |
WpProperties * wp_properties_new_take (struct pw_properties * props); |
| 52 |
|
| 53 |
WP_API |
| 54 |
WpProperties * wp_properties_new_copy (const struct pw_properties * props); |
| 55 |
|
| 56 |
WP_API |
| 57 |
WpProperties * wp_properties_new_wrap_dict (const struct spa_dict * dict); |
| 58 |
|
| 59 |
WP_API |
| 60 |
WpProperties * wp_properties_new_copy_dict (const struct spa_dict * dict); |
| 61 |
|
| 62 |
WP_API |
| 63 |
WpProperties * wp_properties_copy (WpProperties * other); |
| 64 |
|
| 65 |
/* ref counting */ |
| 66 |
|
| 67 |
WP_API |
| 68 |
WpProperties * wp_properties_ref (WpProperties * self); |
| 69 |
|
| 70 |
WP_API |
| 71 |
void wp_properties_unref (WpProperties * self); |
| 72 |
|
| 73 |
WP_API |
| 74 |
WpProperties * wp_properties_ensure_unique_owner (WpProperties * self); |
| 75 |
|
| 76 |
/* update */ |
| 77 |
|
| 78 |
WP_API |
| 79 |
gint wp_properties_update (WpProperties * self, WpProperties * props); |
| 80 |
|
| 81 |
WP_API |
| 82 |
gint wp_properties_update_from_dict (WpProperties * self, |
| 83 |
const struct spa_dict * dict); |
| 84 |
|
| 85 |
WP_API |
| 86 |
gint wp_properties_update_from_json (WpProperties * self, const WpSpaJson * json); |
| 87 |
|
| 88 |
/* add */ |
| 89 |
|
| 90 |
WP_API |
| 91 |
gint wp_properties_add (WpProperties * self, WpProperties * props); |
| 92 |
|
| 93 |
WP_API |
| 94 |
gint wp_properties_add_from_dict (WpProperties * self, |
| 95 |
const struct spa_dict * dict); |
| 96 |
|
| 97 |
/* update keys */ |
| 98 |
|
| 99 |
WP_API |
| 100 |
gint wp_properties_update_keys (WpProperties * self, WpProperties * props, |
| 101 |
const gchar * key1, ...) G_GNUC_NULL_TERMINATED; |
| 102 |
|
| 103 |
WP_API |
| 104 |
gint wp_properties_update_keys_from_dict (WpProperties * self, |
| 105 |
const struct spa_dict * dict, const gchar * key1, ...) G_GNUC_NULL_TERMINATED; |
| 106 |
|
| 107 |
WP_API |
| 108 |
gint wp_properties_update_keys_array (WpProperties * self, WpProperties * props, |
| 109 |
const gchar * keys[]); |
| 110 |
|
| 111 |
/* add keys */ |
| 112 |
|
| 113 |
WP_API |
| 114 |
gint wp_properties_add_keys (WpProperties * self, WpProperties * props, |
| 115 |
const gchar * key1, ...) G_GNUC_NULL_TERMINATED; |
| 116 |
|
| 117 |
WP_API |
| 118 |
gint wp_properties_add_keys_from_dict (WpProperties * self, |
| 119 |
const struct spa_dict * dict, const gchar * key1, ...) G_GNUC_NULL_TERMINATED; |
| 120 |
|
| 121 |
WP_API |
| 122 |
gint wp_properties_add_keys_array (WpProperties * self, WpProperties * props, |
| 123 |
const gchar * keys[]); |
| 124 |
|
| 125 |
/* get/set */ |
| 126 |
|
| 127 |
WP_API |
| 128 |
const gchar * wp_properties_get (WpProperties * self, const gchar * key); |
| 129 |
|
| 130 |
WP_API |
| 131 |
gint wp_properties_set (WpProperties * self, const gchar * key, |
| 132 |
const gchar * value); |
| 133 |
|
| 134 |
WP_API |
| 135 |
gint wp_properties_setf (WpProperties * self, const gchar * key, |
| 136 |
const gchar * format, ...) G_GNUC_PRINTF(3, 4); |
| 137 |
|
| 138 |
WP_API |
| 139 |
gint wp_properties_setf_valist (WpProperties * self, const gchar * key, |
| 140 |
const gchar * format, va_list args) G_GNUC_PRINTF(3, 0); |
| 141 |
|
| 142 |
/* iterate */ |
| 143 |
|
| 144 |
#define WP_TYPE_PROPERTIES_ITEM (wp_properties_item_get_type ()) |
| 145 |
WP_API |
| 146 |
GType wp_properties_item_get_type (void); |
| 147 |
|
| 148 |
typedef struct _WpPropertiesItem WpPropertiesItem; |
| 149 |
|
| 150 |
WP_API |
| 151 |
WpPropertiesItem *wp_properties_item_ref (WpPropertiesItem *self); |
| 152 |
|
| 153 |
WP_API |
| 154 |
void wp_properties_item_unref (WpPropertiesItem *self); |
| 155 |
|
| 156 |
WP_API |
| 157 |
const gchar * wp_properties_item_get_key (WpPropertiesItem * self); |
| 158 |
|
| 159 |
WP_API |
| 160 |
const gchar * wp_properties_item_get_value (WpPropertiesItem * self); |
| 161 |
|
| 162 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpPropertiesItem, wp_properties_item_unref) |
| 163 |
|
| 164 |
WP_API |
| 165 |
WpIterator * wp_properties_new_iterator (WpProperties * self); |
| 166 |
|
| 167 |
/* count */ |
| 168 |
|
| 169 |
WP_API |
| 170 |
guint wp_properties_get_count (WpProperties * self); |
| 171 |
|
| 172 |
|
| 173 |
/* sort */ |
| 174 |
|
| 175 |
WP_API |
| 176 |
void wp_properties_sort (WpProperties * self); |
| 177 |
|
| 178 |
/* convert */ |
| 179 |
|
| 180 |
WP_API |
| 181 |
const struct spa_dict * wp_properties_peek_dict (WpProperties * self); |
| 182 |
|
| 183 |
WP_API |
| 184 |
struct pw_properties * wp_properties_to_pw_properties (WpProperties * self); |
| 185 |
|
| 186 |
WP_API |
| 187 |
struct pw_properties * wp_properties_unref_and_take_pw_properties ( |
| 188 |
WpProperties * self); |
| 189 |
|
| 190 |
/* comparison */ |
| 191 |
|
| 192 |
WP_API |
| 193 |
gboolean wp_properties_matches (WpProperties * self, WpProperties *other); |
| 194 |
|
| 195 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpProperties, wp_properties_unref) |
| 196 |
|
| 197 |
G_END_DECLS |
| 198 |
|
| 199 |
#endif |