properties.h
Go to the documentation of this file.
/* PipeWire
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_PROPERTIES_H__
#define __PIPEWIRE_PROPERTIES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/dict.h>
struct pw_properties {
struct spa_dict dict;
};
struct pw_properties *
pw_properties_new(const char *key, ...) SPA_SENTINEL;
struct pw_properties *
pw_properties_new_dict(const struct spa_dict *dict);
struct pw_properties *
pw_properties_new_string(const char *args);
struct pw_properties *
pw_properties_copy(const struct pw_properties *properties);
struct pw_properties *
pw_properties_merge(const struct pw_properties *oldprops,
struct pw_properties *newprops);
void
pw_properties_free(struct pw_properties *properties);
int
pw_properties_set(struct pw_properties *properties, const char *key, const char *value);
int
pw_properties_setf(struct pw_properties *properties,
const char *key, const char *format, ...) SPA_PRINTF_FUNC(3, 4);
const char *
pw_properties_get(const struct pw_properties *properties, const char *key);
const char *
pw_properties_iterate(const struct pw_properties *properties, void **state);
static inline bool pw_properties_parse_bool(const char *value) {
return (strcmp(value, "true") == 0 || atoi(value) == 1);
}
static inline int pw_properties_parse_int(const char *value) {
return strtol(value, NULL, 0);
}
static inline int64_t pw_properties_parse_int64(const char *value) {
return strtoll(value, NULL, 0);
}
static inline uint64_t pw_properties_parse_uint64(const char *value) {
return strtoull(value, NULL, 0);
}
static inline float pw_properties_parse_float(const char *value) {
return strtof(value, NULL);
}
static inline double pw_properties_parse_double(const char *value) {
return strtod(value, NULL);
}
#ifdef __cplusplus
}
#endif
#endif /* __PIPEWIRE_PROPERTIES_H__ */
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:89
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
pw_properties::pw_properties_copy
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:183
pw_properties::pw_properties_get
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
pw_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:338
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:308
pw_properties::pw_properties_new_dict
SPA_EXPORT struct pw_properties * pw_properties_new_dict(const struct spa_dict *dict)
Make a new properties object from the given dictionary.
Definition: properties.c:119
pw_properties::pw_properties_iterate
SPA_EXPORT const char * pw_properties_iterate(const struct pw_properties *properties, void **state)
Iterate property values.
Definition: properties.c:386
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:245
pw_properties::pw_properties_new_string
SPA_EXPORT struct pw_properties * pw_properties_new_string(const char *str)
Make a new properties object from the given str.
Definition: properties.c:149
pw_properties::pw_properties_merge
SPA_EXPORT struct pw_properties * pw_properties_merge(const struct pw_properties *oldprops, struct pw_properties *newprops)
Merge properties into one.
Definition: properties.c:211