Mercurial > pidgin.yaz
annotate src/value.h @ 13344:1c2f284986b7
[gaim-migrate @ 15714]
really fix x:data user searches
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 28 Feb 2006 02:00:15 +0000 |
parents | d0f7f698b6de |
children | d9dbb874a30c |
rev | line source |
---|---|
6562 | 1 /** |
2 * @file value.h Value wrapper API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6562 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #ifndef _GAIM_VALUE_H_ | |
26 #define _GAIM_VALUE_H_ | |
27 | |
6565
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
28 #include <glib.h> |
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
29 |
6562 | 30 /** |
31 * Specific value types. | |
32 */ | |
33 typedef enum | |
34 { | |
35 GAIM_TYPE_UNKNOWN = 0, /**< Unknown type. */ | |
36 GAIM_TYPE_SUBTYPE, /**< Subtype. */ | |
37 GAIM_TYPE_CHAR, /**< Character. */ | |
38 GAIM_TYPE_UCHAR, /**< Unsigned character. */ | |
39 GAIM_TYPE_BOOLEAN, /**< Boolean. */ | |
40 GAIM_TYPE_SHORT, /**< Short integer. */ | |
41 GAIM_TYPE_USHORT, /**< Unsigned short integer. */ | |
42 GAIM_TYPE_INT, /**< Integer. */ | |
43 GAIM_TYPE_UINT, /**< Unsigned integer. */ | |
44 GAIM_TYPE_LONG, /**< Long integer. */ | |
45 GAIM_TYPE_ULONG, /**< Unsigned long integer. */ | |
46 GAIM_TYPE_INT64, /**< 64-bit integer. */ | |
47 GAIM_TYPE_UINT64, /**< 64-bit unsigned integer. */ | |
48 GAIM_TYPE_STRING, /**< String. */ | |
49 GAIM_TYPE_OBJECT, /**< Object pointer. */ | |
50 GAIM_TYPE_POINTER, /**< Generic pointer. */ | |
51 GAIM_TYPE_ENUM, /**< Enum. */ | |
52 GAIM_TYPE_BOXED /**< Boxed pointer with specific type. */ | |
53 | |
54 } GaimType; | |
55 | |
56 /** | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
57 * Gaim-specific subtype values. |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
58 */ |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
59 typedef enum |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
60 { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
61 GAIM_SUBTYPE_UNKNOWN = 0, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
62 GAIM_SUBTYPE_ACCOUNT, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
63 GAIM_SUBTYPE_BLIST, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
64 GAIM_SUBTYPE_BLIST_BUDDY, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
65 GAIM_SUBTYPE_BLIST_GROUP, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
66 GAIM_SUBTYPE_BLIST_CHAT, |
10934 | 67 GAIM_SUBTYPE_BUDDY_ICON, |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
68 GAIM_SUBTYPE_CONNECTION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
69 GAIM_SUBTYPE_CONVERSATION, |
8817 | 70 GAIM_SUBTYPE_PLUGIN, |
10684
72a5babfa8b4
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10477
diff
changeset
|
71 GAIM_SUBTYPE_BLIST_NODE, |
11979
717cbb3115bc
[gaim-migrate @ 14272]
Gary Kramlich <grim@reaperworld.com>
parents:
10934
diff
changeset
|
72 GAIM_SUBTYPE_CIPHER, |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
11979
diff
changeset
|
73 GAIM_SUBTYPE_STATUS, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
12837
diff
changeset
|
74 GAIM_SUBTYPE_LOG, |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
12837
diff
changeset
|
75 GAIM_SUBTYPE_XFER |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
76 } GaimSubType; |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
77 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
78 /** |
6562 | 79 * A wrapper for a type, subtype, and specific type of value. |
80 */ | |
81 typedef struct | |
82 { | |
83 GaimType type; | |
84 unsigned short flags; | |
85 | |
86 union | |
87 { | |
88 char char_data; | |
89 unsigned char uchar_data; | |
90 gboolean boolean_data; | |
91 short short_data; | |
92 unsigned short ushort_data; | |
93 int int_data; | |
94 unsigned int uint_data; | |
95 long long_data; | |
96 unsigned long ulong_data; | |
97 gint64 int64_data; | |
98 guint64 uint64_data; | |
99 char *string_data; | |
100 void *object_data; | |
101 void *pointer_data; | |
102 int enum_data; | |
103 void *boxed_data; | |
104 | |
105 } data; | |
106 | |
107 union | |
108 { | |
109 unsigned int subtype; | |
110 char *specific_type; | |
111 | |
112 } u; | |
113 | |
114 } GaimValue; | |
115 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
116 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
117 extern "C" { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
118 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
119 |
6562 | 120 /** |
121 * Creates a new GaimValue. | |
122 * | |
123 * This function takes a type and, depending on that type, a sub-type | |
124 * or specific type. | |
125 * | |
10477 | 126 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 127 * string representing the specific type. |
128 * | |
129 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
130 * integer or enum representing the sub-type. | |
131 * | |
132 * If the subtype or specific type is not set when required, random | |
133 * errors may occur. You have been warned. | |
134 * | |
135 * @param type The type. | |
136 * | |
137 * @return The new value. | |
138 */ | |
139 GaimValue *gaim_value_new(GaimType type, ...); | |
140 | |
141 /** | |
10477 | 142 * Creates a new outgoing GaimValue. If a value is an "outgoing" value |
143 * it means the value can be modified by plugins and scripts. | |
6562 | 144 * |
145 * This function takes a type and, depending on that type, a sub-type | |
146 * or specific type. | |
147 * | |
10477 | 148 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 149 * string representing the specific type. |
150 * | |
151 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
152 * integer or enum representing the sub-type. | |
153 * | |
154 * If the sub-type or specific type is not set when required, random | |
155 * errors may occur. You have been warned. | |
156 * | |
157 * @param type The type. | |
158 * | |
159 * @return The new value. | |
160 */ | |
161 GaimValue *gaim_value_new_outgoing(GaimType type, ...); | |
162 | |
163 /** | |
164 * Destroys a GaimValue. | |
165 * | |
166 * @param value The value to destroy. | |
167 */ | |
168 void gaim_value_destroy(GaimValue *value); | |
169 | |
170 /** | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 * Duplicated a GaimValue. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
173 * @param value The value to duplicate. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
174 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
175 * @return The duplicate value. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 */ |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 GaimValue *gaim_value_dup(const GaimValue *value); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
179 /** |
6562 | 180 * Returns a value's type. |
181 * | |
10071 | 182 * @param value The value whose type you want. |
183 * | |
6562 | 184 * @return The value's type. |
185 */ | |
186 GaimType gaim_value_get_type(const GaimValue *value); | |
187 | |
188 /** | |
189 * Returns a value's subtype. | |
190 * | |
191 * If the value's type is not GAIM_TYPE_SUBTYPE, this will return 0. | |
192 * Subtypes should never have a subtype of 0. | |
193 * | |
10071 | 194 * @param value The value whose subtype you want. |
195 * | |
6562 | 196 * @return The value's subtype, or 0 if @a type is not GAIM_TYPE_SUBTYPE. |
197 */ | |
198 unsigned int gaim_value_get_subtype(const GaimValue *value); | |
199 | |
200 /** | |
201 * Returns a value's specific type. | |
202 * | |
203 * If the value's type is not GAIM_TYPE_BOXED, this will return @c NULL. | |
204 * | |
10071 | 205 * @param value The value whose specific type you want. |
206 * | |
6562 | 207 * @return The value's specific type, or @a NULL if not GAIM_TYPE_BOXED. |
208 */ | |
209 const char *gaim_value_get_specific_type(const GaimValue *value); | |
210 | |
211 /** | |
212 * Returns whether or not the value is an outgoing value. | |
213 * | |
214 * @param value The value. | |
215 * | |
216 * @return TRUE if the value is outgoing, or FALSE otherwise. | |
217 */ | |
218 gboolean gaim_value_is_outgoing(const GaimValue *value); | |
219 | |
220 /** | |
221 * Sets the value's character data. | |
222 * | |
223 * @param value The value. | |
224 * @param data The character data. | |
225 */ | |
226 void gaim_value_set_char(GaimValue *value, char data); | |
227 | |
228 /** | |
229 * Sets the value's unsigned character data. | |
230 * | |
231 * @param value The value. | |
232 * @param data The unsigned character data. | |
233 */ | |
234 void gaim_value_set_uchar(GaimValue *value, unsigned char data); | |
235 | |
236 /** | |
237 * Sets the value's boolean data. | |
238 * | |
239 * @param value The value. | |
240 * @param data The boolean data. | |
241 */ | |
242 void gaim_value_set_boolean(GaimValue *value, gboolean data); | |
243 | |
244 /** | |
245 * Sets the value's short integer data. | |
246 * | |
247 * @param value The value. | |
248 * @param data The short integer data. | |
249 */ | |
250 void gaim_value_set_short(GaimValue *value, short data); | |
251 | |
252 /** | |
253 * Sets the value's unsigned short integer data. | |
254 * | |
255 * @param value The value. | |
256 * @param data The unsigned short integer data. | |
257 */ | |
258 void gaim_value_set_ushort(GaimValue *value, unsigned short data); | |
259 | |
260 /** | |
261 * Sets the value's integer data. | |
262 * | |
263 * @param value The value. | |
264 * @param data The integer data. | |
265 */ | |
266 void gaim_value_set_int(GaimValue *value, int data); | |
267 | |
268 /** | |
269 * Sets the value's unsigned integer data. | |
270 * | |
271 * @param value The value. | |
272 * @param data The unsigned integer data. | |
273 */ | |
274 void gaim_value_set_uint(GaimValue *value, unsigned int data); | |
275 | |
276 /** | |
277 * Sets the value's long integer data. | |
278 * | |
279 * @param value The value. | |
280 * @param data The long integer data. | |
281 */ | |
282 void gaim_value_set_long(GaimValue *value, long data); | |
283 | |
284 /** | |
285 * Sets the value's unsigned long integer data. | |
286 * | |
287 * @param value The value. | |
288 * @param data The unsigned long integer data. | |
289 */ | |
290 void gaim_value_set_ulong(GaimValue *value, unsigned long data); | |
291 | |
292 /** | |
293 * Sets the value's 64-bit integer data. | |
294 * | |
295 * @param value The value. | |
296 * @param data The 64-bit integer data. | |
297 */ | |
298 void gaim_value_set_int64(GaimValue *value, gint64 data); | |
299 | |
300 /** | |
301 * Sets the value's unsigned 64-bit integer data. | |
302 * | |
303 * @param value The value. | |
304 * @param data The unsigned 64-bit integer data. | |
305 */ | |
306 void gaim_value_set_uint64(GaimValue *value, guint64 data); | |
307 | |
308 /** | |
309 * Sets the value's string data. | |
310 * | |
311 * @param value The value. | |
312 * @param data The string data. | |
313 */ | |
314 void gaim_value_set_string(GaimValue *value, const char *data); | |
315 | |
316 /** | |
317 * Sets the value's object data. | |
318 * | |
319 * @param value The value. | |
320 * @param data The object data. | |
321 */ | |
322 void gaim_value_set_object(GaimValue *value, void *data); | |
323 | |
324 /** | |
325 * Sets the value's pointer data. | |
326 * | |
327 * @param value The value. | |
328 * @param data The pointer data. | |
329 */ | |
330 void gaim_value_set_pointer(GaimValue *value, void *data); | |
331 | |
332 /** | |
333 * Sets the value's enum data. | |
334 * | |
335 * @param value The value. | |
336 * @param data The enum data. | |
337 */ | |
338 void gaim_value_set_enum(GaimValue *value, int data); | |
339 | |
340 /** | |
341 * Sets the value's boxed data. | |
342 * | |
343 * @param value The value. | |
344 * @param data The boxed data. | |
345 */ | |
346 void gaim_value_set_boxed(GaimValue *value, void *data); | |
347 | |
348 /** | |
349 * Returns the value's character data. | |
350 * | |
351 * @param value The value. | |
352 * | |
353 * @return The character data. | |
354 */ | |
355 char gaim_value_get_char(const GaimValue *value); | |
356 | |
357 /** | |
358 * Returns the value's unsigned character data. | |
359 * | |
360 * @param value The value. | |
361 * | |
362 * @return The unsigned character data. | |
363 */ | |
364 unsigned char gaim_value_get_uchar(const GaimValue *value); | |
365 | |
366 /** | |
367 * Returns the value's boolean data. | |
368 * | |
369 * @param value The value. | |
370 * | |
371 * @return The boolean data. | |
372 */ | |
373 gboolean gaim_value_get_boolean(const GaimValue *value); | |
374 | |
375 /** | |
376 * Returns the value's short integer data. | |
377 * | |
378 * @param value The value. | |
379 * | |
380 * @return The short integer data. | |
381 */ | |
382 short gaim_value_get_short(const GaimValue *value); | |
383 | |
384 /** | |
385 * Returns the value's unsigned short integer data. | |
386 * | |
387 * @param value The value. | |
388 * | |
389 * @return The unsigned short integer data. | |
390 */ | |
391 unsigned short gaim_value_get_ushort(const GaimValue *value); | |
392 | |
393 /** | |
394 * Returns the value's integer data. | |
395 * | |
396 * @param value The value. | |
397 * | |
398 * @return The integer data. | |
399 */ | |
400 int gaim_value_get_int(const GaimValue *value); | |
401 | |
402 /** | |
403 * Returns the value's unsigned integer data. | |
404 * | |
405 * @param value The value. | |
406 * | |
407 * @return The unsigned integer data. | |
408 */ | |
409 unsigned int gaim_value_get_uint(const GaimValue *value); | |
410 | |
411 /** | |
412 * Returns the value's long integer data. | |
413 * | |
414 * @param value The value. | |
415 * | |
416 * @return The long integer data. | |
417 */ | |
418 long gaim_value_get_long(const GaimValue *value); | |
419 | |
420 /** | |
421 * Returns the value's unsigned long integer data. | |
422 * | |
423 * @param value The value. | |
424 * | |
425 * @return The unsigned long integer data. | |
426 */ | |
427 unsigned long gaim_value_get_ulong(const GaimValue *value); | |
428 | |
429 /** | |
430 * Returns the value's 64-bit integer data. | |
431 * | |
432 * @param value The value. | |
433 * | |
434 * @return The 64-bit integer data. | |
435 */ | |
436 gint64 gaim_value_get_int64(const GaimValue *value); | |
437 | |
438 /** | |
439 * Returns the value's unsigned 64-bit integer data. | |
440 * | |
441 * @param value The value. | |
442 * | |
443 * @return The unsigned 64-bit integer data. | |
444 */ | |
445 guint64 gaim_value_get_uint64(const GaimValue *value); | |
446 | |
447 /** | |
448 * Returns the value's string data. | |
449 * | |
450 * @param value The value. | |
451 * | |
452 * @return The string data. | |
453 */ | |
454 const char *gaim_value_get_string(const GaimValue *value); | |
455 | |
456 /** | |
457 * Returns the value's object data. | |
458 * | |
459 * @param value The value. | |
460 * | |
461 * @return The object data. | |
462 */ | |
463 void *gaim_value_get_object(const GaimValue *value); | |
464 | |
465 /** | |
466 * Returns the value's pointer data. | |
467 * | |
468 * @param value The value. | |
469 * | |
470 * @return The pointer data. | |
471 */ | |
472 void *gaim_value_get_pointer(const GaimValue *value); | |
473 | |
474 /** | |
475 * Returns the value's enum data. | |
476 * | |
477 * @param value The value. | |
478 * | |
479 * @return The enum data. | |
480 */ | |
481 int gaim_value_get_enum(const GaimValue *value); | |
482 | |
483 /** | |
484 * Returns the value's boxed data. | |
485 * | |
486 * @param value The value. | |
487 * | |
488 * @return The boxed data. | |
489 */ | |
490 void *gaim_value_get_boxed(const GaimValue *value); | |
491 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
492 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
493 } |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
494 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
495 |
6562 | 496 #endif /* _GAIM_VALUE_H_ */ |