PipeWire 0.3.77
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_TYPES_H
6#define SPA_DEBUG_TYPES_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
17#include <spa/utils/type-info.h>
18
19#include <string.h>
20
21static inline const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
22{
23 const struct spa_type_info *res;
24
25 if (info == NULL)
27
28 while (info && info->name) {
29 if (info->type == SPA_ID_INVALID) {
30 if (info->values && (res = spa_debug_type_find(info->values, type)))
31 return res;
32 }
33 else if (info->type == type)
34 return info;
35 info++;
36 }
37 return NULL;
38}
39
40static inline const char *spa_debug_type_short_name(const char *name)
41{
42 const char *h;
43 if ((h = strrchr(name, ':')) != NULL)
44 name = h + 1;
45 return name;
46}
47
48static inline const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
49{
50 if ((info = spa_debug_type_find(info, type)) == NULL)
51 return NULL;
52 return info->name;
54
55static inline const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
56{
57 const char *str;
58 if ((str = spa_debug_type_find_name(info, type)) == NULL)
59 return NULL;
61}
62
63static inline uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
64{
65 if (info == NULL)
66 info = SPA_TYPE_ROOT;
67
68 while (info && info->name) {
69 uint32_t res;
70 if (strcmp(info->name, name) == 0)
71 return info->type;
72 if (info->values && (res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID)
73 return res;
74 info++;
75 }
76 return SPA_ID_INVALID;
77}
78
79static inline const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
80{
81 while (info && info->name) {
82 if (strcmp(spa_debug_type_short_name(info->name), name) == 0)
83 return info;
84 if (strcmp(info->name, name) == 0)
85 return info;
86 if (info->type != 0 && info->type == (uint32_t)atoi(name))
87 return info;
88 info++;
89 }
90 return NULL;
91}
92
93static inline uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
94{
95 if ((info = spa_debug_type_find_short(info, name)) == NULL)
96 return SPA_ID_INVALID;
97 return info->type;
103#ifdef __cplusplus
104} /* extern "C" */
105#endif
106
107#endif /* SPA_DEBUG_NODE_H */
static uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
Definition: types.h:68
static const struct spa_type_info * spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
Definition: types.h:26
static const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:53
static const char * spa_debug_type_short_name(const char *name)
Definition: types.h:45
static const char * spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:60
static const struct spa_type_info * spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
Definition: types.h:84
static uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
Definition: types.h:98
#define SPA_TYPE_ROOT
Definition: utils/type-info.h:26
#define SPA_ID_INVALID
Definition: defs.h:228
spa/utils/string.h
Definition: spa/include/spa/utils/type.h:142
uint32_t type
Definition: spa/include/spa/utils/type.h:143
const struct spa_type_info * values
Definition: spa/include/spa/utils/type.h:146
spa/utils/type-info.h