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