-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_values.h
272 lines (231 loc) · 7.08 KB
/
content_values.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#ifndef _DB_CONTENT_VALUES_H_
#define _DB_CONTENT_VALUES_H_
#include <common.h>
typedef enum
{
ContentValues_SUCC=0,
ContentValues_ERROR=-1,
ContentValues_KEY_NOT_EXIST=-2,
ContentValues_NO_MEMORY=-3,
}ContentValuesErrcode;
typedef enum
{
ContentValuesEntry_TYPE_INT,
ContentValuesEntry_TYPE_DOUBLE,
ContentValuesEntry_TYPE_BOOL,
ContentValuesEntry_TYPE_STRING,
ContentValuesEntry_TYPE_STRING_16,
ContentValuesEntry_TYPE_BLOB,
}ContentValuesEntry_TYPE;
typedef struct _ContentValues ContentValues;
typedef void* ContentValuesItor;
#define ContentValuesInvalidItor NULL
typedef INT32 (*ContentValues_Traverse_Callback ) (ContentValuesEntry_TYPE type,const CHAR* key, void* value );
/**
* @brief create a content value
* @return ContentValues instance
*/
extern ContentValues* content_values_create();
/**
* @brief destroy content value
*
* @param[in] thiz ContentValues handle
*/
extern void content_values_destroy(ContentValues* thiz);
/**
* @brief duplicate content values
*
* @param[in] thiz ContentValues handle
*/
extern ContentValues* content_values_duplicate(ContentValues* values);
/**
* @brief get values number
*
* @param[in] thiz ContentValues handle
* @param[out] count save count
* @return error code
*/
extern INT32 content_values_get_count(ContentValues* thiz,INT32* count);
/**
* @brief get if contain some key
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @return error code
*/
extern BOOL content_values_contains_key(ContentValues* thiz,const CHAR* key);
/**
* @brief get blob value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret blob value, the buffer is a new buffer, need to be released by invoker
* @param[out] len blob value length
* @return error code
*/
extern INT32 content_values_get_blob(ContentValues* thiz,const CHAR* key,void** ret,UINT32* len);
/**
* @brief get blob value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] len blob value length
* @return blob value, the buffer do not need to be released
*/
extern void* content_values_get_blob_v2(ContentValues* thiz,const CHAR* key,UINT32* len);
/**
* @brief get wstring value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret wstring value, the buffer is a new buffer, need to be released by caller
* @return error code
*/
extern INT32 content_values_get_string16(ContentValues* thiz,const CHAR* key,WCHAR** ret);
/**
* @brief get wstring value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @return wstring value
*/
extern const WCHAR* content_values_get_string16_v2(ContentValues* thiz,const CHAR* key);
/**
* @brief get string value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret string value, the buffer is a new buffer, need to be released by caller
* @return error code
*/
extern INT32 content_values_get_string(ContentValues* thiz,const CHAR* key,CHAR** ret);
/**
* @brief get string value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @return string value
*/
extern const CHAR* content_values_get_string_v2(ContentValues* thiz,const CHAR* key);
/**
* @brief get int64 value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret save int value
* @return error code
*/
extern INT32 content_values_get_int(ContentValues* thiz,const CHAR* key,INT64* ret);
/**
* @brief get double value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret save double value
* @return error code
*/
extern INT32 content_values_get_double(ContentValues* thiz,const CHAR* key,double* ret);
/**
* @brief get bool value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[out] ret save bool value
* @return error code
*/
extern INT32 content_values_get_bool(ContentValues* thiz,const CHAR* key,BOOL* ret);
/**
* @brief put blob value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value blob value
* @param[in] len blob value length
* @return error code
*/
extern INT32 content_values_put_blob(ContentValues* thiz,const CHAR* key,const void* value,UINT32 len);
/**
* @brief put wstring value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value wstring value
* @return error code
*/
extern INT32 content_values_put_string_16(ContentValues* thiz,const CHAR* key,const WCHAR* value);
/**
* @brief put string value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value string value
* @return error code
*/
extern INT32 content_values_put_string(ContentValues* thiz,const CHAR* key,const CHAR* value);
/**
* @brief put int64 value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value int64 value
* @return error code
*/
extern INT32 content_values_put_int(ContentValues* thiz,const CHAR* key,INT64 value);
/**
* @brief put double value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value double value
* @return error code
*/
extern INT32 content_values_put_double(ContentValues* thiz,const CHAR* key,double value);
/**
* @brief put bool value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @param[in] value bool value
* @return error code
*/
extern INT32 content_values_put_bool(ContentValues* thiz,const CHAR* key,BOOL value);
/**
* @brief delete value
*
* @param[in] thiz ContentValues handle
* @param[in] key key string
* @return error code
*/
extern INT32 content_values_delete_key(ContentValues* thiz,const CHAR* key);
/**
* @brief get the first value
*
* @param[in] thiz ContentValues handle
* @return ContentValuesItor is user for traversal the content value list
*/
extern ContentValuesItor content_values_first(ContentValues* thiz);
/**
* @brief get the next value
*
* @param[in] thiz ContentValues handle
* @param[in] itor ContentValuesItor handle
* @return ContentValuesItor is user for traversal the content value list
*/
extern ContentValuesItor content_values_next(ContentValues* thiz,ContentValuesItor* itor);
/**
* @brief get key
*
* @param[in] itor ContentValuesItor handle
* @return key string
*/
extern const CHAR* content_values_get_key(ContentValuesItor* itor);
/**
* @brief get value
*
* @param[in] itor ContentValuesItor handle
* @param[out] type save type
* @param[in] len save value length
* @return value
*/
extern const void* content_values_get_value(ContentValuesItor* itor,ContentValuesEntry_TYPE* type,UINT32* len);
#endif