00001
00010 #ifndef _VALUE_H_
00011 #define _VALUE_H_
00012
00013 #include <gtk/gtk.h>
00014
00015
00016 typedef enum {
00017 T_ILLEGAL,
00018
00019 T_NONE,
00020 T_INT,
00021 T_FLOAT,
00022 T_BOOL,
00023 T_STRING
00024 } valuetype_t;
00025
00026
00027 struct s_value {
00028 valuetype_t valuetype;
00030
00031 union {
00032 guint vint;
00033 gdouble vfloat;
00034 gboolean vbool;
00035 gchar * vstring;
00036 } content;
00037 };
00038
00039
00040 #define VALUE_TYPE(class) ((CLASS(class))->value.valuetype)
00041 #define VALUE_VALUE(class, type) \
00042 ({ \
00043 if(type & VALUE_TYPE(class) == 0) \
00044 { g_critical("not compatible types\n"); } \
00045 else \
00046 { \
00047 switch(VALUE_TYPE(class)) \
00048 { \
00049 case T_INT : CLASS(class)->value.content.vint; \
00050 case T_FLOAT : CLASS(class)->value.content.vfloat; \
00051 case T_BOOL : CLASS(class)->value.content.vbool; \
00052 case T_STRING: CLASS(class)->value.content.vstring; \
00053 } \
00054 } \
00055 })
00056
00057
00058
00059 void value_set(struct s_value *, valuetype_t, ...);
00060 void value_unset(struct s_value);
00061 void value_translate(struct s_value, struct s_value);
00062 #ifdef DEBUG
00063 gchar *value_subdebug(struct s_value);
00064 #endif
00065 #endif