XMMS2
Typedefs | Functions
Iteration
Lists

Typedefs

typedef void(* xmmsv_list_foreach_func )(xmmsv_t *value, void *user_data)
typedef struct xmmsv_list_iter_St xmmsv_list_iter_t

Functions

int xmmsv_list_foreach (xmmsv_t *listv, xmmsv_list_foreach_func func, void *user_data)
 Apply a function to each element in the list, in sequential order.
int xmmsv_get_list_iter (const xmmsv_t *val, xmmsv_list_iter_t **it)
 Retrieves a list iterator from a list xmmsv_t.
void xmmsv_list_iter_explicit_destroy (xmmsv_list_iter_t *it)
 Explicitly free list iterator.
int xmmsv_list_iter_entry (xmmsv_list_iter_t *it, xmmsv_t **val)
 Get the element currently pointed at by the iterator.
int xmmsv_list_iter_valid (xmmsv_list_iter_t *it)
 Check whether the iterator is valid and points to a valid element.
void xmmsv_list_iter_first (xmmsv_list_iter_t *it)
 Rewind the iterator to the start of the list.
void xmmsv_list_iter_last (xmmsv_list_iter_t *it)
 Move the iterator to end of the list.
void xmmsv_list_iter_next (xmmsv_list_iter_t *it)
 Advance the iterator to the next element in the list.
void xmmsv_list_iter_prev (xmmsv_list_iter_t *it)
 Move the iterator to the previous element in the list.
int xmmsv_list_iter_seek (xmmsv_list_iter_t *it, int pos)
 Move the iterator to the n-th element in the list.
int xmmsv_list_iter_tell (const xmmsv_list_iter_t *it)
 Tell the position of the iterator.
xmmsv_txmmsv_list_iter_get_parent (const xmmsv_list_iter_t *it)
 Return the parent xmmsv_t of an iterator.
int xmmsv_list_iter_insert (xmmsv_list_iter_t *it, xmmsv_t *val)
 Insert an element in the list at the position pointed at by the iterator.
int xmmsv_list_iter_remove (xmmsv_list_iter_t *it)
 Remove the element in the list at the position pointed at by the iterator.
int xmmsv_list_iter_entry_string (xmmsv_list_iter_t *it, const char **val)
int xmmsv_list_iter_entry_int (xmmsv_list_iter_t *it, int32_t *val)
int xmmsv_list_iter_entry_coll (xmmsv_list_iter_t *it, xmmsv_coll_t **val)
int xmmsv_list_iter_insert_string (xmmsv_list_iter_t *it, const char *val)
int xmmsv_list_iter_insert_int (xmmsv_list_iter_t *it, int32_t val)
int xmmsv_list_iter_insert_coll (xmmsv_list_iter_t *it, xmmsv_coll_t *val)

Typedef Documentation

typedef void(* xmmsv_list_foreach_func)(xmmsv_t *value, void *user_data)

Definition at line 66 of file xmmsv_list.h.

typedef struct xmmsv_list_iter_St xmmsv_list_iter_t

Definition at line 69 of file xmmsv_list.h.


Function Documentation

int xmmsv_get_list_iter ( const xmmsv_t val,
xmmsv_list_iter_t **  it 
)

Retrieves a list iterator from a list xmmsv_t.

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

Definition at line 926 of file value.c.

Referenced by check_string_list(), xmmsv_coll_add_operand(), xmmsv_coll_get_idlist(), xmmsv_coll_remove_operand(), xmmsv_list_foreach(), and xmmsv_list_restrict_type().

int xmmsv_list_foreach ( xmmsv_t listv,
xmmsv_list_foreach_func  func,
void *  user_data 
)

Apply a function to each element in the list, in sequential order.

Parameters:
listvA xmmsv_t containing a list.
functionThe function to apply to each element.
user_dataUser data passed to the foreach function.
Returns:
1 upon success otherwise 0

Definition at line 1375 of file value.c.

int xmmsv_list_iter_entry ( xmmsv_list_iter_t it,
xmmsv_t **  val 
)

Get the element currently pointed at by the iterator.

This function does not increase the refcount of the element, the reference is still owned by the list. If iterator does not point on a valid element xmmsv_list_iter_entry returns 0 and leaves val untouched.

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

Definition at line 1495 of file value.c.

Referenced by check_string_list(), xmmsv_dict_iter_find(), xmmsv_dict_iter_pair(), xmmsv_list_foreach(), and xmmsv_list_restrict_type().

int xmmsv_list_iter_entry_int ( xmmsv_list_iter_t it,
int32_t *  val 
)

Referenced by xmmsv_coll_get_idlist().

int xmmsv_list_iter_entry_string ( xmmsv_list_iter_t it,
const char **  val 
)

Explicitly free list iterator.

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

Parameters:
ititerator to free

Definition at line 1478 of file value.c.

Referenced by xmmsv_coll_add_operand(), and xmmsv_coll_remove_operand().

Rewind the iterator to the start of the list.

Parameters:
itA xmmsv_list_iter_t.

Definition at line 1523 of file value.c.

Referenced by xmmsv_dict_iter_first().

Return the parent xmmsv_t of an iterator.

Parameters:
itA xmmsv_list_iter_t.
Returns:
The parent xmmsv_t of the iterator, or NULL if invalid.

Definition at line 1620 of file value.c.

Insert an element in the list at the position pointed at by the iterator.

Parameters:
itA xmmsv_list_iter_t.
valThe element to insert.
Returns:
1 upon success otherwise 0

Definition at line 1636 of file value.c.

Referenced by xmmsv_dict_iter_set(), and xmmsv_dict_set().

int xmmsv_list_iter_insert_int ( xmmsv_list_iter_t it,
int32_t  val 
)
int xmmsv_list_iter_insert_string ( xmmsv_list_iter_t it,
const char *  val 
)

Move the iterator to end of the list.

Parameters:
listvA xmmsv_list_iter_t.

Definition at line 1536 of file value.c.

Move the iterator to the previous element in the list.

Parameters:
listvA xmmsv_list_iter_t.

Definition at line 1568 of file value.c.

Remove the element in the list at the position pointed at by the iterator.

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

Definition at line 1652 of file value.c.

Referenced by xmmsv_coll_remove_operand(), xmmsv_dict_iter_remove(), xmmsv_dict_iter_set(), xmmsv_dict_remove(), and xmmsv_dict_set().

int xmmsv_list_iter_seek ( xmmsv_list_iter_t it,
int  pos 
)

Move the iterator to the n-th element in the list.

Parameters:
itA xmmsv_list_iter_t.
posThe position in the list. If negative, start counting from the end (-1 is the last element, etc).
Returns:
1 upon success otherwise 0

Definition at line 1587 of file value.c.

Referenced by xmmsv_dict_iter_find().

Tell the position of the iterator.

Parameters:
itA xmmsv_list_iter_t.
Returns:
The position of the iterator, or -1 if invalid.

Definition at line 1606 of file value.c.

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

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

Definition at line 1512 of file value.c.

Referenced by check_string_list(), xmmsv_coll_get_idlist(), xmmsv_dict_iter_valid(), xmmsv_list_foreach(), xmmsv_list_iter_entry(), and xmmsv_list_restrict_type().