XMMS2
xmmsv_dict.h
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 
18 #ifndef __XMMSV_DICT_H__
19 #define __XMMSV_DICT_H__
20 
21 #include "xmmsc/xmmsv_general.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * @defgroup DictType Dictionaries
29  * @ingroup ValueType
30  * @{
31  */
32 
33 xmmsv_t *xmmsv_new_dict (void);
34 int xmmsv_dict_get (xmmsv_t *dictv, const char *key, xmmsv_t **val);
35 int xmmsv_dict_set (xmmsv_t *dictv, const char *key, xmmsv_t *val);
36 int xmmsv_dict_remove (xmmsv_t *dictv, const char *key);
37 int xmmsv_dict_clear (xmmsv_t *dictv);
38 int xmmsv_dict_get_size (xmmsv_t *dictv);
39 int xmmsv_dict_has_key (xmmsv_t *dictv, const char *key);
40 
41 int xmmsv_dict_entry_get_string (xmmsv_t *val, const char *key, const char **r);
42 int xmmsv_dict_entry_get_int (xmmsv_t *val, const char *key, int32_t *r);
43 int xmmsv_dict_entry_get_coll (xmmsv_t *val, const char *key, xmmsv_coll_t **coll);
44 
45 int xmmsv_dict_set_string (xmmsv_t *val, const char *key, const char *el);
46 int xmmsv_dict_set_int (xmmsv_t *val, const char *key, int32_t el);
47 int xmmsv_dict_set_coll (xmmsv_t *val, const char *key, xmmsv_coll_t *el);
48 
49 /* Utility */
50 xmmsv_type_t xmmsv_dict_entry_get_type (xmmsv_t *val, const char *key);
51 
52 /**
53  * @defgroup DictIterType Iteration
54  * @{
55  */
56 typedef void (*xmmsv_dict_foreach_func) (const char *key, xmmsv_t *value, void *user_data);
57 int xmmsv_dict_foreach (xmmsv_t *dictv, xmmsv_dict_foreach_func func, void *user_data);
58 
59 typedef struct xmmsv_dict_iter_St xmmsv_dict_iter_t;
60 int xmmsv_get_dict_iter (const xmmsv_t *val, xmmsv_dict_iter_t **it);
62 
63 int xmmsv_dict_iter_pair (xmmsv_dict_iter_t *it, const char **key, xmmsv_t **val);
67 int xmmsv_dict_iter_find (xmmsv_dict_iter_t *it, const char *key);
68 
71 
72 int xmmsv_dict_iter_pair_string (xmmsv_dict_iter_t *it, const char **key, const char **r);
73 int xmmsv_dict_iter_pair_int (xmmsv_dict_iter_t *it, const char **key, int32_t *r);
74 int xmmsv_dict_iter_pair_coll (xmmsv_dict_iter_t *it, const char **key, xmmsv_coll_t **r);
75 
76 int xmmsv_dict_iter_set_string (xmmsv_dict_iter_t *it, const char *elem);
77 int xmmsv_dict_iter_set_int (xmmsv_dict_iter_t *it, int32_t elem);
79 /** @} */
80 
81 /** @} */
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif
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.
Definition: value.c:1752
int xmmsv_dict_iter_pair_int(xmmsv_dict_iter_t *it, const char **key, int32_t *r)
struct xmmsv_St xmmsv_t
Definition: xmmsv_general.h:48
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.
Definition: value.c:1948
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.
Definition: value.c:2101
void xmmsv_dict_iter_next(xmmsv_dict_iter_t *it)
Advance the iterator to the next pair in the dict.
Definition: value.c:2009
xmmsv_t * xmmsv_new_dict(void)
Allocates a new dict xmmsv_t.
Definition: value.c:268
int xmmsv_dict_set_string(xmmsv_t *val, const char *key, const char *el)
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 ...
Definition: value.c:2028
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.
Definition: value.c:1853
int xmmsv_dict_iter_valid(xmmsv_dict_iter_t *it)
Check whether the iterator is valid and points to a valid pair.
Definition: value.c:1983
void xmmsv_dict_iter_explicit_destroy(xmmsv_dict_iter_t *it)
Explicitly free dict iterator.
Definition: value.c:1931
void(* xmmsv_dict_foreach_func)(const char *key, xmmsv_t *value, void *user_data)
Definition: xmmsv_dict.h:56
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).
Definition: value.c:1717
int xmmsv_dict_entry_get_int(xmmsv_t *val, const char *key, int32_t *r)
struct xmmsv_coll_St xmmsv_coll_t
Definition: xmmsv_coll.h:28
xmmsv_type_t xmmsv_dict_entry_get_type(xmmsv_t *val, const char *key)
Gets the type of a dict entry.
Definition: value.c:508
int xmmsv_dict_set_int(xmmsv_t *val, const char *key, int32_t el)
int xmmsv_dict_iter_pair_coll(xmmsv_dict_iter_t *it, const char **key, xmmsv_coll_t **r)
int xmmsv_dict_entry_get_string(xmmsv_t *val, const char *key, const char **r)
xmmsv_type_t
Definition: xmmsv_general.h:35
void xmmsv_dict_iter_first(xmmsv_dict_iter_t *it)
Rewind the iterator to the start of the dict.
Definition: value.c:1995
int xmmsv_dict_entry_get_coll(xmmsv_t *val, const char *key, xmmsv_coll_t **coll)
int xmmsv_dict_iter_set_coll(xmmsv_dict_iter_t *it, xmmsv_coll_t *elem)
int xmmsv_dict_iter_pair_string(xmmsv_dict_iter_t *it, const char **key, const char **r)
int xmmsv_dict_iter_set_int(xmmsv_dict_iter_t *it, int32_t elem)
int xmmsv_dict_set_coll(xmmsv_t *val, const char *key, xmmsv_coll_t *el)
int xmmsv_dict_iter_remove(xmmsv_dict_iter_t *it)
Remove the pair in the dict pointed at by the iterator.
Definition: value.c:2128
struct xmmsv_dict_iter_St xmmsv_dict_iter_t
Definition: xmmsv_dict.h:59
int xmmsv_get_dict_iter(const xmmsv_t *val, xmmsv_dict_iter_t **it)
Retrieves a dict iterator from a dict xmmsv_t.
Definition: value.c:955
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).
Definition: value.c:1803
int xmmsv_dict_iter_set_string(xmmsv_dict_iter_t *it, const char *elem)
int xmmsv_dict_get_size(xmmsv_t *dictv)
Return the size of the dict.
Definition: value.c:1882
int xmmsv_dict_has_key(xmmsv_t *dictv, const char *key)
Definition: value.c:2492
int xmmsv_dict_clear(xmmsv_t *dictv)
Empty the dict of all its elements.
Definition: value.c:1833