2 * @file value.h Value wrapper API
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_VALUE_H_
27 #define _PURPLE_VALUE_H_
32 * Specific value types.
36 PURPLE_TYPE_UNKNOWN
= 0, /**< Unknown type. */
37 PURPLE_TYPE_SUBTYPE
, /**< Subtype. */
38 PURPLE_TYPE_CHAR
, /**< Character. */
39 PURPLE_TYPE_UCHAR
, /**< Unsigned character. */
40 PURPLE_TYPE_BOOLEAN
, /**< Boolean. */
41 PURPLE_TYPE_SHORT
, /**< Short integer. */
42 PURPLE_TYPE_USHORT
, /**< Unsigned short integer. */
43 PURPLE_TYPE_INT
, /**< Integer. */
44 PURPLE_TYPE_UINT
, /**< Unsigned integer. */
45 PURPLE_TYPE_LONG
, /**< Long integer. */
46 PURPLE_TYPE_ULONG
, /**< Unsigned long integer. */
47 PURPLE_TYPE_INT64
, /**< 64-bit integer. */
48 PURPLE_TYPE_UINT64
, /**< 64-bit unsigned integer. */
49 PURPLE_TYPE_STRING
, /**< String. */
50 PURPLE_TYPE_OBJECT
, /**< Object pointer. */
51 PURPLE_TYPE_POINTER
, /**< Generic pointer. */
52 PURPLE_TYPE_ENUM
, /**< Enum. */
53 PURPLE_TYPE_BOXED
/**< Boxed pointer with specific type. */
59 * Purple-specific subtype values.
63 PURPLE_SUBTYPE_UNKNOWN
= 0,
64 PURPLE_SUBTYPE_ACCOUNT
,
66 PURPLE_SUBTYPE_BLIST_BUDDY
,
67 PURPLE_SUBTYPE_BLIST_GROUP
,
68 PURPLE_SUBTYPE_BLIST_CHAT
,
69 PURPLE_SUBTYPE_BUDDY_ICON
,
70 PURPLE_SUBTYPE_CONNECTION
,
71 PURPLE_SUBTYPE_CONVERSATION
,
72 PURPLE_SUBTYPE_PLUGIN
,
73 PURPLE_SUBTYPE_BLIST_NODE
,
74 PURPLE_SUBTYPE_CIPHER
,
75 PURPLE_SUBTYPE_STATUS
,
78 PURPLE_SUBTYPE_SAVEDSTATUS
,
79 PURPLE_SUBTYPE_XMLNODE
,
80 PURPLE_SUBTYPE_USERINFO
,
81 PURPLE_SUBTYPE_STORED_IMAGE
,
82 PURPLE_SUBTYPE_CERTIFICATEPOOL
86 * A wrapper for a type, subtype, and specific type of value.
96 unsigned char uchar_data
;
97 gboolean boolean_data
;
99 unsigned short ushort_data
;
101 unsigned int uint_data
;
103 unsigned long ulong_data
;
116 unsigned int subtype
;
128 * Creates a new PurpleValue.
130 * This function takes a type and, depending on that type, a sub-type
133 * If @a type is PURPLE_TYPE_BOXED, the next parameter must be a
134 * string representing the specific type.
136 * If @a type is PURPLE_TYPE_SUBTYPE, the next parameter must be a
137 * integer or enum representing the sub-type.
139 * If the subtype or specific type is not set when required, random
140 * errors may occur. You have been warned.
142 * @param type The type.
144 * @return The new value.
146 PurpleValue
*purple_value_new(PurpleType type
, ...);
149 * Creates a new outgoing PurpleValue. If a value is an "outgoing" value
150 * it means the value can be modified by plugins and scripts.
152 * This function takes a type and, depending on that type, a sub-type
155 * If @a type is PURPLE_TYPE_BOXED, the next parameter must be a
156 * string representing the specific type.
158 * If @a type is PURPLE_TYPE_SUBTYPE, the next parameter must be a
159 * integer or enum representing the sub-type.
161 * If the sub-type or specific type is not set when required, random
162 * errors may occur. You have been warned.
164 * @param type The type.
166 * @return The new value.
168 PurpleValue
*purple_value_new_outgoing(PurpleType type
, ...);
171 * Destroys a PurpleValue.
173 * @param value The value to destroy.
175 void purple_value_destroy(PurpleValue
*value
);
178 * Duplicated a PurpleValue.
180 * @param value The value to duplicate.
182 * @return The duplicate value.
184 PurpleValue
*purple_value_dup(const PurpleValue
*value
);
187 * Returns a value's type.
189 * @param value The value whose type you want.
191 * @return The value's type.
193 PurpleType
purple_value_get_type(const PurpleValue
*value
);
196 * Returns a value's subtype.
198 * If the value's type is not PURPLE_TYPE_SUBTYPE, this will return 0.
199 * Subtypes should never have a subtype of 0.
201 * @param value The value whose subtype you want.
203 * @return The value's subtype, or 0 if @a type is not PURPLE_TYPE_SUBTYPE.
205 unsigned int purple_value_get_subtype(const PurpleValue
*value
);
208 * Returns a value's specific type.
210 * If the value's type is not PURPLE_TYPE_BOXED, this will return @c NULL.
212 * @param value The value whose specific type you want.
214 * @return The value's specific type, or @a NULL if not PURPLE_TYPE_BOXED.
216 const char *purple_value_get_specific_type(const PurpleValue
*value
);
219 * Returns whether or not the value is an outgoing value.
221 * @param value The value.
223 * @return TRUE if the value is outgoing, or FALSE otherwise.
225 gboolean
purple_value_is_outgoing(const PurpleValue
*value
);
228 * Sets the value's character data.
230 * @param value The value.
231 * @param data The character data.
233 void purple_value_set_char(PurpleValue
*value
, char data
);
236 * Sets the value's unsigned character data.
238 * @param value The value.
239 * @param data The unsigned character data.
241 void purple_value_set_uchar(PurpleValue
*value
, unsigned char data
);
244 * Sets the value's boolean data.
246 * @param value The value.
247 * @param data The boolean data.
249 void purple_value_set_boolean(PurpleValue
*value
, gboolean data
);
252 * Sets the value's short integer data.
254 * @param value The value.
255 * @param data The short integer data.
257 void purple_value_set_short(PurpleValue
*value
, short data
);
260 * Sets the value's unsigned short integer data.
262 * @param value The value.
263 * @param data The unsigned short integer data.
265 void purple_value_set_ushort(PurpleValue
*value
, unsigned short data
);
268 * Sets the value's integer data.
270 * @param value The value.
271 * @param data The integer data.
273 void purple_value_set_int(PurpleValue
*value
, int data
);
276 * Sets the value's unsigned integer data.
278 * @param value The value.
279 * @param data The unsigned integer data.
281 void purple_value_set_uint(PurpleValue
*value
, unsigned int data
);
284 * Sets the value's long integer data.
286 * @param value The value.
287 * @param data The long integer data.
289 void purple_value_set_long(PurpleValue
*value
, long data
);
292 * Sets the value's unsigned long integer data.
294 * @param value The value.
295 * @param data The unsigned long integer data.
297 void purple_value_set_ulong(PurpleValue
*value
, unsigned long data
);
300 * Sets the value's 64-bit integer data.
302 * @param value The value.
303 * @param data The 64-bit integer data.
305 void purple_value_set_int64(PurpleValue
*value
, gint64 data
);
308 * Sets the value's unsigned 64-bit integer data.
310 * @param value The value.
311 * @param data The unsigned 64-bit integer data.
313 void purple_value_set_uint64(PurpleValue
*value
, guint64 data
);
316 * Sets the value's string data.
318 * @param value The value.
319 * @param data The string data.
321 void purple_value_set_string(PurpleValue
*value
, const char *data
);
324 * Sets the value's object data.
326 * @param value The value.
327 * @param data The object data.
329 void purple_value_set_object(PurpleValue
*value
, void *data
);
332 * Sets the value's pointer data.
334 * @param value The value.
335 * @param data The pointer data.
337 void purple_value_set_pointer(PurpleValue
*value
, void *data
);
340 * Sets the value's enum data.
342 * @param value The value.
343 * @param data The enum data.
345 void purple_value_set_enum(PurpleValue
*value
, int data
);
348 * Sets the value's boxed data.
350 * @param value The value.
351 * @param data The boxed data.
353 void purple_value_set_boxed(PurpleValue
*value
, void *data
);
356 * Returns the value's character data.
358 * @param value The value.
360 * @return The character data.
362 char purple_value_get_char(const PurpleValue
*value
);
365 * Returns the value's unsigned character data.
367 * @param value The value.
369 * @return The unsigned character data.
371 unsigned char purple_value_get_uchar(const PurpleValue
*value
);
374 * Returns the value's boolean data.
376 * @param value The value.
378 * @return The boolean data.
380 gboolean
purple_value_get_boolean(const PurpleValue
*value
);
383 * Returns the value's short integer data.
385 * @param value The value.
387 * @return The short integer data.
389 short purple_value_get_short(const PurpleValue
*value
);
392 * Returns the value's unsigned short integer data.
394 * @param value The value.
396 * @return The unsigned short integer data.
398 unsigned short purple_value_get_ushort(const PurpleValue
*value
);
401 * Returns the value's integer data.
403 * @param value The value.
405 * @return The integer data.
407 int purple_value_get_int(const PurpleValue
*value
);
410 * Returns the value's unsigned integer data.
412 * @param value The value.
414 * @return The unsigned integer data.
416 unsigned int purple_value_get_uint(const PurpleValue
*value
);
419 * Returns the value's long integer data.
421 * @param value The value.
423 * @return The long integer data.
425 long purple_value_get_long(const PurpleValue
*value
);
428 * Returns the value's unsigned long integer data.
430 * @param value The value.
432 * @return The unsigned long integer data.
434 unsigned long purple_value_get_ulong(const PurpleValue
*value
);
437 * Returns the value's 64-bit integer data.
439 * @param value The value.
441 * @return The 64-bit integer data.
443 gint64
purple_value_get_int64(const PurpleValue
*value
);
446 * Returns the value's unsigned 64-bit integer data.
448 * @param value The value.
450 * @return The unsigned 64-bit integer data.
452 guint64
purple_value_get_uint64(const PurpleValue
*value
);
455 * Returns the value's string data.
457 * @param value The value.
459 * @return The string data.
461 const char *purple_value_get_string(const PurpleValue
*value
);
464 * Returns the value's object data.
466 * @param value The value.
468 * @return The object data.
470 void *purple_value_get_object(const PurpleValue
*value
);
473 * Returns the value's pointer data.
475 * @param value The value.
477 * @return The pointer data.
479 void *purple_value_get_pointer(const PurpleValue
*value
);
482 * Returns the value's enum data.
484 * @param value The value.
486 * @return The enum data.
488 int purple_value_get_enum(const PurpleValue
*value
);
491 * Returns the value's boxed data.
493 * @param value The value.
495 * @return The boxed data.
497 void *purple_value_get_boxed(const PurpleValue
*value
);
503 #endif /* _PURPLE_VALUE_H_ */