PipeWire 1.3.0
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 return spa_type_short_name(name);
43}
44
45static inline const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
46{
47 if ((info = spa_debug_type_find(info, type)) == NULL)
48 return NULL;
49 return info->name;
51
52static inline const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type)
53{
54 const char *str;
55 if ((str = spa_debug_type_find_name(info, type)) == NULL)
56 return NULL;
58}
59
60static inline uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)
61{
62 if (info == NULL)
63 info = SPA_TYPE_ROOT;
64
65 while (info && info->name) {
66 uint32_t res;
67 if (strcmp(info->name, name) == 0)
68 return info->type;
69 if (info->values && (res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID)
70 return res;
71 info++;
72 }
73 return SPA_ID_INVALID;
74}
75
76static inline const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
77{
78 while (info && info->name) {
79 if (strcmp(spa_debug_type_short_name(info->name), name) == 0)
80 return info;
81 if (strcmp(info->name, name) == 0)
82 return info;
83 if (info->type != 0 && info->type == (uint32_t)atoi(name))
84 return info;
85 info++;
86 }
87 return NULL;
88}
89
90static inline uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
91{
92 if ((info = spa_debug_type_find_short(info, name)) == NULL)
93 return SPA_ID_INVALID;
94 return info->type;
100#ifdef __cplusplus
101} /* extern "C" */
102#endif
103
104#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:65
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:50
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:57
static const struct spa_type_info * spa_debug_type_find_short(const struct spa_type_info *info, const char *name)
Definition types.h:81
static uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name)
Definition types.h:95
static const char * spa_type_short_name(const char *name)
Definition type.h:156
#define SPA_TYPE_ROOT
Definition type-info.h:26
#define SPA_ID_INVALID
Definition defs.h:250
spa/utils/string.h
Definition type.h:144
uint32_t type
Definition type.h:145
spa/utils/type-info.h