ValueType

The API to be used to work with value objects. More...

Defines

#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)
#define GEN_LIST_EXTRACTOR_FUNC(typename, type)
#define GEN_LIST_SET_FUNC(typename, type)
#define GEN_LIST_INSERT_FUNC(typename, type)
#define GEN_LIST_APPEND_FUNC(typename, type)
#define GEN_LIST_ITER_EXTRACTOR_FUNC(typename, type)
#define GEN_LIST_ITER_INSERT_FUNC(typename, type)

Functions

xmmsv_t * xmmsv_new_none (void)
 Allocates a new empty xmmsv_t.
xmmsv_t * xmmsv_new_error (const char *errstr)
 Allocates a new error xmmsv_t.
xmmsv_t * xmmsv_new_int (int32_t i)
 Allocates a new integer xmmsv_t.
xmmsv_t * xmmsv_new_string (const char *s)
 Allocates a new string xmmsv_t.
xmmsv_t * xmmsv_new_coll (xmmsv_coll_t *c)
 Allocates a new collection xmmsv_t.
xmmsv_t * xmmsv_new_bin (unsigned char *data, unsigned int len)
 Allocates a new binary data xmmsv_t.
xmmsv_t * xmmsv_new_list (void)
 Allocates a new list xmmsv_t.
xmmsv_t * xmmsv_new_dict (void)
 Allocates a new dict xmmsv_t.
xmmsv_t * xmmsv_ref (xmmsv_t *val)
 References the xmmsv_t.
void xmmsv_unref (xmmsv_t *val)
 Decreases the references for the xmmsv_t When the number of references reaches 0 it will be freed.
xmmsv_type_t xmmsv_get_type (const xmmsv_t *val)
 Get the type of the value.
int xmmsv_is_type (const xmmsv_t *val, xmmsv_type_t t)
 Check if value is of specified type.
int xmmsv_is_error (const xmmsv_t *val)
 Check if the value stores an error.
int xmmsv_is_list (const xmmsv_t *val)
 Check if the value stores a list.
int xmmsv_is_dict (const xmmsv_t *val)
 Check if the value stores a dict.
const char * xmmsv_get_error_old (const xmmsv_t *val)
 Legacy alias to retrieve the error string from an xmmsv_t.
xmmsv_t * xmmsv_make_stringlist (char *array[], int num)
 Helper function to build a list xmmsv_t containing the strings from the input array.
xmmsv_type_t xmmsv_dict_entry_get_type (xmmsv_t *val, const char *key)
 Gets the type of a dict entry.
xmmsv_t * xmmsv_propdict_to_dict (xmmsv_t *propdict, const char **src_prefs)
 Helper function to transform a key-source-value dict-of-dict xmmsv_t (formerly a propdict) to a regular key-value dict, given a list of source preference.
int xmmsv_get_error (const xmmsv_t *val, const char **r)
 Retrieves an error string describing the server error from the value.
int xmmsv_get_int (const xmmsv_t *val, int32_t *r)
 Retrieves a signed integer from the value.
int xmmsv_get_uint (const xmmsv_t *val, uint32_t *r)
 Retrieves a unsigned integer from the value.
int xmmsv_get_string (const xmmsv_t *val, const char **r)
 Retrieves a string from the value.
int xmmsv_get_coll (const xmmsv_t *val, xmmsv_coll_t **c)
 Retrieves a collection from the value.
int xmmsv_get_bin (const xmmsv_t *val, const unsigned char **r, unsigned int *rlen)
 Retrieves binary data from the value.
int xmmsv_get_list_iter (const xmmsv_t *val, xmmsv_list_iter_t **it)
 Retrieves a list iterator from a list xmmsv_t.
int xmmsv_get_dict_iter (const xmmsv_t *val, xmmsv_dict_iter_t **it)
 Retrieves a dict iterator from a dict xmmsv_t.
int xmmsv_list_get (xmmsv_t *listv, int pos, xmmsv_t **val)
 Get the element at the given position in the list xmmsv_t.
