Go to the documentation of this file.
25 #ifndef SPA_POD_PARSER_H
26 #define SPA_POD_PARSER_H
56 #define SPA_POD_PARSER_INIT(buffer,size) (struct spa_pod_parser){ buffer, size, 0, {} }
59 const void *
data, uint32_t size)
73 *state = parser->
state;
79 parser->
state = *state;
85 if (offset + 8 <=
size) {
337 #define SPA_POD_PARSER_COLLECT(pod,_type,args) \
341 *va_arg(args, bool*) = SPA_POD_VALUE(struct spa_pod_bool, pod); \
345 *va_arg(args, int32_t*) = SPA_POD_VALUE(struct spa_pod_int, pod); \
348 *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_long, pod); \
351 *va_arg(args, float*) = SPA_POD_VALUE(struct spa_pod_float, pod); \
354 *va_arg(args, double*) = SPA_POD_VALUE(struct spa_pod_double, pod); \
357 *va_arg(args, char**) = \
358 (pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
360 : (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \
364 char *dest = va_arg(args, char*); \
365 uint32_t maxlen = va_arg(args, uint32_t); \
366 strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \
370 *(va_arg(args, void **)) = SPA_POD_CONTENTS(struct spa_pod_bytes, pod); \
371 *(va_arg(args, uint32_t *)) = SPA_POD_BODY_SIZE(pod); \
374 *va_arg(args, struct spa_rectangle*) = \
375 SPA_POD_VALUE(struct spa_pod_rectangle, pod); \
378 *va_arg(args, struct spa_fraction*) = \
379 SPA_POD_VALUE(struct spa_pod_fraction, pod); \
382 *va_arg(args, uint32_t **) = \
383 (uint32_t *) SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \
386 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_SIZE(pod); \
387 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_TYPE(pod); \
388 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_N_VALUES(pod); \
389 *va_arg(args, void**) = SPA_POD_ARRAY_VALUES(pod); \
393 struct spa_pod_pointer_body *b = \
394 (struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
395 *(va_arg(args, uint32_t *)) = b->type; \
396 *(va_arg(args, const void **)) = b->value; \
400 *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_fd, pod); \
407 const struct spa_pod **d = va_arg(args, const struct spa_pod**); \
409 *d = (pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
418 #define SPA_POD_PARSER_SKIP(_type,args) \
422 va_arg(args, char*); \
423 va_arg(args, uint32_t); \
426 va_arg(args, void*); \
427 va_arg(args, void*); \
431 va_arg(args, void*); \
448 va_arg(args, void*); \
462 const struct spa_pod *pod = NULL;
466 uint32_t key = va_arg(args, uint32_t);
477 if ((format = va_arg(args,
char *)) == NULL)
483 if ((optional = (*format ==
'?')))
512 va_start(args, parser);
519 #define SPA_POD_OPT_Bool(val) "?" SPA_POD_Bool(val)
520 #define SPA_POD_OPT_Id(val) "?" SPA_POD_Id(val)
521 #define SPA_POD_OPT_Int(val) "?" SPA_POD_Int(val)
522 #define SPA_POD_OPT_Long(val) "?" SPA_POD_Long(val)
523 #define SPA_POD_OPT_Float(val) "?" SPA_POD_Float(val)
524 #define SPA_POD_OPT_Double(val) "?" SPA_POD_Double(val)
525 #define SPA_POD_OPT_String(val) "?" SPA_POD_String(val)
526 #define SPA_POD_OPT_Stringn(val,len) "?" SPA_POD_Stringn(val,len)
527 #define SPA_POD_OPT_Bytes(val,len) "?" SPA_POD_Bytes(val,len)
528 #define SPA_POD_OPT_Rectangle(val) "?" SPA_POD_Rectangle(val)
529 #define SPA_POD_OPT_Fraction(val) "?" SPA_POD_Fraction(val)
530 #define SPA_POD_OPT_Array(csize,ctype,n_vals,vals) "?" SPA_POD_Array(csize,ctype,n_vals,vals)
531 #define SPA_POD_OPT_Pointer(type,val) "?" SPA_POD_Pointer(type,val)
532 #define SPA_POD_OPT_Fd(val) "?" SPA_POD_Fd(val)
533 #define SPA_POD_OPT_Pod(val) "?" SPA_POD_Pod(val)
534 #define SPA_POD_OPT_PodObject(val) "?" SPA_POD_PodObject(val)
535 #define SPA_POD_OPT_PodStruct(val) "?" SPA_POD_PodStruct(val)
536 #define SPA_POD_OPT_PodChoice(val) "?" SPA_POD_PodChoice(val)
538 #define spa_pod_parser_get_object(p,type,id,...) \
540 struct spa_pod_frame _f; \
542 if ((_res = spa_pod_parser_push_object(p, &_f, type, id)) == 0) { \
543 _res = spa_pod_parser_get(p,##__VA_ARGS__, 0); \
544 spa_pod_parser_pop(p, &_f); \
549 #define spa_pod_parser_get_struct(p,...) \
551 struct spa_pod_frame _f; \
553 if ((_res = spa_pod_parser_push_struct(p, &_f)) == 0) { \
554 _res = spa_pod_parser_get(p,##__VA_ARGS__, NULL); \
555 spa_pod_parser_pop(p, &_f); \
560 #define spa_pod_parse_object(pod,type,id,...) \
562 struct spa_pod_parser _p; \
563 spa_pod_parser_pod(&_p, pod); \
564 spa_pod_parser_get_object(&_p,type,id,##__VA_ARGS__); \
567 #define spa_pod_parse_struct(pod,...) \
569 struct spa_pod_parser _p; \
570 spa_pod_parser_pod(&_p, pod); \
571 spa_pod_parser_get_struct(&_p,##__VA_ARGS__); \
int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:195
int spa_pod_parser_push_struct(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:253
Definition: pod/pod.h:175
int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
Definition: parser.h:235
int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
Definition: parser.h:199
void spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition: parser.h:77
int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
Definition: parser.h:190
uint32_t flags
Definition: parser.h:45
bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
Definition: parser.h:283
void spa_pod_parser_push(struct spa_pod_parser *parser, struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)
Definition: parser.h:98
int spa_pod_is_id(const struct spa_pod *pod)
Definition: iter.h:164
user data to add to an object
Definition: filter.c:75
uint32_t size
Definition: parser.h:51
Definition: pod/pod.h:199
int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
Definition: parser.h:226
int spa_pod_is_array(const struct spa_pod *pod)
Definition: iter.h:331
int spa_pod_is_choice(const struct spa_pod *pod)
Definition: iter.h:356
int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition: iter.h:298
int spa_pod_parser_pop(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:128
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:223
int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:290
int spa_pod_parser_get(struct spa_pod_parser *parser,...)
Definition: parser.h:507
int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition: iter.h:304
int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
Definition: parser.h:181
int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition: iter.h:275
int spa_pod_is_int(const struct spa_pod *pod)
Definition: iter.h:177
int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
Definition: parser.h:154
#define SPA_POD_CHOICE_CHILD(choice)
Definition: pod/pod.h:132
int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition: iter.h:221
int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
Definition: parser.h:217
int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition: iter.h:182
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
#define SPA_POD_OBJECT_ID(obj)
Definition: pod/pod.h:167
struct spa_pod * spa_pod_parser_current(struct spa_pod_parser *parser)
Definition: parser.h:108
struct spa_pod_frame * parent
Definition: iter.h:44
int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
Definition: parser.h:145
int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition: iter.h:318
int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition: iter.h:156
int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
Definition: parser.h:453
int spa_pod_is_long(const struct spa_pod *pod)
Definition: iter.h:190
int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition: iter.h:325
int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition: iter.h:169
struct spa_pod_parser_state state
Definition: parser.h:53
int spa_pod_is_float(const struct spa_pod *pod)
Definition: iter.h:203
void spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition: parser.h:71
uint32_t offset
Definition: iter.h:45
#define SPA_POD_PARSER_INIT(buffer, size)
Definition: parser.h:56
int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
Definition: parser.h:136
void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition: parser.h:115
void spa_pod_parser_init(struct spa_pod_parser *parser, const void *data, uint32_t size)
Definition: parser.h:58
int spa_pod_is_pointer(const struct spa_pod *pod)
Definition: iter.h:269
int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition: iter.h:260
void spa_pod_parser_pod(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition: parser.h:64
#define SPA_POD_PARSER_COLLECT(pod, _type, args)
Definition: parser.h:337
uint32_t size
Definition: pod/pod.h:51
int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
Definition: parser.h:208
uint32_t _padding
Definition: parser.h:52
int spa_pod_is_none(const struct spa_pod *pod)
Definition: iter.h:146
int spa_pod_is_fraction(const struct spa_pod *pod)
Definition: iter.h:312
int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
Definition: parser.h:172
@ SPA_TYPE_Object
Definition: build-12775836/doc/spa/utils/type.h:59
#define SPA_POD_OBJECT_TYPE(obj)
Definition: pod/pod.h:166
int spa_pod_is_double(const struct spa_pod *pod)
Definition: iter.h:216
struct spa_pod_frame * frame
Definition: parser.h:46
struct spa_pod pod
Definition: pod/pod.h:176
int spa_pod_is_bytes(const struct spa_pod *pod)
Definition: iter.h:255
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
int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition: iter.h:208
@ SPA_CHOICE_None
no choice, first value is current
Definition: pod/pod.h:141
#define SPA_POD_PARSER_SKIP(_type, args)
Definition: parser.h:418
uint32_t flags
Definition: iter.h:46
int spa_pod_is_string(const struct spa_pod *pod)
Definition: iter.h:229
uint32_t type
Definition: pod/pod.h:52
struct spa_pod * spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:93
const void * data
Definition: parser.h:50
int spa_pod_is_struct(const struct spa_pod *pod)
Definition: iter.h:376
int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
Definition: parser.h:244
struct spa_pod pod
Definition: iter.h:43
#define SPA_POD_SIZE(pod)
Definition: pod/pod.h:42
int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
Definition: parser.h:163
@ SPA_TYPE_Choice
Definition: build-12775836/doc/spa/utils/type.h:63
int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition: iter.h:237
Definition: pod/pod.h:161
int spa_pod_is_bool(const struct spa_pod *pod)
Definition: iter.h:151
struct spa_pod value
Definition: pod/pod.h:212
struct spa_pod * spa_pod_parser_next(struct spa_pod_parser *parser)
Definition: parser.h:120
int spa_pod_parser_push_object(struct spa_pod_parser *parser, struct spa_pod_frame *frame, uint32_t type, uint32_t *id)
Definition: parser.h:266
int spa_pod_is_object(const struct spa_pod *pod)
Definition: iter.h:381
uint32_t offset
Definition: parser.h:44
#define SPA_POD_CHOICE_TYPE(choice)
Definition: pod/pod.h:133
int spa_pod_is_fd(const struct spa_pod *pod)
Definition: iter.h:284
struct spa_pod * spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
Definition: parser.h:83
@ SPA_TYPE_Struct
Definition: build-12775836/doc/spa/utils/type.h:58