value.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 #ifndef _PURPLE_VALUE_H_
00027 #define _PURPLE_VALUE_H_
00028 
00029 #include <glib.h>
00030 
00034 typedef enum
00035 {
00036     PURPLE_TYPE_UNKNOWN = 0,  
00037     PURPLE_TYPE_SUBTYPE,      
00038     PURPLE_TYPE_CHAR,         
00039     PURPLE_TYPE_UCHAR,        
00040     PURPLE_TYPE_BOOLEAN,      
00041     PURPLE_TYPE_SHORT,        
00042     PURPLE_TYPE_USHORT,       
00043     PURPLE_TYPE_INT,          
00044     PURPLE_TYPE_UINT,         
00045     PURPLE_TYPE_LONG,         
00046     PURPLE_TYPE_ULONG,        
00047     PURPLE_TYPE_INT64,        
00048     PURPLE_TYPE_UINT64,       
00049     PURPLE_TYPE_STRING,       
00050     PURPLE_TYPE_OBJECT,       
00051     PURPLE_TYPE_POINTER,      
00052     PURPLE_TYPE_ENUM,         
00053     PURPLE_TYPE_BOXED         
00055 } PurpleType;
00056 
00057 
00061 typedef enum
00062 {
00063     PURPLE_SUBTYPE_UNKNOWN = 0,
00064     PURPLE_SUBTYPE_ACCOUNT,
00065     PURPLE_SUBTYPE_BLIST,
00066     PURPLE_SUBTYPE_BLIST_BUDDY,
00067     PURPLE_SUBTYPE_BLIST_GROUP,
00068     PURPLE_SUBTYPE_BLIST_CHAT,
00069     PURPLE_SUBTYPE_BUDDY_ICON,
00070     PURPLE_SUBTYPE_CONNECTION,
00071     PURPLE_SUBTYPE_CONVERSATION,
00072     PURPLE_SUBTYPE_PLUGIN,
00073     PURPLE_SUBTYPE_BLIST_NODE,
00074     PURPLE_SUBTYPE_CIPHER,
00075     PURPLE_SUBTYPE_STATUS,
00076     PURPLE_SUBTYPE_LOG,
00077     PURPLE_SUBTYPE_XFER,
00078     PURPLE_SUBTYPE_SAVEDSTATUS,
00079     PURPLE_SUBTYPE_XMLNODE,
00080     PURPLE_SUBTYPE_USERINFO,
00081     PURPLE_SUBTYPE_STORED_IMAGE,
00082     PURPLE_SUBTYPE_CERTIFICATEPOOL
00083 } PurpleSubType;
00084 
00088 typedef struct
00089 {
00090     PurpleType type;
00091     unsigned short flags;
00092 
00093     union
00094     {
00095         char char_data;
00096         unsigned char uchar_data;
00097         gboolean boolean_data;
00098         short short_data;
00099         unsigned short ushort_data;
00100         int int_data;
00101         unsigned int uint_data;
00102         long long_data;
00103         unsigned long ulong_data;
00104         gint64 int64_data;
00105         guint64 uint64_data;
00106         char *string_data;
00107         void *object_data;
00108         void *pointer_data;
00109         int enum_data;
00110         void *boxed_data;
00111 
00112     } data;
00113 
00114     union
00115     {
00116         unsigned int subtype;
00117         char *specific_type;
00118 
00119     } u;
00120 
00121 } PurpleValue;
00122 
00123 #ifdef __cplusplus
00124 extern "C" {
00125 #endif
00126 
00146 PurpleValue *purple_value_new(PurpleType type, ...);
00147 
00168 PurpleValue *purple_value_new_outgoing(PurpleType type, ...);
00169 
00175 void purple_value_destroy(PurpleValue *value);
00176 
00184 PurpleValue *purple_value_dup(const PurpleValue *value);
00185 
00193 PurpleType purple_value_get_type(const PurpleValue *value);
00194 
00205 unsigned int purple_value_get_subtype(const PurpleValue *value);
00206 
00216 const char *purple_value_get_specific_type(const PurpleValue *value);
00217 
00225 gboolean purple_value_is_outgoing(const PurpleValue *value);
00226 
00233 void purple_value_set_char(PurpleValue *value, char data);
00234 
00241 void purple_value_set_uchar(PurpleValue *value, unsigned char data);
00242 
00249 void purple_value_set_boolean(PurpleValue *value, gboolean data);
00250 
00257 void purple_value_set_short(PurpleValue *value, short data);
00258 
00265 void purple_value_set_ushort(PurpleValue *value, unsigned short data);
00266 
00273 void purple_value_set_int(PurpleValue *value, int data);
00274 
00281 void purple_value_set_uint(PurpleValue *value, unsigned int data);
00282 
00289 void purple_value_set_long(PurpleValue *value, long data);
00290 
00297 void purple_value_set_ulong(PurpleValue *value, unsigned long data);
00298 
00305 void purple_value_set_int64(PurpleValue *value, gint64 data);
00306 
00313 void purple_value_set_uint64(PurpleValue *value, guint64 data);
00314 
00321 void purple_value_set_string(PurpleValue *value, const char *data);
00322 
00329 void purple_value_set_object(PurpleValue *value, void *data);
00330 
00337 void purple_value_set_pointer(PurpleValue *value, void *data);
00338 
00345 void purple_value_set_enum(PurpleValue *value, int data);
00346 
00353 void purple_value_set_boxed(PurpleValue *value, void *data);
00354 
00362 char purple_value_get_char(const PurpleValue *value);
00363 
00371 unsigned char purple_value_get_uchar(const PurpleValue *value);
00372 
00380 gboolean purple_value_get_boolean(const PurpleValue *value);
00381 
00389 short purple_value_get_short(const PurpleValue *value);
00390 
00398 unsigned short purple_value_get_ushort(const PurpleValue *value);
00399 
00407 int purple_value_get_int(const PurpleValue *value);
00408 
00416 unsigned int purple_value_get_uint(const PurpleValue *value);
00417 
00425 long purple_value_get_long(const PurpleValue *value);
00426 
00434 unsigned long purple_value_get_ulong(const PurpleValue *value);
00435 
00443 gint64 purple_value_get_int64(const PurpleValue *value);
00444 
00452 guint64 purple_value_get_uint64(const PurpleValue *value);
00453 
00461 const char *purple_value_get_string(const PurpleValue *value);
00462 
00470 void *purple_value_get_object(const PurpleValue *value);
00471 
00479 void *purple_value_get_pointer(const PurpleValue *value);
00480 
00488 int purple_value_get_enum(const PurpleValue *value);
00489 
00497 void *purple_value_get_boxed(const PurpleValue *value);
00498 
00499 #ifdef __cplusplus
00500 }
00501 #endif
00502 
00503 #endif /* _PURPLE_VALUE_H_ */