XMMS2
Macros | Typedefs | Functions
xmmsv_dict.c File Reference
#include <stdlib.h>
#include <string.h>
#include <xmmscpriv/xmmsv.h>
#include <xmmscpriv/xmms_list.h>

Macros

#define HASH_MASK(table)   ((1 << (table)->size) - 1)
 
#define HASH_FILL_LIM   7
 
#define DELETED_STR   ((char*)-1)
 
#define DICT_INIT_DATA(s)   {.hash = _xmmsv_dict_hash (s, strlen (s)), .str = (char*)s}
 
#define START_SIZE   2
 
#define GEN_DICT_EXTRACTOR_FUNC(typename, type)
 
#define GEN_DICT_SET_FUNC(typename, type)
 
#define GEN_DICT_ITER_EXTRACTOR_FUNC(typename, type)
 
#define GEN_DICT_ITER_SET_FUNC(typename, type)
 

Typedefs

typedef struct xmmsv_dict_data_St xmmsv_dict_data_t
 

Functions

void _xmmsv_dict_free (xmmsv_dict_internal_t *dict)
 
xmmsv_txmmsv_new_dict (void)
 Allocates a new dict xmmsv_t. More...
 
int xmmsv_dict_has_key (xmmsv_t *dictv, const char *key)
 
int xmmsv_dict_keys (xmmsv_t *dictv, xmmsv_t **keys)
 Get a XMMSV_TYPE_LIST of all the keys. More...
 
int xmmsv_dict_values (xmmsv_t *dictv, xmmsv_t **values)
 Get a XMMSV_TYPE_LIST of all the values. More...
 
xmmsv_type_t xmmsv_dict_entry_get_type (xmmsv_t *val, const char *key)
 Gets the type of a dict entry. More...
 
int xmmsv_dict_get (xmmsv_t *dictv, const char *key, xmmsv_t **val)
 Get the element corresponding to the given key in the dict xmmsv_t (if it exists). More...
 
int xmmsv_dict_set (xmmsv_t *dictv, const char *key, xmmsv_t *val)
 Insert an element under the given key in the dict xmmsv_t. More...
 
int xmmsv_dict_remove (xmmsv_t *dictv, const char *key)
 Remove the element corresponding to a given key in the dict xmmsv_t (if it exists). More...
 
int xmmsv_dict_clear (xmmsv_t *dictv)
 Empty the dict of all its elements. More...
 
int xmmsv_dict_foreach (xmmsv_t *dictv, xmmsv_dict_foreach_func func, void *user_data)
 Apply a function to each key-element pair in the list. More...
 
int xmmsv_dict_get_size (xmmsv_t *dictv)
 Return the size of the dict. More...
 
int xmmsv_get_dict_iter (const xmmsv_t *val, xmmsv_dict_iter_t **it)
 Retrieves a dict iterator from a dict xmmsv_t. More...
 
void xmmsv_dict_iter_explicit_destroy (xmmsv_dict_iter_t *it)
 Explicitly free dict iterator. More...
 
int xmmsv_dict_iter_pair (xmmsv_dict_iter_t *it, const char **key, xmmsv_t **val)
 Get the key-element pair currently pointed at by the iterator. More...
 
int xmmsv_dict_iter_valid (xmmsv_dict_iter_t *it)
 Check whether the iterator is valid and points to a valid pair. More...
 
void xmmsv_dict_iter_first (xmmsv_dict_iter_t *it)
 Rewind the iterator to the start of the dict. More...
 
void xmmsv_dict_iter_next (xmmsv_dict_iter_t *it)
 Advance the iterator to the next pair in the dict. More...
 
