📄 glib-full.h
字号:
G_LOG_LEVEL_ERROR, \ format, ##args)#define g_message(format, args...) g_log (G_LOG_DOMAIN, \ G_LOG_LEVEL_MESSAGE, \ format, ##args)#define g_warning(format, args...) g_log (G_LOG_DOMAIN, \ G_LOG_LEVEL_WARNING, \ format, ##args)#else /* !__GNUC__ */static voidg_error (const gchar *format, ...){ va_list args; va_start (args, format); g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); va_end (args);}static voidg_message (const gchar *format, ...){ va_list args; va_start (args, format); g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); va_end (args);}static voidg_warning (const gchar *format, ...){ va_list args; va_start (args, format); g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); va_end (args);}#endif /* !__GNUC__ */typedef void (*GPrintFunc) (const gchar *string);void g_print (const gchar *format, ...) G_GNUC_PRINTF (1, 2);GPrintFunc g_set_print_handler (GPrintFunc func);void g_printerr (const gchar *format, ...) G_GNUC_PRINTF (1, 2);GPrintFunc g_set_printerr_handler (GPrintFunc func);/* deprecated compatibility functions, use g_log_set_handler() instead */typedef void (*GErrorFunc) (const gchar *str);typedef void (*GWarningFunc) (const gchar *str);GErrorFunc g_set_error_handler (GErrorFunc func);GWarningFunc g_set_warning_handler (GWarningFunc func);GPrintFunc g_set_message_handler (GPrintFunc func);/* Memory allocation and debugging */#ifdef USE_DMALLOC#define g_malloc(size) ((gpointer) MALLOC (size))#define g_malloc0(size) ((gpointer) CALLOC (char, size))#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))#define g_free(mem) FREE (mem)#else /* !USE_DMALLOC */gpointer g_malloc (gulong size);gpointer g_malloc0 (gulong size);gpointer g_realloc (gpointer mem, gulong size);void g_free (gpointer mem);#endif /* !USE_DMALLOC */void g_mem_profile (void);void g_mem_check (gpointer mem);/* Generic allocators */GAllocator* g_allocator_new (const gchar *name, guint n_preallocs);void g_allocator_free (GAllocator *allocator);#define G_ALLOCATOR_LIST (1)#define G_ALLOCATOR_SLIST (2)#define G_ALLOCATOR_NODE (3)/* "g_mem_chunk_new" creates a new memory chunk. * Memory chunks are used to allocate pieces of memory which are * always the same size. Lists are a good example of such a data type. * The memory chunk allocates and frees blocks of memory as needed. * Just be sure to call "g_mem_chunk_free" and not "g_free" on data * allocated in a mem chunk. ("g_free" will most likely cause a seg * fault...somewhere). * * Oh yeah, GMemChunk is an opaque data type. (You don't really * want to know what's going on inside do you?) *//* ALLOC_ONLY MemChunk's can only allocate memory. The free operation * is interpreted as a no op. ALLOC_ONLY MemChunk's save 4 bytes per * atom. (They are also useful for lists which use MemChunk to allocate * memory but are also part of the MemChunk implementation). * ALLOC_AND_FREE MemChunk's can allocate and free memory. */#define G_ALLOC_ONLY 1#define G_ALLOC_AND_FREE 2GMemChunk* g_mem_chunk_new (gchar *name, gint atom_size, gulong area_size, gint type);void g_mem_chunk_destroy (GMemChunk *mem_chunk);gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);void g_mem_chunk_free (GMemChunk *mem_chunk, gpointer mem);void g_mem_chunk_clean (GMemChunk *mem_chunk);void g_mem_chunk_reset (GMemChunk *mem_chunk);void g_mem_chunk_print (GMemChunk *mem_chunk);void g_mem_chunk_info (void);/* Ah yes...we have a "g_blow_chunks" function. * "g_blow_chunks" simply compresses all the chunks. This operation * consists of freeing every memory area that should be freed (but * which we haven't gotten around to doing yet). And, no, * "g_blow_chunks" doesn't follow the naming scheme, but it is a * much better name than "g_mem_chunk_clean_all" or something * similar. */void g_blow_chunks (void);/* Timer */GTimer* g_timer_new (void);void g_timer_destroy (GTimer *timer);void g_timer_start (GTimer *timer);void g_timer_stop (GTimer *timer);void g_timer_reset (GTimer *timer);gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);/* String utility functions that modify a string argument or * return a constant string that must not be freed. */#define G_STR_DELIMITERS "_-|> <."gchar* g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);gdouble g_strtod (const gchar *nptr, gchar **endptr);gchar* g_strerror (gint errnum);gchar* g_strsignal (gint signum);gint g_strcasecmp (const gchar *s1, const gchar *s2);gint g_strncasecmp (const gchar *s1, const gchar *s2, guint n);void g_strdown (gchar *string);void g_strup (gchar *string);void g_strreverse (gchar *string);/* removes leading spaces */gchar* g_strchug (gchar *string);/* removes trailing spaces */gchar* g_strchomp (gchar *string);/* removes leading & trailing spaces */#define g_strstrip( string ) g_strchomp (g_strchug (string))/* String utility functions that return a newly allocated string which * ought to be freed from the caller at some point. */gchar* g_strdup (const gchar *str);gchar* g_strdup_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2);gchar* g_strdup_vprintf (const gchar *format, va_list args);gchar* g_strndup (const gchar *str, guint n);gchar* g_strnfill (guint length, gchar fill_char);gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */gchar* g_strjoin (const gchar *separator, ...); /* NULL terminated */gchar* g_strescape (gchar *string);gpointer g_memdup (gconstpointer mem, guint byte_size);/* NULL terminated string arrays. * g_strsplit() splits up string into max_tokens tokens at delim and * returns a newly allocated string array. * g_strjoinv() concatenates all of str_array's strings, sliding in an * optional separator, the returned string is newly allocated. * g_strfreev() frees the array itself and all of its strings. */gchar** g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);gchar* g_strjoinv (const gchar *separator, gchar **str_array);void g_strfreev (gchar **str_array);/* calculate a string size, guarranteed to fit format + args. */guint g_printf_string_upper_bound (const gchar* format, va_list args);/* Retrive static string info */gchar* g_get_user_name (void);gchar* g_get_real_name (void);gchar* g_get_home_dir (void);gchar* g_get_tmp_dir (void);gchar* g_get_prgname (void);void g_set_prgname (const gchar *prgname);/* Miscellaneous utility functions */guint g_parse_debug_string (const gchar *string, GDebugKey *keys, guint nkeys);gint g_snprintf (gchar *string, gulong n, gchar const *format, ...) G_GNUC_PRINTF (3, 4);gint g_vsnprintf (gchar *string, gulong n, gchar const *format, va_list args);gchar* g_basename (const gchar *file_name);/* Check if a file name is an absolute path */gboolean g_path_is_absolute (const gchar *file_name);/* In case of absolute paths, skip the root part */gchar* g_path_skip_root (gchar *file_name);/* strings are newly allocated with g_malloc() */gchar* g_dirname (const gchar *file_name);gchar* g_get_current_dir (void);gchar* g_getenv (const gchar *variable);/* we use a GLib function as a replacement for ATEXIT, so * the programmer is not required to check the return value * (if there is any in the implementation) and doesn't encounter * missing include files. */void g_atexit (GVoidFunc func);/* Bit tests */G_INLINE_FUNC gint g_bit_nth_lsf (guint32 mask, gint nth_bit);#ifdef G_CAN_INLINEG_INLINE_FUNC gintg_bit_nth_lsf (guint32 mask, gint nth_bit){ do { nth_bit++; if (mask & (1 << (guint) nth_bit)) return nth_bit; } while (nth_bit < 32); return -1;}#endif /* G_CAN_INLINE */G_INLINE_FUNC gint g_bit_nth_msf (guint32 mask, gint nth_bit);#ifdef G_CAN_INLINEG_INLINE_FUNC gintg_bit_nth_msf (guint32 mask, gint nth_bit){ if (nth_bit < 0) nth_bit = 32; do { nth_bit--; if (mask & (1 << (guint) nth_bit)) return nth_bit; } while (nth_bit > 0); return -1;}#endif /* G_CAN_INLINE */G_INLINE_FUNC guint g_bit_storage (guint number);#ifdef G_CAN_INLINEG_INLINE_FUNC guintg_bit_storage (guint number){ register guint n_bits = 0; do { n_bits++; number >>= 1; } while (number); return n_bits;}#endif /* G_CAN_INLINE *//* String Chunks */GStringChunk* g_string_chunk_new (gint size);void g_string_chunk_free (GStringChunk *chunk);gchar* g_string_chunk_insert (GStringChunk *chunk, const gchar *string);gchar* g_string_chunk_insert_const (GStringChunk *chunk, const gchar *string);/* Strings */GString* g_string_new (const gchar *init);GString* g_string_sized_new (guint dfl_size);void g_string_free (GString *string, gint free_segment);GString* g_string_assign (GString *lval, const gchar *rval);GString* g_string_truncate (GString *string, gint len);GString* g_string_append (GString *string, const gchar *val);GString* g_string_append_c (GString *string, gchar c);GString* g_string_prepend (GString *string, const gchar *val);GString* g_string_prepend_c (GString *string, gchar c);GString* g_string_insert (GString *string, gint pos, const gchar *val);GString* g_string_insert_c (GString *string, gint pos, gchar c);GString* g_string_erase (GString *string, gint pos, gint len);GString* g_string_down (GString *string);GString* g_string_up (GString *string);void g_string_sprintf (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3);void g_string_sprintfa (GString *string, const gchar *format, ...) G_GNUC_PRINTF (2, 3);/* Resizable arrays, remove fills any cleared spot and shortens the * array, while preserving the order. remove_fast will distort the * order by moving the last element to the position of the removed */#define g_array_append_val(a,v) g_array_append_vals (a, &v, 1)#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &v, 1)#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1)#define g_array_index(a,t,i) (((t*) (a)->data) [(i)])GArray* g_array_new (gboolean zero_terminated, gboolean clear, guint element_size);void g_array_free (GArray *array, gboolean free_segment);GArray* g_array_append_vals (GArray *array, gconstpointer data, guint len);GArray* g_array_prepend_vals (GArray *array, gconstpointer data, guint len);GArray* g_array_insert_vals (GArray *array, guint index, gconstpointer data, guint len);GArray* g_array_set_size (GArray *array, guint length);GArray* g_array_remove_index (GArray *array, guint index);GArray* g_array_remove_index_fast (GArray *array, guint index);/* Resizable pointer array. This interface is much less complicated * than the above. Add appends appends a pointer. Remove fills any * cleared spot and shortens the array. remove_fast will again distort * order. */#define g_ptr_array_index(array,index) (array->pdata)[index]GPtrArray* g_ptr_array_new (void);void g_ptr_array_free (GPtrArray *array, gboolean free_seg);void g_ptr_array_set_size (GPtrArray *array, gint length);gpointer g_ptr_array_remove_index (GPtrArray *array, guint index);gpointer g_ptr_array_remove_index_fast (GPtrArray *array, guint index);gboolean g_ptr_array_remove (GPtrArray *array, gpointer data);gboolean g_ptr_array_remove_fast (GPtrArray *array, gpointer data);void g_ptr_array_add (GPtrArray *array, gpointer data);/* Byte arrays, an array of guint8. Implemented as a GArray, * but type-safe. */GByteArray* g_byte_array_new (void);void g_byte_array_free (GByteArray *array, gboolean free_segment);GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);GByteArray* g_byte_array_prepend (GByteArray *array, const guint8 *data, guint len);GByteArray* g_byte_array_set_size (GByteArray *array,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -