Go to the documentation of this file.
33 #ifndef __WEED_UTILS_H__
34 #define __WEED_UTILS_H__
41 #ifndef NEED_LOCAL_WEED
50 #define WEED_LEAF_GET(plant, key, type) weed_get_##type##_value(plant, key, NULL)
51 #define WEED_LEAF_GET_ARRAY_COUNTED(plant, key, type, counter) weed_get_##type##_array_counted(plant, key, &count)
52 #define WEED_LEAF_SET(plant, key, type, value) weed_set_##type##_value(plant, key, value)
53 #define WEED_LEAF_SET_ARRAY(plant, key, type, nvals, array) weed_set_##type##_array(plant, key, nvals, array)
55 #if defined(__WEED_HOST__) || defined(__LIBWEED__)
56 typedef int (*weed_memcmp_f)(
const void *,
const void *, size_t);
143 #ifdef __WEED_EFFECTS_H__
147 int32_t plugin_filter_min_api_version, int32_t plugin_filter_max_api_version);
157 #ifdef __WEED_PLUGIN__
160 #define FN_TYPE static inline
164 #ifdef __weed_get_value__
165 #undef __weed_get_value__
167 #ifdef __weed_check_leaf__
168 #undef __weed_check_leaf__
171 #define __weed_get_value__(plant, key, value) weed_leaf_get(plant, key, 0, value)
172 #define __weed_check_leaf__(plant, key) __weed_get_value__(plant, key, NULL)
178 #define _WEED_SET_(stype) return weed_leaf_set(plant, key, WEED_SEED_##stype, 1, (weed_voidptr_t)&value);
199 if ((*perr = __weed_leaf_check__(plant, key, seed_type)) ==
WEED_SUCCESS) *perr = __weed_get_value__(plant, key, retval);
202 #define _WEED_GET_(ctype, stype) ctype retval; \
203 return *((ctype *)(__weed_value_get__(plant, key, WEED_SEED_##stype, (weed_voidptr_t)&retval, error)));
212 char *retval = NULL;
weed_error_t err, *perr = (error ? error : &err);
216 retval = *((
char **)(__weed_value_get__(plant, key,
WEED_SEED_STRING, &retval, perr)));
233 if (nvals) *nvals = 0;
241 if (nvals) *nvals = (int)num_elems;
246 weed_error_t err, *perr = (error ? error : &err);
char *retvals = NULL;
247 if ((*perr = __weed_leaf_check__(plant, key, seed_type)) !=
WEED_SUCCESS)
return NULL;
248 *perr = __weed_get_values__(plant, key, typelen, (
char **)&retvals, nvals);
return retvals;}
250 #define _ARRAY_COUNT_(ctype, stype) \
251 return (ctype *)(__weed_get_arrayx__(plant, key, WEED_SEED_##stype, sizeof(ctype), NULL, count));
252 #define _ARRAY_NORM_(ctype, stype) \
253 return (ctype *)(__weed_get_arrayx__(plant, key, WEED_SEED_##stype, sizeof(ctype), error, NULL));
261 _ARRAY_COUNT_(int32_t, BOOLEAN)}
263 _ARRAY_NORM_(int32_t, BOOLEAN)}
269 if (count) *count = 0;
274 for (i = 0; i < num_elems; i++) {
281 if (count) *count = num_elems;
311 #define _SET_ARRAY_(stype) return weed_leaf_set(plant, key, WEED_SEED_##stype, num_elems, (weed_voidptr_t)values);
321 _SET_ARRAY_(BOOLEAN)}
330 _SET_ARRAY_(FUNCPTR)}
333 _SET_ARRAY_(VOIDPTR)}
336 _SET_ARRAY_(PLANTPTR)}
339 #undef __weed_get_value__
340 #undef __weed_check_leaf__
343 #define WEED_LEAF_MIN_WEED_API_VERSION "min_weed_api_version"
344 #define WEED_LEAF_MAX_WEED_API_VERSION "max_weed_api_version"
345 #define WEED_LEAF_MIN_WEED_ABI_VERSION WEED_LEAF_MIN_WEED_API_VERSION
346 #define WEED_LEAF_MAX_WEED_ABI_VERSION WEED_LEAF_MAX_WEED_API_VERSION
347 #define WEED_LEAF_MIN_FILTER_API_VERSION "min_weed_filter_version"
348 #define WEED_LEAF_MAX_FILTER_API_VERSION "max_weed_filter_version"
354 #endif // #ifndef __WEED_UTILS_H__
weed_error_t weed_set_boolean_value(weed_plant_t *plant, const char *key, int32_t value)
Definition: weed-utils.c:100
int32_t weed_error_t
Definition: weed.h:70
weed_voidptr_t * weed_get_custom_array_counted(weed_plant_t *plant, const char *key, uint32_t seed_type, int *count)
Definition: weed-utils.c:378
weed_error_t weed_set_plantptr_value(weed_plant_t *plant, const char *key, weed_plant_t *value)
Definition: weed-utils.c:125
uint32_t weed_size_t
Definition: weed.h:69
weed_error_t weed_set_custom_value(weed_plant_t *plant, const char *key, uint32_t seed_type, weed_voidptr_t value)
Definition: weed-utils.c:130
weed_plant_t ** weed_get_plantptr_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:374
int64_t * weed_get_int64_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:307
__WEED_FN_DEF__ weed_calloc_f weed_calloc
Definition: weed.h:200
weed_error_t weed_set_boolean_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, int32_t *values)
Definition: weed-utils.c:395
char ** __weed_get_string_array__(weed_plant_t *plant, const char *key, weed_error_t *error, int *count)
Definition: weed-utils.c:312
weed_error_t weed_set_plantptr_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, weed_plant_t **values)
Definition: weed-utils.c:415
__WEED_FN_DEF__ weed_leaf_get_f weed_leaf_get
Definition: weed.h:179
int weed_plant_has_leaf(weed_plant_t *plant, const char *key)
Definition: weed-utils.c:73
weed_error_t weed_leaf_dup(weed_plant_t *dst, weed_plant_t *src, const char *key)
Definition: weed-utils.c:652
weed_error_t weed_set_int_value(weed_plant_t *plant, const char *key, int32_t value)
Definition: weed-utils.c:90
int32_t * weed_get_boolean_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:297
#define WEED_TRUE
Definition: weed.h:53
weed_error_t weed_leaf_dup_nth(weed_plant_t *dst, weed_plant_t *src, const char *key, int n)
Definition: weed-utils.c:656
weed_error_t weed_set_int64_value(weed_plant_t *plant, const char *key, int64_t value)
Definition: weed-utils.c:105
weed_funcptr_t * weed_get_funcptr_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:357
weed_leaf_t weed_plant_t
Definition: weed.h:125
int32_t weed_get_plant_type(weed_plant_t *plant)
Definition: weed-utils.c:426
weed_voidptr_t weed_get_voidptr_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:212
int check_weed_abi_compat(int32_t higher, int32_t lower)
Definition: weed-utils.c:802
weed_error_t weed_set_funcptr_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, weed_funcptr_t *values)
Definition: weed-utils.c:407
int weed_leaf_elements_equate(weed_plant_t *p0, const char *k0, weed_plant_t *p1, const char *k1, int elem)
Definition: weed-utils.c:660
weed_plant_t * weed_get_plantptr_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:228
#define WEED_SEED_STRING
Definition: weed.h:229
weed_voidptr_t * weed_get_voidptr_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:367
weed_error_t weed_set_voidptr_value(weed_plant_t *plant, const char *key, weed_voidptr_t value)
Definition: weed-utils.c:120
weed_error_t weed_set_custom_array(weed_plant_t *plant, const char *key, uint32_t seed_type, weed_size_t num_elems, weed_voidptr_t *values)
Definition: weed-utils.c:419
void weed_set_host_info_callback(weed_host_info_callback_f cb, void *user_data)
Definition: weed-utils.c:796
int32_t weed_get_int_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:154
weed_error_t weed_set_int_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, int32_t *values)
Definition: weed-utils.c:387
int check_filter_api_compat(int32_t higher, int32_t lower)
Definition: weed-utils.c:816
int32_t weed_get_boolean_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:170
weed_voidptr_t * weed_get_voidptr_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:364
__WEED_FN_DEF__ weed_leaf_element_size_f weed_leaf_element_size
Definition: weed.h:184
double weed_get_double_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:162
#define WEED_ERROR_MEMORY_ALLOCATION
Definition: weed.h:211
double * weed_get_double_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:293
weed_error_t weed_set_double_value(weed_plant_t *plant, const char *key, double value)
Definition: weed-utils.c:95
weed_error_t weed_leaf_copy_nth(weed_plant_t *dst, const char *keyt, weed_plant_t *src, const char *keyf, int n)
Definition: weed-utils.c:432
char ** weed_get_string_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:353
int32_t * weed_get_int_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:283
int64_t weed_get_int64_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:178
char * weed_get_string_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:186
weed_voidptr_t weed_get_custom_value(weed_plant_t *plant, const char *key, uint32_t seed_type, weed_error_t *error)
Definition: weed-utils.c:236
weed_plant_t * weed_bootstrap(weed_default_getter_f *value, int32_t plugin_min_weed_abi_version, int32_t plugin_max_weed_abi_version, int32_t plugin_min_filter_api_version, int32_t plugin_max_filter_api_version)
Definition: weed-utils.c:849
weed_error_t weed_set_voidptr_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, weed_voidptr_t *values)
Definition: weed-utils.c:411
weed_error_t weed_set_funcptr_value(weed_plant_t *plant, const char *key, weed_voidptr_t value)
Definition: weed-utils.c:115
#define WEED_ERROR_WRONG_SEED_TYPE
Definition: weed.h:214
weed_funcptr_t weed_get_funcptr_value(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:220
int weed_leaf_exists(weed_plant_t *plant, const char *key)
Definition: weed-utils.c:80
weed_error_t weed_set_double_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, double *values)
Definition: weed-utils.c:391
__WEED_FN_DEF__ weed_malloc_f weed_malloc
Definition: weed.h:193
weed_funcptr_t * weed_get_funcptr_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:360
__WEED_FN_DEF__ weed_leaf_seed_type_f weed_leaf_seed_type
Definition: weed.h:185
weed_error_t weed_set_string_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, char **values)
Definition: weed-utils.c:403
weed_error_t(* weed_default_getter_f)(weed_plant_t *plant, const char *key, void *value)
Definition: weed-effects.h:149
#define WEED_SUCCESS
Definition: weed.h:210
void *(* weed_calloc_f)(size_t, size_t)
Definition: weed.h:137
weed_error_t weed_set_string_value(weed_plant_t *plant, const char *key, const char *value)
Definition: weed-utils.c:110
void * weed_voidptr_t
Definition: weed.h:71
__WEED_FN_DEF__ weed_leaf_num_elements_f weed_leaf_num_elements
Definition: weed.h:183
__WEED_FN_DEF__ weed_free_f weed_free
Definition: weed.h:194
int32_t * weed_get_boolean_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:300
void(* weed_free_f)(void *)
Definition: weed.h:131
#define WEED_FALSE
Definition: weed.h:54
weed_error_t weed_set_int64_array(weed_plant_t *plant, const char *key, weed_size_t num_elems, int64_t *values)
Definition: weed-utils.c:399
char ** weed_get_string_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:350
void(* weed_funcptr_t)()
Definition: weed.h:72
weed_plant_t ** weed_get_plantptr_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:371
void weed_utils_set_custom_memfuncs(weed_malloc_f malloc_func, weed_calloc_f calloc_func, weed_memcpy_f memcpy_func, weed_memcmp_f memcmp_func, weed_free_f free_func)
Definition: weed-utils.c:63
double * weed_get_double_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:290
int64_t * weed_get_int64_array_counted(weed_plant_t *plant, const char *key, int *count)
Definition: weed-utils.c:304
int32_t * weed_get_int_array(weed_plant_t *plant, const char *key, weed_error_t *error)
Definition: weed-utils.c:286
weed_voidptr_t * weed_get_custom_array(weed_plant_t *plant, const char *key, uint32_t seed_type, weed_error_t *error)
Definition: weed-utils.c:381
weed_plant_t * weed_plant_copy(weed_plant_t *src)
Definition: weed-utils.c:707
weed_plant_t * weed_plantptr_t
Definition: weed.h:128
void *(* weed_memcpy_f)(void *, const void *, size_t)
Definition: weed.h:133
weed_error_t weed_leaf_copy(weed_plant_t *dst, const char *keyt, weed_plant_t *src, const char *keyf)
Definition: weed-utils.c:648
void *(* weed_malloc_f)(size_t)
Definition: weed.h:130