int xmmsv_list_set (xmmsv_t *listv, int pos, xmmsv_t *val)
 Set the element at the given position in the list xmmsv_t.
int xmmsv_list_insert (xmmsv_t *listv, int pos, xmmsv_t *val)
 Insert an element at the given position in the list xmmsv_t.
int xmmsv_list_remove (xmmsv_t *listv, int pos)
 Remove the element at the given position from the list xmmsv_t.
int xmmsv_list_move (xmmsv_t *listv, int old_pos, int new_pos)
 Move the element from position old to position new.
int xmmsv_list_append (xmmsv_t *listv, xmmsv_t *val)
 Append an element to the end of the list xmmsv_t.
int xmmsv_list_clear (xmmsv_t *listv)
 Empty the list from all its elements.
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_list_get_size (xmmsv_t *listv)
 Return the size of the list.
int xmmsv_list_restrict_type (xmmsv_t *listv, xmmsv_type_t type)
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_t * xmmsv_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_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).
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.
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).
int xmmsv_dict_clear (xmmsv_t *dictv)
 Empty the dict of all its elements.
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_dict_get_size (xmmsv_t *dictv)
 Return the size of the dict.
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.
xmmsv_t * xmmsv_decode_url (const xmmsv_t *inv)
 Decode an URL-encoded string.
xmmsv_t * xmmsv_build_dict (const char *firstkey,...)
xmmsv_t * xmmsv_build_list_va (xmmsv_t *first_entry, va_list ap)
xmmsv_t * xmmsv_build_list (xmmsv_t *first_entry,...)
int xmmsv_dict_format (char *target, int len, const char *fmt, xmmsv_t *val)
 This function will make a pretty string about the information in xmmsv dict.
int xmmsv_utf8_validate (const char *str)
 Check if a string is valid UTF-8.

Detailed Description

The API to be used to work with value objects.


Define Documentation

#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);         \
    }

Definition at line 513 of file value.c.

#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; \
        } \
    }

Definition at line 549 of file value.c.

#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); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 571 of file value.c.

#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); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 530 of file value.c.

