PipeWire  0.3.27
properties.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_PROPERTIES_H
26 #define PIPEWIRE_PROPERTIES_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdarg.h>
33 
34 #include <spa/utils/dict.h>
35 
45 struct pw_properties {
46  struct spa_dict dict;
47  uint32_t flags;
48 };
49 
50 struct pw_properties *
51 pw_properties_new(const char *key, ...) SPA_SENTINEL;
52 
53 struct pw_properties *
55 
56 struct pw_properties *
58 
59 struct pw_properties *
60 pw_properties_copy(const struct pw_properties *properties);
61 
63  const struct spa_dict *dict, const char *keys[]);
65  const struct spa_dict *dict, const char *ignore[]);
66 
67 int pw_properties_update(struct pw_properties *oldprops,
68  const struct spa_dict *dict);
70  const char *str, size_t size);
71 
72 int pw_properties_add(struct pw_properties *oldprops,
73  const struct spa_dict *dict);
75  const struct spa_dict *dict, const char *keys[]);
76 
77 void pw_properties_clear(struct pw_properties *properties);
78 
79 void
80 pw_properties_free(struct pw_properties *properties);
81 
82 int
83 pw_properties_set(struct pw_properties *properties, const char *key, const char *value);
84 
85 int
86 pw_properties_setf(struct pw_properties *properties,
87  const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4);
88 int
90  const char *key, const char *format, va_list args) SPA_PRINTF_FUNC(3,0);
91 const char *
92 pw_properties_get(const struct pw_properties *properties, const char *key);
93 
94 const char *
95 pw_properties_iterate(const struct pw_properties *properties, void **state);
96 
97 static inline bool pw_properties_parse_bool(const char *value) {
98  return (strcmp(value, "true") == 0 || atoi(value) == 1);
99 }
100 
101 static inline int pw_properties_parse_int(const char *value) {
102  return strtol(value, NULL, 0);
103 }
104 
105 static inline int64_t pw_properties_parse_int64(const char *value) {
106  return strtoll(value, NULL, 0);
107 }
108 
109 static inline uint64_t pw_properties_parse_uint64(const char *value) {
110  return strtoull(value, NULL, 0);
111 }
112 
113 static inline float pw_properties_parse_float(const char *value) {
114  return strtof(value, NULL);
115 }
116 
117 static inline double pw_properties_parse_double(const char *value) {
118  return strtod(value, NULL);
119 }
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* PIPEWIRE_PROPERTIES_H */
res
static uint32_t int int res
Definition: core.h:326
pw_properties::flags
uint32_t flags
extra flags
Definition: properties.h:47
pw_properties::pw_properties_iterate
SPA_EXPORT const char * pw_properties_iterate(const struct pw_properties *properties, void **state)
Iterate property values.
Definition: properties.c:526
pw_properties::pw_properties_new_string
SPA_EXPORT struct pw_properties * pw_properties_new_string(const char *object)
Make a new properties object from the given str.
Definition: properties.c:196
impl
Definition: control.c:33
pw_array_for_each
#define pw_array_for_each(pos, array)
Definition: array.h:67
array.h
pw_properties_update_ignore
SPA_EXPORT int pw_properties_update_ignore(struct pw_properties *props, const struct spa_dict *dict, const char *ignore[])
Definition: properties.c:262
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
pw_properties_update_string
SPA_EXPORT int pw_properties_update_string(struct pw_properties *props, const char *str, size_t size)
Definition: properties.c:149
pw_array
An array object.
Definition: array.h:43
pw_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:478
utils.h
va_start
va_start(args, message)
pw_array::pw_array_ensure_size
static int pw_array_ensure_size(struct pw_array *arr, size_t size)
Make sure size bytes can be added to the array.
Definition: array.h:105
pw_properties::pw_properties_new_dict
SPA_EXPORT struct pw_properties * pw_properties_new_dict(const struct spa_dict *dict)
Make a new properties object from the given dictionary.
Definition: properties.c:129
pw_properties::pw_properties_update
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:305
pw_properties_update_ignore
int pw_properties_update_ignore(struct pw_properties *props, const struct spa_dict *dict, const char *ignore[])
Definition: properties.c:262
spa_dict
Update client properties.
args
static uint32_t int int const char va_list args
Definition: core.h:327
pw_array::pw_array_add
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:127
pw_array::pw_array_get_len
#define pw_array_get_len(a, t)
Get the number of items of type t in array.
Definition: array.h:57
pw_properties::pw_properties_copy
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:223
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:445
pw_properties_update_string
int pw_properties_update_string(struct pw_properties *props, const char *str, size_t size)
Definition: properties.c:149
pw_properties::pw_properties_clear
SPA_EXPORT void pw_properties_clear(struct pw_properties *properties)
Clear a properties object.
Definition: properties.c:282
pw_properties::pw_properties_get
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:501
va_end
va_end(args)
pw_array::pw_array_get_unchecked
#define pw_array_get_unchecked(a, idx, t)
Get the item with index idx and type t from array.
Definition: array.h:59
pw_properties::pw_properties_add
SPA_EXPORT int pw_properties_add(struct pw_properties *props, const struct spa_dict *dict)
Add properties.
Definition: properties.c:328
impl::this
struct pw_control this
Definition: control.c:34
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:99
pw_array::pw_array_check_index
#define pw_array_check_index(a, idx, t)
Check if an item with index idx and type t exist in array.
Definition: array.h:61
properties.h
pw_properties::pw_properties_add_keys
SPA_EXPORT int pw_properties_add_keys(struct pw_properties *props, const struct spa_dict *dict, const char *keys[])
Add keys.
Definition: properties.c:354
pw_properties::pw_properties_update_keys
SPA_EXPORT int pw_properties_update_keys(struct pw_properties *props, const struct spa_dict *dict, const char *keys[])
Copy multiple keys from one property to another.
Definition: properties.c:238
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:377
pw_properties_setva
int int pw_properties_setva(struct pw_properties *properties, const char *key, const char *format, va_list args) SPA_PRINTF_FUNC(3
pw_properties_setva
SPA_EXPORT int pw_properties_setva(struct pw_properties *properties, const char *key, const char *format, va_list args)
Definition: properties.c:451
pw_array::pw_array_init
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:85