int xmmsv_dict_iter_find (xmmsv_dict_iter_t *it, const char *key)
 Move the iterator to the pair with the given key (if it exists) or move it to the position where the key would have to be put (if it doesn't exist yet). More...
 
int xmmsv_dict_iter_set (xmmsv_dict_iter_t *it, xmmsv_t *val)
 Replace the element of the pair currently pointed to by the iterator. More...
 
int xmmsv_dict_iter_remove (xmmsv_dict_iter_t *it)
 Remove the pair in the dict pointed at by the iterator. More...
 
int xmmsv_dict_entry_get_string (xmmsv_t *val, const char *key, const char **r)
 
int xmmsv_dict_entry_get_int32 (xmmsv_t *val, const char *key, int32_t *r)
 
int xmmsv_dict_entry_get_int64 (xmmsv_t *val, const char *key, int64_t *r)
 
int xmmsv_dict_entry_get_float (xmmsv_t *val, const char *key, float *r)
 
int xmmsv_dict_entry_get_coll (xmmsv_t *val, const char *key, xmmsv_t **r)
 
int xmmsv_dict_set_string (xmmsv_t *dict, const char *key, const char *elem)
 
int xmmsv_dict_set_int (xmmsv_t *dict, const char *key, int64_t elem)
 
int xmmsv_dict_set_float (xmmsv_t *dict, const char *key, float elem)
 
int xmmsv_dict_set_coll (xmmsv_t *dict, const char *key, xmmsv_t *elem)
 
int xmmsv_dict_iter_pair_string (xmmsv_dict_iter_t *it, const char **key, const char **r)
 
int xmmsv_dict_iter_pair_int32 (xmmsv_dict_iter_t *it, const char **key, int32_t *r)
 
int xmmsv_dict_iter_pair_int64 (xmmsv_dict_iter_t *it, const char **key, int64_t *r)
 
int xmmsv_dict_iter_pair_float (xmmsv_dict_iter_t *it, const char **key, float *r)
 
int xmmsv_dict_iter_pair_coll (xmmsv_dict_iter_t *it, const char **key, xmmsv_t **r)
 
int xmmsv_dict_iter_set_string (xmmsv_dict_iter_t *it, const char *elem)
 
int xmmsv_dict_iter_set_int (xmmsv_dict_iter_t *it, int64_t elem)
 
int xmmsv_dict_iter_set_float (xmmsv_dict_iter_t *it, float elem)
 
int xmmsv_dict_iter_set_coll (xmmsv_dict_iter_t *it, xmmsv_t *elem)
 

Macro Definition Documentation

#define DELETED_STR   ((char*)-1)
#define DICT_INIT_DATA (   s)    {.hash = _xmmsv_dict_hash (s, strlen (s)), .str = (char*)s}
#define GEN_DICT_EXTRACTOR_FUNC (   typename,
  type 
)
Value:
int \
xmmsv_dict_entry_get_##typename (xmmsv_t *val, const char *key, \
type *r) \
{ \
xmmsv_t *v; \
if (!xmmsv_dict_get (val, key, &v)) { \
return 0; \
} \
return xmmsv_get_##typename (v, r); \
}
#define GEN_DICT_ITER_EXTRACTOR_FUNC (   typename,
  type 
)
Value:
int \
xmmsv_dict_iter_pair_##typename (xmmsv_dict_iter_t *it, \
const char **key, \
type *r) \
{ \
xmmsv_t *v; \
if (!xmmsv_dict_iter_pair (it, key, &v)) { \
return 0; \
} \
if (r) { \
return xmmsv_get_##typename (v, r); \
} else { \
return 1; \
} \
}
#define GEN_DICT_ITER_SET_FUNC (   typename,
  type 
)
Value:
int \
xmmsv_dict_iter_set_##typename (xmmsv_dict_iter_t *it, type elem) \
{ \
int ret; \
xmmsv_t *v; \
\
v = xmmsv_new_##typename (elem); \
ret = xmmsv_dict_iter_set (it, v); \
\
return ret; \
}
#define GEN_DICT_SET_FUNC (   typename,
  type 
)
Value:
int \
xmmsv_dict_set_##typename (xmmsv_t *dict, const char *key, type elem) \
{ \
int ret; \
xmmsv_t *v; \
\
v = xmmsv_new_##typename (elem); \
ret = xmmsv_dict_set (dict, key, v); \
\
return ret; \
}
#define HASH_FILL_LIM   7

Referenced by xmmsv_dict_set().

#define HASH_MASK (   table)    ((1 << (table)->size) - 1)
#define START_SIZE   2

Typedef Documentation

typedef struct xmmsv_dict_data_St xmmsv_dict_data_t

Function Documentation

void _xmmsv_dict_free ( xmmsv_dict_internal_t *  dict)