XMMS2
Typedefs | Functions
Iteration
Dictionaries

Typedefs

typedef void(* xmmsv_dict_foreach_func )(const char *key, xmmsv_t *value, void *user_data)
typedef struct xmmsv_dict_iter_St xmmsv_dict_iter_t

Functions

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.
int xmmsv_get_dict_iter (const xmmsv_t *val, xmmsv_dict_iter_t **it)
 Retrieves a dict iterator from a dict xmmsv_t.
void xmmsv_dict_iter_explicit_destroy (xmmsv_dict_iter_t *it)
 Explicitly free dict iterator.
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.
int xmmsv_dict_iter_valid (xmmsv_dict_iter_t *it)
 Check whether the iterator is valid and points to a valid pair.
void xmmsv_dict_iter_first (xmmsv_dict_iter_t *it)
 Rewind the iterator to the start of the dict.
void xmmsv_dict_iter_next (xmmsv_dict_iter_t *it)
 Advance the iterator to the next pair in the dict.
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).
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.
int xmmsv_dict_iter_remove (xmmsv_dict_iter_t *it)
 Remove the pair in the dict pointed at by the iterator.
int xmmsv_dict_iter_pair_string (xmmsv_dict_iter_t *it, const char **key, const char **r)
int xmmsv_dict_iter_pair_int (xmmsv_dict_iter_t *it, const char **key, int32_t *r)
int xmmsv_dict_iter_pair_coll (xmmsv_dict_iter_t *it, const char **key, xmmsv_coll_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, int32_t elem)
int xmmsv_dict_iter_set_coll (xmmsv_dict_iter_t *it, xmmsv_coll_t *elem)

Typedef Documentation

typedef void(* xmmsv_dict_foreach_func)(const char *key, xmmsv_t *value, void *user_data)

Definition at line 56 of file xmmsv_dict.h.

typedef struct xmmsv_dict_iter_St xmmsv_dict_iter_t

Definition at line 59 of file xmmsv_dict.h.


Function Documentation

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.

No particular order is assumed.

Parameters:
dictvA xmmsv_t containing a dict.
functionThe function to apply to each key-element pair.
user_dataUser data passed to the foreach function.
Returns:
1 upon success otherwise 0

Definition at line 1853 of file value.c.

Referenced by xmmsv_coll_attribute_foreach().

Explicitly free dict iterator.

Immediately frees any resources used by this iterator. The iterator is freed automatically when the dict is freed, but this function is useful when the dict can be long lived.

Parameters:
ititerator to free

Definition at line 1931 of file value.c.

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).

Parameters:
itA xmmsv_dict_iter_t.
keyThe key to seek for.
Returns:
1 upon success otherwise 0

Definition at line 2028 of file value.c.

Referenced by xmmsv_dict_format(), xmmsv_dict_get(), xmmsv_dict_remove(), and xmmsv_dict_set().

Rewind the iterator to the start of the dict.

Parameters:
itA xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 1995 of file value.c.

Advance the iterator to the next pair in the dict.

Parameters:
itA xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 2009 of file value.c.

Referenced by xmmsv_dict_foreach(), and xmmsv_propdict_to_dict().

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.

This function does not increase the refcount of the element, the reference is still owned by the dict.

Parameters:
itA xmmsv_dict_iter_t.
keyPointer set to the key pointed at by the iterator.
valPointer set to a borrowed reference to the element pointed at by the iterator.
Returns:
1 upon success otherwise 0

Definition at line 1948 of file value.c.

Referenced by xmmsv_dict_foreach(), xmmsv_dict_format(), xmmsv_dict_get(), and xmmsv_propdict_to_dict().

int xmmsv_dict_iter_pair_coll ( xmmsv_dict_iter_t it,
const char **  key,
xmmsv_coll_t **  r 
)
int xmmsv_dict_iter_pair_int ( xmmsv_dict_iter_t it,
const char **  key,
int32_t *  r 
)
int xmmsv_dict_iter_pair_string ( xmmsv_dict_iter_t it,
const char **  key,
const char **  r 
)

Remove the pair in the dict pointed at by the iterator.

Parameters:
itA xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 2128 of file value.c.

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.

Parameters:
itA xmmsv_dict_iter_t.
valThe element to set in the pair.
Returns:
1 upon success otherwise 0

Definition at line 2101 of file value.c.

Referenced by xmmsv_dict_set().

int xmmsv_dict_iter_set_int ( xmmsv_dict_iter_t it,
int32_t  elem 
)
int xmmsv_dict_iter_set_string ( xmmsv_dict_iter_t it,
const char *  elem 
)

Check whether the iterator is valid and points to a valid pair.

Parameters:
itA xmmsv_dict_iter_t.
Returns:
1 if the iterator is valid, 0 otherwise

Definition at line 1983 of file value.c.

Referenced by xmmsv_dict_foreach(), xmmsv_dict_iter_pair(), xmmsv_dict_iter_set(), and xmmsv_propdict_to_dict().

int xmmsv_get_dict_iter ( const xmmsv_t val,
xmmsv_dict_iter_t **  it 
)

Retrieves a dict iterator from a dict xmmsv_t.

Parameters:
vala xmmsv_t containing a dict.
itAn xmmsv_dict_iter_t that can be used to access the dict data. The iterator will be freed when the value is freed.
Returns:
1 upon success otherwise 0

Definition at line 955 of file value.c.

Referenced by xmmsv_dict_foreach(), xmmsv_dict_format(), xmmsv_dict_get(), xmmsv_dict_remove(), xmmsv_dict_set(), and xmmsv_propdict_to_dict().