PipeWire 1.4.5 |

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
9 extern "C" {
10#endif
11
16
17#include <spa/utils/type-info.h>
18
19#include <string.h>
20
21#ifndef SPA_API_DEBUG_TYPES
22 #ifdef SPA_API_IMPL
23 #define SPA_API_DEBUG_TYPES SPA_API_IMPL
24 #else
25 #define SPA_API_DEBUG_TYPES static inline
26 #endif
27#endif
28
29
30 SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
31{
32 const struct spa_type_info *res;
33
34 if (info == NULL)
35 info = SPA_TYPE_ROOT;
36
37 while (info && info->name) {
38 if (info->type == SPA_ID_INVALID) {
39 if (info->values && (res = spa_debug_type_find(info->values, type)))
40 return res;
41 }
42 else if (info->type == type)
43 return info;
44 info++;
45 }
46 return NULL;
47}
48
49 SPA_API_DEBUG_TYPES const char *spa_debug_type_short_name(const char *name)
50{
51 return spa_type_short_name(name);
52}
53
54 SPA_API_DEBUG_TYPES const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
55{
56 if ((info = spa_debug_type_find(info, type)) == NULL)
57 return NULL;
58 return info->name;
59}
60
61 SPA_API_DEBUG_TYPES const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
62{
63 const char *str;
64 if ((str = spa_debug_type_find_name(info, type)) == NULL)
65 return NULL;
66 return spa_debug_type_short_name(str);
67}
68
69 SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
70{
71 if (info == NULL)
72 info = SPA_TYPE_ROOT;
73
74 while (info && info->name) {
75 uint32_t res;
76 if (strcmp(info->name, name) == 0)
77 return info->type;
78 if (info->values && (res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID)
79 return res;
80 info++;
81 }
82 return SPA_ID_INVALID;
83}
84
85 SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
86{
87 while (info && info->name) {
88 if (strcmp(spa_debug_type_short_name(info->name), name) == 0)
89 return info;
90 if (strcmp(info->name, name) == 0)
91 return info;
92 if (info->type != 0 && info->type == (uint32_t)atoi(name))
93 return info;
94 info++;
95 }
96 return NULL;
97}
98
99 SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
100{
101 if ((info = spa_debug_type_find_short(info, name)) == NULL)
102 return SPA_ID_INVALID;
103 return info->type;
104}
105
106 * \}
107 */
108
109#ifdef __cplusplus
110} /* extern "C" */
111#endif
112
113#endif /* SPA_DEBUG_NODE_H */
res
uint32_t int int res
Definition core.h:433
spa_debug_type_find_short
SPA_API_DEBUG_TYPES const struct spa_type_info * spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
Definition types.h:92
spa_debug_type_find_short_name
SPA_API_DEBUG_TYPES const char * spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
Definition types.h:68
SPA_API_DEBUG_TYPES
#define SPA_API_DEBUG_TYPES
Definition types.h:32
spa_debug_type_find_type_short
SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
Definition types.h:106
spa_debug_type_find
SPA_API_DEBUG_TYPES const struct spa_type_info * spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
Definition types.h:37
spa_debug_type_find_type
SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
Definition types.h:76
spa_debug_type_short_name
SPA_API_DEBUG_TYPES const char * spa_debug_type_short_name(const char *name)
Definition types.h:56
spa_debug_type_find_name
SPA_API_DEBUG_TYPES const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition types.h:61
spa_type_short_name
SPA_API_TYPE const char * spa_type_short_name(const char *name)
Definition type.h:166
SPA_TYPE_ROOT
#define SPA_TYPE_ROOT
Definition type-info.h:26
SPA_ID_INVALID
#define SPA_ID_INVALID
Definition defs.h:250
string.h
spa/utils/string.h
spa_type_info
Definition type.h:154
spa_type_info::type
uint32_t type
Definition type.h:155
type-info.h
spa/utils/type-info.h