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     PURPLE_SUBTYPE_CHATBUDDY
00084 } PurpleSubType;
00085 
00089 typedef struct
00090 {
00091     PurpleType type;
00092     unsigned short flags;
00093 
00094     union
00095     {
00096         char char_data;
00097         unsigned char uchar_data;
00098         gboolean boolean_data;
00099         short short_data;
00100         unsigned short ushort_data;
00101         int int_data;
00102         unsigned int uint_data;
00103         long long_data;
00104         unsigned long ulong_data;
00105         gint64 int64_data;
00106         guint64 uint64_data;
00107         char *string_data;
00108         void *object_data;
00109         void *pointer_data;
00110         int enum_data;
00111         void *boxed_data;
00112 
00113     } data;
00114 
00115     union
00116     {
00117         unsigned int subtype;
00118         char *specific_type;
00119 
00120     } u;
00121 
00122 } PurpleValue;
00123 
00124 #ifdef __cplusplus
00125 extern "C" {
00126 #endif
00127 
00147 PurpleValue *purple_value_new(PurpleType type, ...);
00148 
00169 PurpleValue *purple_value_new_outgoing(PurpleType type, ...);
00170 
00176 void purple_value_destroy(PurpleValue *value);
00177 
00185 PurpleValue *purple_value_dup(const PurpleValue *value);
00186 
00194 PurpleType purple_value_get_type(const PurpleValue *value);
00195 
00206 unsigned int purple_value_get_subtype(const PurpleValue *value);
00207 
00217 const char *purple_value_get_specific_type(const PurpleValue *value);
00218 
00226 gboolean purple_value_is_outgoing(const PurpleValue *value);
00227 
00234 void purple_value_set_char(PurpleValue *value, char data);
00235 
00242 void purple_value_set_uchar(PurpleValue *value, unsigned char data);
00243 
00250 void purple_value_set_boolean(PurpleValue *value, gboolean data);
00251 
00258 void purple_value_set_short(PurpleValue *value, short data);
00259 
00266 void purple_value_set_ushort(PurpleValue *value, unsigned short data);
00267 
00274 void purple_value_set_int(PurpleValue *value, int data);
00275 
00282 void purple_value_set_uint(PurpleValue *value, unsigned int data);
00283 
00290 void purple_value_set_long(PurpleValue *value, long data);
00291 
00298 void purple_value_set_ulong(PurpleValue *value, unsigned long data);
00299 
00306 void purple_value_set_int64(PurpleValue *value, gint64 data);
00307 
00314 void purple_value_set_uint64(PurpleValue *value, guint64 data);
00315 
00322 void purple_value_set_string(PurpleValue *value, const char *data);
00323 
00330 void purple_value_set_object(PurpleValue *value, void *data);
00331 
00338 void purple_value_set_pointer(PurpleValue *value, void *data);
00339 
00346 void purple_value_set_enum(PurpleValue *value, int data);
00347 
00354 void purple_value_set_boxed(PurpleValue *value, void *data);
00355 
00363 char purple_value_get_char(const PurpleValue *value);
00364 
00372 unsigned char purple_value_get_uchar(const PurpleValue *value);
00373 
00381 gboolean purple_value_get_boolean(const PurpleValue *value);
00382 
00390 short purple_value_get_short(const PurpleValue *value);
00391 
00399 unsigned short purple_value_get_ushort(const PurpleValue *value);
00400 
00408 int purple_value_get_int(const PurpleValue *value);
00409 
00417 unsigned int purple_value_get_uint(const PurpleValue *value);
00418 
00426 long purple_value_get_long(const PurpleValue *value);
00427 
00435 unsigned long purple_value_get_ulong(const PurpleValue *value);
00436 
00444 gint64 purple_value_get_int64(const PurpleValue *value);
00445 
00453 guint64 purple_value_get_uint64(const PurpleValue *value);
00454 
00462 const char *purple_value_get_string(const PurpleValue *value);
00463 
00471 void *purple_value_get_object(const PurpleValue *value);
00472 
00480 void *purple_value_get_pointer(const PurpleValue *value);
00481 
00489 int purple_value_get_enum(const PurpleValue *value);
00490 
00498 void *purple_value_get_boxed(const PurpleValue *value);
00499 
00500 #ifdef __cplusplus
00501 }
00502 #endif
00503 
00504 #endif /* _PURPLE_VALUE_H_ */