• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

go-glib-extras.h

Go to the documentation of this file.
00001 #ifndef GO_GLIB_EXTRAS_H
00002 #define GO_GLIB_EXTRAS_H
00003 
00004 #include <goffice/goffice.h>
00005 
00006 G_BEGIN_DECLS
00007 
00008 /* Misc convenience routines that would be nice to have in glib */
00009 
00010 typedef gpointer (*GOMapFunc) (gpointer value);
00011 
00012 void     go_ptr_array_insert    (GPtrArray *array, gpointer value, int index);
00013 
00014 GSList  *go_hash_keys       (GHashTable *hash);
00015 GSList  *go_hash_values     (GHashTable *hash);
00016 
00017 GSList  *go_slist_map       (GSList const *list, GOMapFunc map_func);
00018 GSList  *go_slist_create    (gpointer item1, ...);
00019 void     go_slist_free_custom   (GSList *list, GFreeFunc free_func);
00020 #define  go_string_slist_copy(list) go_slist_map (list, (GOMapFunc) g_strdup)
00021 GSList  *go_strsplit_to_slist   (char const *str, gchar delimiter);
00022 #define GO_SLIST_FOREACH(list,valtype,val,stmnt) \
00023 G_STMT_START { \
00024     GSList const *go_l; \
00025     for (go_l = (list); go_l != NULL; go_l = go_l->next) { \
00026         valtype *val = go_l->data; \
00027         stmnt \
00028         ; \
00029     } \
00030 } G_STMT_END
00031 #define GO_SLIST_PREPEND(list,item) \
00032     (list = g_slist_prepend (list, item))
00033 #define GO_SLIST_APPEND(list,item) \
00034     (list = g_slist_append (list, item))
00035 #define GO_SLIST_REMOVE(list,item) \
00036     (list = g_slist_remove (list, item))
00037 #define GO_SLIST_CONCAT(list_a,list_b) \
00038     (list_a = g_slist_concat (list_a, list_b))
00039 #define GO_SLIST_REVERSE(list) \
00040     (list = g_slist_reverse (list))
00041 #define GO_SLIST_SORT(list,cmp_func) \
00042     (list = g_slist_sort (list, cmp_func))
00043 
00044 gint go_list_index_custom (GList *list, gpointer data, GCompareFunc cmp_func);
00045 void go_list_free_custom  (GList *list, GFreeFunc free_func);
00046 #define GO_LIST_FOREACH(list,valtype,val,stmnt) \
00047 G_STMT_START { \
00048     GList *go_l; \
00049     for (go_l = (list); go_l != NULL; go_l = go_l->next) { \
00050         valtype *val = go_l->data; \
00051         stmnt \
00052         ; \
00053     } \
00054 } G_STMT_END
00055 #define GO_LIST_PREPEND(list,item) \
00056     (list = g_list_prepend (list, item))
00057 #define GO_LIST_APPEND(list,item) \
00058     (list = g_list_append (list, item))
00059 #define GO_LIST_REMOVE(list,item) \
00060     (list = g_list_remove (list, item))
00061 #define GO_LIST_CONCAT(list_a,list_b) \
00062     (list_a = g_list_concat (list_a, list_b))
00063 #define GO_LIST_REVERSE(list) \
00064     (list = g_list_reverse (list))
00065 #define GO_LIST_SORT(list,cmp_func) \
00066     (list = g_list_sort (list, cmp_func))
00067 
00068 int     go_str_compare      (void const *x, void const *y);
00069 guint       go_ascii_strcase_hash   (gconstpointer v);
00070 gint        go_ascii_strcase_equal  (gconstpointer v, gconstpointer v2);
00071 gint        go_utf8_collate_casefold    (char const *a, char const *b);
00072 char       *go_utf8_strcapital      (char const *p, gssize len);
00073 void        go_strescape        (GString *target, char const *str);
00074 char const *go_strunescape      (GString *target, char const *str);
00075 void        go_string_append_gstring    (GString *target, const GString *src);
00076 void        go_string_append_c_n        (GString *target, char c, gsize n);
00077 void        go_string_replace           (GString *target,
00078                      gsize pos, gssize oldlen,
00079                      const char *txt, gssize newlen);
00080 
00081 char const *go_guess_encoding       (char const *raw, gsize len,
00082                      char const *user_guess,
00083                      char **utf8_str);
00084 
00085 char const *go_get_real_name        (void);
00086 void        go_destroy_password (char *passwd);
00087 
00088 GOMemChunk  *go_mem_chunk_new       (char const *name, gsize user_atom_size, gsize chunk_size);
00089 void         go_mem_chunk_destroy   (GOMemChunk *chunk, gboolean expect_leaks);
00090 gpointer     go_mem_chunk_alloc     (GOMemChunk *chunk);
00091 gpointer     go_mem_chunk_alloc0    (GOMemChunk *chunk);
00092 void         go_mem_chunk_free      (GOMemChunk *chunk, gpointer mem);
00093 void         go_mem_chunk_foreach_leak  (GOMemChunk *chunk, GFunc cb, gpointer user);
00094 
00095 void    go_object_toggle             (gpointer object,
00096                       const gchar *property_name);
00097 gboolean go_object_set_property (GObject *obj, const char *property_name,
00098                  const char *user_prop_name, const char *value,
00099                  GError **err,
00100                  const char *error_template);
00101 GSList *go_object_properties_collect (GObject *obj);
00102 void    go_object_properties_apply   (GObject *obj,
00103                       GSList *props,
00104                       gboolean changed_only);
00105 void    go_object_properties_free    (GSList *props);
00106 
00107 typedef gboolean (*GOParseKeyValueFunc) (const char *name,
00108           const char *value,
00109           GError **err,
00110           gpointer user);
00111 
00112 gboolean go_parse_key_value (const char *options,
00113                  GError **err,
00114                  GOParseKeyValueFunc handler,
00115                  gpointer user);
00116 
00117 G_END_DECLS
00118 
00119 #endif /* GO_GLIB_EXTRAS_H */

Generated on Wed Mar 5 2014 for AbiWord by  doxygen 1.7.1