#define GEN_LIST_APPEND_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_append_##typename (xmmsv_t *list, type elem) \
    { \
        int ret; \
        xmmsv_t *v; \
 \
        v = xmmsv_new_##typename (elem); \
        ret = xmmsv_list_append (list, v); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 644 of file value.c.

#define GEN_LIST_EXTRACTOR_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_get_##typename (xmmsv_t *val, int pos, type *r) \
    { \
        xmmsv_t *v; \
        if (!xmmsv_list_get (val, pos, &v)) { \
            return 0; \
        } \
        return xmmsv_get_##typename (v, r); \
    }

Definition at line 590 of file value.c.

#define GEN_LIST_INSERT_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_insert_##typename (xmmsv_t *list, int pos, type elem) \
    { \
        int ret; \
        xmmsv_t *v; \
 \
        v = xmmsv_new_##typename (elem); \
        ret = xmmsv_list_insert (list, pos, v); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 625 of file value.c.

#define GEN_LIST_ITER_EXTRACTOR_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_iter_entry_##typename (xmmsv_list_iter_t *it, type *r) \
    { \
        xmmsv_t *v; \
        if (!xmmsv_list_iter_entry (it, &v)) { \
            return 0; \
        } \
        return xmmsv_get_##typename (v, r); \
    }

Definition at line 663 of file value.c.

#define GEN_LIST_ITER_INSERT_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_iter_insert_##typename (xmmsv_list_iter_t *it, type elem) \
    { \
        int ret; \
        xmmsv_t *v; \
 \
        v = xmmsv_new_##typename (elem); \
        ret = xmmsv_list_iter_insert (it, v); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 679 of file value.c.

#define GEN_LIST_SET_FUNC ( typename,
type   ) 
Value:
int \
    xmmsv_list_set_##typename (xmmsv_t *list, int pos, type elem) \
    { \
        int ret; \
        xmmsv_t *v; \
 \
        v = xmmsv_new_##typename (elem); \
        ret = xmmsv_list_set (list, pos, v); \
        xmmsv_unref (v); \
 \
        return ret; \
    }

Definition at line 606 of file value.c.


Function Documentation

xmmsv_t* xmmsv_build_dict ( const char *  firstkey,
  ... 
)

Definition at line 2213 of file value.c.

xmmsv_t* xmmsv_build_list ( xmmsv_t *  first_entry,
  ... 
)

Definition at line 2270 of file value.c.

xmmsv_t* xmmsv_build_list_va ( xmmsv_t *  first_entry,
va_list  ap 
)

Definition at line 2244 of file value.c.

Referenced by xmmsv_build_list().

xmmsv_t* xmmsv_decode_url ( const xmmsv_t *  inv  ) 

Decode an URL-encoded string.

Some strings (currently only the url of media) has no known encoding, and must be encoded in an UTF-8 clean way. This is done similar to the url encoding web browsers do. This functions decodes a string encoded in that way. OBSERVE that the decoded string HAS NO KNOWN ENCODING and you cannot display it on screen in a 100% guaranteed correct way (a good heuristic is to try to validate the decoded string as UTF-8, and if it validates assume that it is an UTF-8 encoded string, and otherwise fall back to some other encoding).

Do not use this function if you don't understand the implications. The best thing is not to try to display the url at all.

Note that the fact that the string has NO KNOWN ENCODING and CAN NOT BE DISPLAYED does not stop you from open the file if it is a local file (if it starts with "file://").

Parameters:
url the xmmsv_t containing a url-encoded string
Returns:
a new xmmsv_t containing the decoded string as a XMMSV_BIN or NULL on failure

Definition at line 2159 of file value.c.

int xmmsv_dict_clear ( xmmsv_t *  dictv  ) 

Empty the dict of all its elements.

Parameters:
dictv A xmmsv_t containing a dict.
Returns:
1 upon success otherwise 0

Definition at line 1825 of file value.c.

xmmsv_type_t xmmsv_dict_entry_get_type ( xmmsv_t *  val,
const char *  key 
)

Gets the type of a dict entry.

Parameters:
val A xmmsv_t containing a dict.
key The key in the dict.
Returns:
The type of the entry or XMMSV_TYPE_NONE if something goes wrong.

Definition at line 500 of file value.c.

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:
dictv A xmmsv_t containing a dict.
function The function to apply to each key-element pair.
user_data User data passed to the foreach function.
Returns:
1 upon success otherwise 0

Definition at line 1845 of file value.c.

Referenced by xmmsv_coll_attribute_foreach().

int xmmsv_dict_format ( char *  target,
int  len,
const char *  fmt,
xmmsv_t *  val 
)

This function will make a pretty string about the information in xmmsv dict.

Parameters:
target A allocated char *
len Length of target
fmt A format string to use. You can insert items from the dict by using specialformat "${field}".
val The xmmsv_t that contains the dict.
Returns:
The number of chars written to target

Definition at line 2296 of file value.c.

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

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

Parameters:
dictv A xmmsv_t containing a dict.
key The key in the dict.
val Pointer set to a borrowed reference to the element corresponding to the given key in the dict.
Returns:
1 upon success otherwise 0

Definition at line 1709 of file value.c.

Referenced by xmms_collection_query_ids(), xmmsv_dict_entry_get_type(), and xmmsv_dict_has_key().

int xmmsv_dict_get_size ( xmmsv_t *  dictv  ) 

Return the size of the dict.

Parameters:
dictv The xmmsv_t containing the dict.
Returns:
The size of the dict, or -1 if dict is invalid.

Definition at line 1874 of file value.c.

void xmmsv_dict_iter_explicit_destroy ( xmmsv_dict_iter_t it  ) 

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:
it iterator to free

Definition at line 1923 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:
it A xmmsv_dict_iter_t.
key The key to seek for.
Returns:
1 upon success otherwise 0

Definition at line 2020 of file value.c.

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

void xmmsv_dict_iter_first ( xmmsv_dict_iter_t it  ) 

Rewind the iterator to the start of the dict.

Parameters:
it A xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 1987 of file value.c.

void xmmsv_dict_iter_next ( xmmsv_dict_iter_t it  ) 

Advance the iterator to the next pair in the dict.

Parameters:
it A xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 2001 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:
it A xmmsv_dict_iter_t.
key Pointer set to the key pointed at by the iterator.
val Pointer set to a borrowed reference to the element pointed at by the iterator.
Returns:
1 upon success otherwise 0

Definition at line 1940 of file value.c.

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

int xmmsv_dict_iter_remove ( xmmsv_dict_iter_t it  ) 

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

Parameters:
it A xmmsv_dict_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 2120 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:
it A xmmsv_dict_iter_t.
val The element to set in the pair.
Returns:
1 upon success otherwise 0

Definition at line 2093 of file value.c.

Referenced by xmmsv_dict_set().

int xmmsv_dict_iter_valid ( xmmsv_dict_iter_t it  ) 

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

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

Definition at line 1975 of file value.c.

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

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

Parameters:
dictv A xmmsv_t containing a dict.
key The key in the dict.
Returns:
1 upon success otherwise 0

Definition at line 1795 of file value.c.

Referenced by xmmsv_coll_attribute_remove().

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.

If the key already referenced an element, that element is unref'd and replaced by the new one.

Parameters:
dictv A xmmsv_t containing a dict.
key The key in the dict.
val The new element to insert in the dict.
Returns:
1 upon success otherwise 0

Definition at line 1744 of file value.c.

Referenced by xmms_sqlite_query_table(), xmms_xform_browse_add_entry_property(), xmmsv_build_dict(), xmmsv_coll_attribute_set(), and xmmsv_propdict_to_dict().

int xmmsv_get_bin ( const xmmsv_t *  val,
const unsigned char **  r,
unsigned int *  rlen 
)

Retrieves binary data from the value.

Parameters:
val a xmmsv_t containing a string.
r the return data. This data is owned by the value and will be freed when the value is freed.
rlen the return length of data.
Returns:
1 upon success otherwise 0

Definition at line 896 of file value.c.

Referenced by xmms_bin_to_gstring(), xmms_ipc_msg_put_value(), and xmms_xform_auxdata_get_bin().

int xmmsv_get_coll ( const xmmsv_t *  val,
xmmsv_coll_t **  c 
)

Retrieves a collection from the value.

Parameters:
val a xmmsv_t containing a collection.
c the return collection. This collection is owned by the value and will be unref'd when the value is freed.
Returns:
1 upon success otherwise 0

Definition at line 875 of file value.c.

Referenced by xmms_ipc_msg_put_value().

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

Retrieves a dict iterator from a dict xmmsv_t.

Parameters:
val a xmmsv_t containing a dict.
it An 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 947 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().

int xmmsv_get_error ( const xmmsv_t *  val,
const char **  r 
)

Retrieves an error string describing the server error from the value.

Parameters:
val a xmmsv_t containing a integer.
r the return error.
Returns:
1 upon success otherwise 0

Definition at line 796 of file value.c.

Referenced by xmms_ipc_msg_put_value().

const char* xmmsv_get_error_old ( const xmmsv_t *  val  ) 

Legacy alias to retrieve the error string from an xmmsv_t.

Obsolete now, use xmmsv_get_error instead!

Parameters:
val an error xmmsv_t
Returns:
the error string if valid, NULL otherwise.

Definition at line 454 of file value.c.

int xmmsv_get_int ( const xmmsv_t *  val,
int32_t *  r 
)

Retrieves a signed integer from the value.

Parameters:
val a xmmsv_t containing an integer.
r the return integer.
Returns:
1 upon success otherwise 0

Definition at line 815 of file value.c.

Referenced by xmms_collection_get_random_media(), xmms_collection_query_ids(), xmms_ipc_msg_put_value(), xmms_playlist_changed_msg_send(), xmms_xform_auxdata_get_int(), xmms_xform_metadata_get_int(), xmms_xform_volatile_get_int(), and xmmsv_dict_format().

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

Retrieves a list iterator from a list xmmsv_t.

Parameters:
val a xmmsv_t containing a list.
it An 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 918 of file value.c.

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

int xmmsv_get_string ( const xmmsv_t *  val,
const char **  r 
)

Retrieves a string from the value.

Parameters:
val a xmmsv_t containing a string.
r the return string. This string is owned by the value and will be freed when the value is freed.
Returns:
1 upon success otherwise 0

Definition at line 855 of file value.c.

Referenced by xmms_ipc_msg_put_value(), xmms_playlist_changed_msg_send(), xmms_xform_auxdata_get_str(), xmms_xform_metadata_get_str(), xmms_xform_volatile_get_str(), xmmsv_decode_url(), xmmsv_dict_format(), xmmsv_dict_iter_find(), and xmmsv_dict_iter_pair().

xmmsv_type_t xmmsv_get_type ( const xmmsv_t *  val  ) 
int xmmsv_get_uint ( const xmmsv_t *  val,
uint32_t *  r 
)

Retrieves a unsigned integer from the value.

Parameters:
val a xmmsv_t containing an unsigned integer.
r the return unsigned integer.
Returns:
1 upon success otherwise 0

Definition at line 834 of file value.c.

Referenced by xmmsv_dict_format().

int xmmsv_is_dict ( const xmmsv_t *  val  ) 

Check if the value stores a dict.

Parameters:
val a xmmsv_t
Returns:
1 if value stores a dict, 0 otherwise.

Definition at line 441 of file value.c.

int xmmsv_is_error ( const xmmsv_t *  val  ) 

Check if the value stores an error.

Parameters:
val a xmmsv_t
Returns:
1 if error was encountered, 0 otherwise.

Definition at line 417 of file value.c.

int xmmsv_is_list ( const xmmsv_t *  val  ) 

Check if the value stores a list.

Parameters:
val a xmmsv_t
Returns:
1 if value stores a list, 0 otherwise.

Definition at line 429 of file value.c.

int xmmsv_is_type ( const xmmsv_t *  val,
xmmsv_type_t  t 
)
int xmmsv_list_append ( xmmsv_t *  listv,
xmmsv_t *  val 
)

Append an element to the end of the list xmmsv_t.

The list will hold a reference to the element until it's removed.

Parameters:
listv A xmmsv_t containing a list.
val The element to append.
Returns:
1 upon success otherwise 0

Definition at line 1332 of file value.c.

Referenced by xmms_collection_get_random_media(), xmms_collection_query_ids(), xmmsv_build_list_va(), xmmsv_coll_add_operand(), and xmmsv_make_stringlist().

int xmmsv_list_clear ( xmmsv_t *  listv  ) 

Empty the list from all its elements.

Parameters:
listv A xmmsv_t containing a list.
Returns:
1 upon success otherwise 0

Definition at line 1348 of file value.c.

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:
listv A xmmsv_t containing a list.
function The function to apply to each element.
user_data User data passed to the foreach function.
Returns:
1 upon success otherwise 0

Definition at line 1367 of file value.c.

int xmmsv_list_get ( xmmsv_t *  listv,
int  pos,
xmmsv_t **  val 
)

Get the element at the given position in the list xmmsv_t.

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

Parameters:
listv A xmmsv_t containing a list.
pos The position in the list. If negative, start counting from the end (-1 is the last element, etc).
val Pointer set to a borrowed reference to the element at the given position in the list.
Returns:
1 upon success otherwise 0

Definition at line 1210 of file value.c.

int xmmsv_list_get_size ( xmmsv_t *  listv  ) 

Return the size of the list.

Parameters:
listv The xmmsv_t containing the list.
Returns:
The size of the list, or -1 if listv is invalid.

Definition at line 1395 of file value.c.

int xmmsv_list_insert ( xmmsv_t *  listv,
int  pos,
xmmsv_t *  val 
)

Insert an element at the given position in the list xmmsv_t.

The list will hold a reference to the element until it's removed.

Parameters:
listv A xmmsv_t containing a list.
pos The position in the list. If negative, start counting from the end (-1 is the last element, etc).
val The element to insert.
Returns:
1 upon success otherwise 0

Definition at line 1274 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:
it A xmmsv_list_iter_t.
val Pointer set to a borrowed reference to the element pointed at by the iterator.
Returns:
1 upon success otherwise 0

Definition at line 1487 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().

void xmmsv_list_iter_explicit_destroy ( xmmsv_list_iter_t it  ) 

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:
it iterator to free

Definition at line 1470 of file value.c.

Referenced by xmmsv_coll_add_operand(), and xmmsv_coll_remove_operand().

void xmmsv_list_iter_first ( xmmsv_list_iter_t it  ) 

Rewind the iterator to the start of the list.

Parameters:
it A xmmsv_list_iter_t.

Definition at line 1515 of file value.c.

Referenced by xmmsv_dict_iter_first().

xmmsv_t* xmmsv_list_iter_get_parent ( const xmmsv_list_iter_t it  ) 

Return the parent xmmsv_t of an iterator.

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

Definition at line 1612 of file value.c.

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.

Parameters:
it A xmmsv_list_iter_t.
val The element to insert.
Returns:
1 upon success otherwise 0

Definition at line 1628 of file value.c.

Referenced by xmmsv_dict_iter_set(), and xmmsv_dict_set().

void xmmsv_list_iter_last ( xmmsv_list_iter_t it  ) 

Move the iterator to end of the list.

Parameters:
listv A xmmsv_list_iter_t.

Definition at line 1528 of file value.c.

void xmmsv_list_iter_next ( xmmsv_list_iter_t it  ) 

Advance the iterator to the next element in the list.

Parameters:
it A xmmsv_list_iter_t.

Definition at line 1545 of file value.c.

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

void xmmsv_list_iter_prev ( xmmsv_list_iter_t it  ) 

Move the iterator to the previous element in the list.

Parameters:
listv A xmmsv_list_iter_t.

Definition at line 1560 of file value.c.

int xmmsv_list_iter_remove ( xmmsv_list_iter_t it  ) 

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

Parameters:
it A xmmsv_list_iter_t.
Returns:
1 upon success otherwise 0

Definition at line 1644 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:
it A xmmsv_list_iter_t.
pos The 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 1579 of file value.c.

Referenced by xmmsv_dict_iter_find().

int xmmsv_list_iter_tell ( const xmmsv_list_iter_t it  ) 

Tell the position of the iterator.

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

Definition at line 1598 of file value.c.

int xmmsv_list_iter_valid ( xmmsv_list_iter_t it  ) 

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

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

Definition at line 1504 of file value.c.

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

int xmmsv_list_move ( xmmsv_t *  listv,
int  old_pos,
int  new_pos 
)

Move the element from position old to position new.

xmmsv_list_iter_t's remain pointing at their element (which might or might not be at a different position).

Parameters:
listv A xmmsv_t containing a list
old The original position in the list. If negative, start counting from the end (-1 is the last element, etc.)
new The new position in the list. If negative start counting from the end (-1 is the last element, etc.) For the sake of counting the element to be moved is still at its old position.
Returns:
1 upon success otherwise 0

Definition at line 1315 of file value.c.

int xmmsv_list_remove ( xmmsv_t *  listv,
int  pos 
)

Remove the element at the given position from the list xmmsv_t.

Parameters:
listv A xmmsv_t containing a list.
pos The 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 1292 of file value.c.

int xmmsv_list_restrict_type ( xmmsv_t *  listv,
xmmsv_type_t  type 
)

Definition at line 1405 of file value.c.

Referenced by xmmsv_coll_new().

int xmmsv_list_set ( xmmsv_t *  listv,
int  pos,
xmmsv_t *  val 
)

Set the element at the given position in the list xmmsv_t.

Parameters:
listv A xmmsv_t containing a list.
pos The position in the list. If negative, start counting from the end (-1 is the last element, etc).
val The element to put at the given position in the list.
Returns:
1 upon success otherwise 0

Definition at line 1241 of file value.c.

xmmsv_t* xmmsv_make_stringlist ( char *  array[],
int  num 
)

Helper function to build a list xmmsv_t containing the strings from the input array.

Parameters:
array An array of C strings. Must be NULL-terminated if num is -1.
num The optional number of elements to read from the array. Set to -1 if the array is NULL-terminated.
Returns:
An xmmsv_t containing the list of strings. Must be unreffed manually when done.

Definition at line 475 of file value.c.

xmmsv_t* xmmsv_new_bin ( unsigned char *  data,
unsigned int  len 
)

Allocates a new binary data xmmsv_t.

Parameters:
data The data to store in the xmmsv_t.
len The size of the data.
Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 223 of file value.c.

Referenced by xmms_xform_auxdata_set_bin(), and xmmsv_decode_url().

xmmsv_t* xmmsv_new_coll ( xmmsv_coll_t c  ) 

Allocates a new collection xmmsv_t.

Parameters:
s The value to store in the xmmsv_t.
Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 200 of file value.c.

Referenced by xmmsv_coll_add_operand().

xmmsv_t* xmmsv_new_dict ( void   ) 

Allocates a new dict xmmsv_t.

Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 266 of file value.c.

Referenced by xmms_sqlite_query_table(), xmms_xform_browse_add_entry(), xmms_xform_new(), xmmsv_build_dict(), xmmsv_coll_new(), and xmmsv_propdict_to_dict().

xmmsv_t* xmmsv_new_error ( const char *  errstr  ) 

Allocates a new error xmmsv_t.

Parameters:
s The error message to store in the xmmsv_t. The string is copied in the value.
Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 141 of file value.c.

xmmsv_t* xmmsv_new_int ( int32_t  i  ) 
xmmsv_t* xmmsv_new_list ( void   ) 

Allocates a new list xmmsv_t.

Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 248 of file value.c.

Referenced by xmms_collection_get_random_media(), xmms_collection_query_ids(), xmmsv_build_list_va(), xmmsv_coll_new(), and xmmsv_make_stringlist().

xmmsv_t* xmmsv_new_none ( void   ) 

Allocates a new empty xmmsv_t.

Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 127 of file value.c.

Referenced by xmms_object_emit_f(), and xmms_xform_auxdata_barrier().

xmmsv_t* xmmsv_new_string ( const char *  s  ) 

Allocates a new string xmmsv_t.

Parameters:
s The value to store in the xmmsv_t. The string is copied in the value.
Returns:
The new xmmsv_t. Must be unreferenced with xmmsv_unref.

Definition at line 178 of file value.c.

Referenced by xmms_collection_changed_msg_new(), xmms_collection_get_random_media(), xmms_collection_query_ids(), xmms_config_property_set_data(), xmms_object_emit_f(), xmms_playlist_changed_msg_new(), xmms_xform_auxdata_set_str(), xmms_xform_browse_add_entry_property_str(), xmms_xform_metadata_set_str(), xmmsv_coll_attribute_set(), xmmsv_dict_set(), and xmmsv_make_stringlist().

xmmsv_t* xmmsv_propdict_to_dict ( xmmsv_t *  propdict,
const char **  src_prefs 
)

Helper function to transform a key-source-value dict-of-dict xmmsv_t (formerly a propdict) to a regular key-value dict, given a list of source preference.

Parameters:
propdict A key-source-value dict-of-dict xmmsv_t.
src_prefs A list of source names or patterns. Must be NULL-terminated. If this argument is NULL, the default source preferences is used.
Returns:
An xmmsv_t containing a simple key-value dict. Must be unreffed manually when done.

Definition at line 744 of file value.c.

xmmsv_t* xmmsv_ref ( xmmsv_t *  val  ) 

References the xmmsv_t.

Parameters:
val the value to reference.
Returns:
val

Definition at line 286 of file value.c.

Referenced by xmmsv_list_set().

void xmmsv_unref ( xmmsv_t *  val  ) 
int xmmsv_utf8_validate ( const char *  str  ) 

Check if a string is valid UTF-8.

Definition at line 2436 of file value.c.

Referenced by xmmsv_new_string().


Generated on Tue Feb 23 18:14:36 2010 for XMMS2 by  doxygen 1.6.1