25 #ifndef SPA_POD_ITER_H 26 #define SPA_POD_ITER_H 33 #include <sys/types.h> 94 #define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter) \ 95 for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_array_body), void); \ 96 (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \ 97 (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void)) 99 #define SPA_POD_ARRAY_FOREACH(obj, iter) \ 100 SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter) 102 #define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \ 103 for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_choice_body), void); \ 104 (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \ 105 (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void)) 107 #define SPA_POD_CHOICE_FOREACH(obj, iter) \ 108 SPA_POD_CHOICE_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter) 110 #define SPA_POD_FOREACH(pod, size, iter) \ 111 for ((iter) = (pod); \ 112 spa_pod_is_inside(pod, size, iter); \ 113 (iter) = (__typeof__(iter))spa_pod_next(iter)) 115 #define SPA_POD_STRUCT_FOREACH(obj, iter) \ 116 SPA_POD_FOREACH(SPA_POD_BODY(obj), SPA_POD_BODY_SIZE(obj), iter) 118 #define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \ 119 for ((iter) = spa_pod_prop_first(body); \ 120 spa_pod_prop_is_inside(body, size, iter); \ 121 (iter) = spa_pod_prop_next(iter)) 123 #define SPA_POD_OBJECT_FOREACH(obj, iter) \ 124 SPA_POD_OBJECT_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter) 126 #define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter) \ 127 for ((iter) = spa_pod_control_first(body); \ 128 spa_pod_control_is_inside(body, size, iter); \ 129 (iter) = spa_pod_control_next(iter)) 131 #define SPA_POD_SEQUENCE_FOREACH(seq, iter) \ 132 SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter) 138 if (size <
sizeof(
struct spa_pod) ||
offset + size > maxsize)
250 strncpy(dest, s, maxlen-1);
251 dest[maxlen-1]=
'\0';
345 void *values, uint32_t max_values)
351 n_values =
SPA_MIN(n_values, max_values);
Definition: pod/pod.h:199
#define SPA_POD_CHOICE_N_VALUES(choice)
Definition: pod/pod.h:137
int spa_pod_is_fd(const struct spa_pod *pod)
Definition: iter.h:284
#define SPA_POD_PROP_SIZE(prop)
Definition: pod/pod.h:196
bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
Definition: iter.h:392
void * spa_pod_next(const void *iter)
Definition: iter.h:55
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:47
int spa_pod_is_id(const struct spa_pod *pod)
Definition: iter.h:164
#define SPA_POD_VALUE(type, pod)
Definition: pod/pod.h:55
Definition: pod/pod.h:180
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:51
uint32_t offset
media offset
Definition: pod/pod.h:223
int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)
Definition: iter.h:245
#define SPA_POD_CHOICE_CHILD(choice)
Definition: pod/pod.h:132
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:46
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:45
#define SPA_POD_ARRAY_VALUES(arr)
Definition: pod/pod.h:120
int spa_pod_is_choice(const struct spa_pod *pod)
Definition: iter.h:356
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:220
#define SPA_POD_OBJECT_FOREACH(obj, iter)
Definition: iter.h:123
int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition: iter.h:275
Definition: pod/pod.h:101
#define SPA_POD_OBJECT_ID(obj)
Definition: pod/pod.h:167
bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body, uint32_t size, const struct spa_pod_control *iter)
Definition: iter.h:82
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:60
static uint32_t int int res
Definition: core.h:328
int spa_pod_is_array(const struct spa_pod *pod)
Definition: iter.h:331
int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition: iter.h:298
int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition: iter.h:304
uint32_t flags
Definition: iter.h:46
int spa_pod_is_int(const struct spa_pod *pod)
Definition: iter.h:177
#define SPA_POD_TYPE(pod)
Definition: pod/pod.h:41
int spa_pod_object_fixate(struct spa_pod_object *pod)
Definition: iter.h:431
uint32_t type
Definition: pod/pod.h:52
int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition: iter.h:221
int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:290
bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
Definition: iter.h:49
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:49
int spa_pod_is_sequence(const struct spa_pod *pod)
Definition: iter.h:397
int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition: iter.h:325
struct spa_pod_frame * parent
Definition: iter.h:44
int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition: iter.h:182
bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
Definition: iter.h:387
int spa_pod_fixate(struct spa_pod *pod)
Definition: iter.h:441
uint32_t offset
Definition: iter.h:45
int spa_pod_is_long(const struct spa_pod *pod)
Definition: iter.h:190
bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body, uint32_t size, const struct spa_pod_prop *iter)
Definition: iter.h:65
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:55
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:56
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:59
int spa_pod_is_float(const struct spa_pod *pod)
Definition: iter.h:203
uint32_t type
type of control, enum spa_control_type
Definition: pod/pod.h:224
int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition: iter.h:318
struct spa_pod * spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
Definition: iter.h:362
struct spa_pod pod
Definition: iter.h:43
struct spa_pod_prop * spa_pod_prop_next(const struct spa_pod_prop *iter)
Definition: iter.h:72
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:58
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:52
int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition: iter.h:156
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:62
int spa_pod_is_pointer(const struct spa_pod *pod)
Definition: iter.h:269
int spa_pod_is_none(const struct spa_pod *pod)
Definition: iter.h:146
struct spa_pod_object_body body
Definition: pod/pod.h:177
void * spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size)
Definition: iter.h:135
#define SPA_POD_BODY(pod)
Definition: pod/pod.h:47
int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition: iter.h:169
int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition: iter.h:260
struct spa_pod_control * spa_pod_control_next(const struct spa_pod_control *iter)
Definition: iter.h:89
no choice, first value is current
Definition: pod/pod.h:141
Definition: pod/pod.h:191
#define spa_return_val_if_fail(expr, val)
Definition: defs.h:248
void * spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values)
Definition: iter.h:337
#define SPA_POD_ARRAY_VALUE_SIZE(arr)
Definition: pod/pod.h:118
Definition: pod/pod.h:186
struct spa_pod pod
Definition: pod/pod.h:157
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:53
int spa_pod_is_fraction(const struct spa_pod *pod)
Definition: iter.h:312
const struct spa_pod_prop * spa_pod_object_find_prop(const struct spa_pod_object *pod, const struct spa_pod_prop *start, uint32_t key)
Definition: iter.h:403
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:54
Definition: pod/pod.h:175
int spa_pod_is_double(const struct spa_pod *pod)
Definition: iter.h:216
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:48
#define SPA_POD_BODY_SIZE(pod)
Definition: pod/pod.h:40
struct spa_pod_prop * spa_pod_prop_first(const struct spa_pod_object_body *body)
Definition: iter.h:60
uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type, void *values, uint32_t max_values)
Definition: iter.h:344
Definition: pod/pod.h:148
int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition: iter.h:208
struct spa_pod_control * spa_pod_control_first(const struct spa_pod_sequence_body *body)
Definition: iter.h:77
int spa_pod_is_string(const struct spa_pod *pod)
Definition: iter.h:229
struct spa_pod value
control value, depends on type
Definition: pod/pod.h:225
#define SPA_POD_OBJECT_TYPE(obj)
Definition: pod/pod.h:166
Definition: pod/pod.h:222
const struct spa_pod_prop * spa_pod_find_prop(const struct spa_pod *pod, const struct spa_pod_prop *start, uint32_t key)
Definition: iter.h:423
struct spa_pod pod
Definition: pod/pod.h:176
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:63
#define SPA_MIN(a, b)
Definition: defs.h:122
uint32_t key
key of property, list of valid keys depends on the object type
Definition: pod/pod.h:200
int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition: iter.h:237
int spa_pod_is_bytes(const struct spa_pod *pod)
Definition: iter.h:255
uint32_t size
Definition: pod/pod.h:51
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:57
int spa_pod_is_struct(const struct spa_pod *pod)
Definition: iter.h:376
#define SPA_POD_ARRAY_N_VALUES(arr)
Definition: pod/pod.h:119
int spa_pod_is_object(const struct spa_pod *pod)
Definition: iter.h:381
int spa_pod_is_bool(const struct spa_pod *pod)
Definition: iter.h:151
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:61
#define SPA_POD_SIZE(pod)
Definition: pod/pod.h:42
Definition: pod/pod.h:106
Definition: pod/pod.h:229
#define SPA_POD_CHOICE_TYPE(choice)
Definition: pod/pod.h:133
#define SPA_POD_ARRAY_VALUE_TYPE(arr)
Definition: pod/pod.h:117
#define SPA_POD_CONTROL_SIZE(ev)
Definition: pod/pod.h:219
Definition: x86_64-redhat-linux-gnu/doc/spa/utils/type.h:50
Definition: pod/pod.h:122
#define SPA_POD_CONTENTS(type, pod)
Definition: pod/pod.h:45
struct spa_pod pod
Definition: pod/pod.h:187
Definition: pod/pod.h:169
int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:195
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:158
Definition: pod/pod.h:156