XMMS2
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
include
xmmsc
xmmsv.h
Go to the documentation of this file.
1
/* XMMS2 - X Music Multiplexer System
2
* Copyright (C) 2003-2009 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
#ifndef __XMMSV_H__
18
#define __XMMSV_H__
19
20
#include <stdarg.h>
21
#include "
xmmsc/xmmsc_compiler.h
"
22
#include "
xmmsc/xmmsc_stdint.h
"
23
#include "
xmmsc/xmmsv_coll.h
"
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
typedef
enum
{
30
XMMSV_TYPE_NONE
,
31
XMMSV_TYPE_ERROR
,
32
XMMSV_TYPE_INT32
,
33
XMMSV_TYPE_STRING
,
34
XMMSV_TYPE_COLL
,
35
XMMSV_TYPE_BIN
,
36
XMMSV_TYPE_LIST
,
37
XMMSV_TYPE_DICT
,
38
XMMSV_TYPE_END
39
}
xmmsv_type_t
;
40
41
static
inline
xmmsv_type_t
XMMSV_TYPE_UINT32_IS_DEPRECATED(
void
)
XMMS_DEPRECATED
;
42
static inline
xmmsv_type_t
43
XMMSV_TYPE_UINT32_IS_DEPRECATED (
void
)
44
{
45
return
XMMSV_TYPE_INT32
;
46
}
47
#define XMMSV_TYPE_UINT32 XMMSV_TYPE_UINT32_IS_DEPRECATED()
48
49
50
51
typedef
struct
xmmsv_St
xmmsv_t
;
52
53
typedef
struct
xmmsv_list_iter_St
xmmsv_list_iter_t
;
54
typedef
struct
xmmsv_dict_iter_St
xmmsv_dict_iter_t
;
55
56
xmmsv_t
*
xmmsv_new_none
(
void
);
57
xmmsv_t
*
xmmsv_new_error
(
const
char
*errstr);
/* FIXME: err id? */
58
xmmsv_t
*
xmmsv_new_int
(int32_t i);
59
xmmsv_t
*
xmmsv_new_string
(
const
char
*s);
60
xmmsv_t
*
xmmsv_new_coll
(
xmmsv_coll_t
*coll);
61
xmmsv_t
*
xmmsv_new_bin
(
unsigned
char
*data,
unsigned
int
len);
62
63
xmmsv_t
*
xmmsv_new_list
(
void
);
64
xmmsv_t
*
xmmsv_new_dict
(
void
);
65
66
xmmsv_t
*
xmmsv_ref
(
xmmsv_t
*val);
67
void
xmmsv_unref
(
xmmsv_t
*val);
68
69
xmmsv_type_t
xmmsv_get_type
(
const
xmmsv_t
*val);
70
int
xmmsv_is_type
(
const
xmmsv_t
*val,
xmmsv_type_t
t);
71
72
/* legacy aliases */
73
int
xmmsv_is_error
(
const
xmmsv_t
*val);
74
int
xmmsv_is_list
(
const
xmmsv_t
*val)
XMMS_DEPRECATED
;
75
int
xmmsv_is_dict
(
const
xmmsv_t
*val)
XMMS_DEPRECATED
;
76
77
const
char
*
xmmsv_get_error_old
(
const
xmmsv_t
*val)
XMMS_DEPRECATED
;
78
xmmsv_t
*
xmmsv_make_stringlist
(
char
*array[],
int
num);
79
80
typedef
void (*
xmmsv_list_foreach_func
) (
xmmsv_t
*value,
void
*user_data);
81
typedef
void (*
xmmsv_dict_foreach_func
) (
const
char
*key,
xmmsv_t
*value,
void
*user_data);
82
83
/* legacy transitional utilities */
84
xmmsv_type_t
xmmsv_dict_entry_get_type
(
xmmsv_t
*val,
const
char
*key);
85
xmmsv_t
*
xmmsv_propdict_to_dict
(
xmmsv_t
*propdict,
const
char
**src_prefs);
86
87
int
xmmsv_get_error
(
const
xmmsv_t
*val,
const
char
**r);
88
int
xmmsv_get_int
(
const
xmmsv_t
*val, int32_t *r);
89
int
xmmsv_get_uint
(
const
xmmsv_t
*val, uint32_t *r)
XMMS_DEPRECATED
;
90
int
xmmsv_get_string
(
const
xmmsv_t
*val,
const
char
**r);
91
int
xmmsv_get_coll
(
const
xmmsv_t
*val,
xmmsv_coll_t
**coll);
92
int
xmmsv_get_bin
(
const
xmmsv_t
*val,
const
unsigned
char
**r,
unsigned
int
*rlen);
93
94
int
xmmsv_get_list_iter
(
const
xmmsv_t
*val,
xmmsv_list_iter_t
**it);
95
int
xmmsv_get_dict_iter
(
const
xmmsv_t
*val,
xmmsv_dict_iter_t
**it);
96
97
void
xmmsv_list_iter_explicit_destroy
(
xmmsv_list_iter_t
*it);
98
void
xmmsv_dict_iter_explicit_destroy
(
xmmsv_dict_iter_t
*it);
99
100
101
/* List */
102
int
xmmsv_list_get
(
xmmsv_t
*listv,
int
pos,
xmmsv_t
**val);
103
int
xmmsv_list_set
(
xmmsv_t
*listv,
int
pos,
xmmsv_t
*val);
104
int
xmmsv_list_append
(
xmmsv_t
*listv,
xmmsv_t
*val);
105
int
xmmsv_list_insert
(
xmmsv_t
*listv,
int
pos,
xmmsv_t
*val);
106
int
xmmsv_list_remove
(
xmmsv_t
*listv,
int
pos);
107
int
xmmsv_list_move
(
xmmsv_t
*listv,
int
old_pos,
int
new_pos);
108
int
xmmsv_list_clear
(
xmmsv_t
*listv);
109
int
xmmsv_list_foreach
(
xmmsv_t
*listv,
xmmsv_list_foreach_func
func,
void
* user_data);
110
int
xmmsv_list_get_size
(
xmmsv_t
*listv);
111
int
xmmsv_list_restrict_type
(
xmmsv_t
*listv,
xmmsv_type_t
type);
112
113
int
xmmsv_list_get_string
(
xmmsv_t
*v,
int
pos,
const
char
**val);
114
int
xmmsv_list_get_int
(
xmmsv_t
*v,
int
pos, int32_t *val);
115
int
xmmsv_list_get_coll
(
xmmsv_t
*v,
int
pos,
xmmsv_coll_t
**val);
116
117
int
xmmsv_list_set_string
(
xmmsv_t
*v,
int
pos,
const
char
*val);
118
int
xmmsv_list_set_int
(
xmmsv_t
*v,
int
pos, int32_t val);
119
int
xmmsv_list_set_coll
(
xmmsv_t
*v,
int
pos,
xmmsv_coll_t
*val);
120
121
int
xmmsv_list_insert_string
(
xmmsv_t
*v,
int
pos,
const
char
*val);
122
int
xmmsv_list_insert_int
(
xmmsv_t
*v,
int
pos, int32_t val);
123
int
xmmsv_list_insert_coll
(
xmmsv_t
*v,
int
pos,
xmmsv_coll_t
*val);
124
125
int
xmmsv_list_append_string
(
xmmsv_t
*v,
const
char
*val);
126
int
xmmsv_list_append_int
(
xmmsv_t
*v, int32_t val);
127
int
xmmsv_list_append_coll
(
xmmsv_t
*v,
xmmsv_coll_t
*val);
128
129
int
xmmsv_list_iter_entry
(
xmmsv_list_iter_t
*it,
xmmsv_t
**val);
130
int
xmmsv_list_iter_valid
(
xmmsv_list_iter_t
*it);
131
void
xmmsv_list_iter_first
(
xmmsv_list_iter_t
*it);
132
void
xmmsv_list_iter_last
(
xmmsv_list_iter_t
*it);
133
void
xmmsv_list_iter_next
(
xmmsv_list_iter_t
*it);
134
void
xmmsv_list_iter_prev
(
xmmsv_list_iter_t
*it);
135
int
xmmsv_list_iter_seek
(
xmmsv_list_iter_t
*it,
int
pos);
136
int
xmmsv_list_iter_tell
(
const
xmmsv_list_iter_t
*it);
137
xmmsv_t
*
xmmsv_list_iter_get_parent
(
const
xmmsv_list_iter_t
*it);
138
139
int
xmmsv_list_iter_insert
(
xmmsv_list_iter_t
*it,
xmmsv_t
*val);
140
int
xmmsv_list_iter_remove
(
xmmsv_list_iter_t
*it);
141
142
int
xmmsv_list_iter_entry_string
(
xmmsv_list_iter_t
*it,
const
char
**val);
143
int
xmmsv_list_iter_entry_int
(
xmmsv_list_iter_t
*it, int32_t *val);
144
int
xmmsv_list_iter_entry_coll
(
xmmsv_list_iter_t
*it,
xmmsv_coll_t
**val);
145
146
int
xmmsv_list_iter_insert_string
(
xmmsv_list_iter_t
*it,
const
char
*val);
147
int
xmmsv_list_iter_insert_int
(
xmmsv_list_iter_t
*it, int32_t val);
148
int
xmmsv_list_iter_insert_coll
(
xmmsv_list_iter_t
*it,
xmmsv_coll_t
*val);
149
150
151
/* Dict */
152
int
xmmsv_dict_get
(
xmmsv_t
*dictv,
const
char
*key,
xmmsv_t
**val);
153
int
xmmsv_dict_set
(
xmmsv_t
*dictv,
const
char
*key,
xmmsv_t
*val);
154
int
xmmsv_dict_remove
(
xmmsv_t
*dictv,
const
char
*key);
155
int
xmmsv_dict_clear
(
xmmsv_t
*dictv);
156
int
xmmsv_dict_foreach
(
xmmsv_t
*dictv,
xmmsv_dict_foreach_func
func,
void
*user_data);
157
int
xmmsv_dict_get_size
(
xmmsv_t
*dictv);
158
int
xmmsv_dict_has_key
(
xmmsv_t
*dictv,
const
char
*key);
159
160
int
xmmsv_dict_entry_get_string
(
xmmsv_t
*val,
const
char
*key,
const
char
**r);
161
int
xmmsv_dict_entry_get_int
(
xmmsv_t
*val,
const
char
*key, int32_t *r);
162
int
xmmsv_dict_entry_get_coll
(
xmmsv_t
*val,
const
char
*key,
xmmsv_coll_t
**coll);
163
164
int
xmmsv_dict_set_string
(
xmmsv_t
*val,
const
char
*key,
const
char
*el);
165
int
xmmsv_dict_set_int
(
xmmsv_t
*val,
const
char
*key, int32_t el);
166
int
xmmsv_dict_set_coll
(
xmmsv_t
*val,
const
char
*key,
xmmsv_coll_t
*el);
167
168
int
xmmsv_dict_iter_pair
(
xmmsv_dict_iter_t
*it,
const
char
**key,
xmmsv_t
**val);
169
int
xmmsv_dict_iter_valid
(
xmmsv_dict_iter_t
*it);
170
void
xmmsv_dict_iter_first
(
xmmsv_dict_iter_t
*it);
171
void
xmmsv_dict_iter_next
(
xmmsv_dict_iter_t
*it);
172
int
xmmsv_dict_iter_find
(
xmmsv_dict_iter_t
*it,
const
char
*key);
173
174
int
xmmsv_dict_iter_set
(
xmmsv_dict_iter_t
*it,
xmmsv_t
*val);
175
int
xmmsv_dict_iter_remove
(
xmmsv_dict_iter_t
*it);
176
177
int
xmmsv_dict_iter_pair_string
(
xmmsv_dict_iter_t
*it,
const
char
**key,
const
char
**r);
178
int
xmmsv_dict_iter_pair_int
(
xmmsv_dict_iter_t
*it,
const
char
**key, int32_t *r);
179
int
xmmsv_dict_iter_pair_coll
(
xmmsv_dict_iter_t
*it,
const
char
**key,
xmmsv_coll_t
**r);
180
181
int
xmmsv_dict_iter_set_string
(
xmmsv_dict_iter_t
*it,
const
char
*elem);
182
int
xmmsv_dict_iter_set_int
(
xmmsv_dict_iter_t
*it, int32_t elem);
183
int
xmmsv_dict_iter_set_coll
(
xmmsv_dict_iter_t
*it,
xmmsv_coll_t
*elem);
184
185
/* Utils */
186
187
#define xmmsv_check_type(type) ((type) > XMMSV_TYPE_NONE && (type) < XMMSV_TYPE_END)
188
189
190
xmmsv_t
*
xmmsv_decode_url
(
const
xmmsv_t
*url);
191
int
xmmsv_dict_format
(
char
*target,
int
len,
const
char
*fmt,
xmmsv_t
*val);
192
193
int
xmmsv_utf8_validate
(
const
char
*str);
194
195
196
/* These helps us doing compiletime typechecking */
197
static
inline
const
char
*__xmmsv_identity_const_charp (
const
char
*v) {
return
v;}
198
static
inline
xmmsv_t
*__xmmsv_identity_xmmsv (
xmmsv_t
*v) {
return
v;}
199
#define XMMSV_DICT_ENTRY(k, v) __xmmsv_identity_const_charp (k), __xmmsv_identity_xmmsv (v)
200
#define XMMSV_DICT_ENTRY_STR(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_string (v))
201
#define XMMSV_DICT_ENTRY_INT(k, v) XMMSV_DICT_ENTRY (k, xmmsv_new_int (v))
202
#define XMMSV_DICT_END NULL
203
xmmsv_t
*
xmmsv_build_dict
(
const
char
*firstkey, ...);
204
205
#define XMMSV_LIST_ENTRY(v) __xmmsv_identity_xmmsv (v)
206
#define XMMSV_LIST_ENTRY_STR(v) XMMSV_LIST_ENTRY (xmmsv_new_string (v))
207
#define XMMSV_LIST_ENTRY_INT(v) XMMSV_LIST_ENTRY (xmmsv_new_int (v))
208
#define XMMSV_LIST_ENTRY_COLL(v) XMMSV_LIST_ENTRY (xmmsv_new_coll (v))
209
#define XMMSV_LIST_END NULL
210
211
xmmsv_t
*
xmmsv_build_list
(
xmmsv_t
*first_entry, ...);
212
xmmsv_t
*
xmmsv_build_list_va
(
xmmsv_t
*first_entry, va_list ap);
213
214
#ifdef __cplusplus
215
}
216
#endif
217
218
#endif
Generated by
1.8.2