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