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