mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
type: add subclass check
This commit is contained in:
parent
25b7ede0bc
commit
141202b1fd
2 changed files with 12 additions and 0 deletions
|
|
@ -39,6 +39,12 @@ typedef uint32_t SpaType;
|
||||||
#define SPA_TYPE__Object SPA_TYPE_BASE "Object"
|
#define SPA_TYPE__Object SPA_TYPE_BASE "Object"
|
||||||
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
|
#define SPA_TYPE_OBJECT_BASE SPA_TYPE__Object ":"
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_type_is_a (const char *type, const char *parent)
|
||||||
|
{
|
||||||
|
return type != NULL && parent != NULL && strstr (type, parent) == type;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -269,5 +269,11 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
do_static_struct ();
|
do_static_struct ();
|
||||||
|
|
||||||
|
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaType, SPA_TYPE_ENUM_BASE));
|
||||||
|
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaSubtype, SPA_TYPE_ENUM_BASE));
|
||||||
|
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_ENUM_BASE));
|
||||||
|
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_BASE));
|
||||||
|
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_OBJECT_BASE));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue