亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? gtk_tut-20.html

?? GTK development guide
?? HTML
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
 <TITLE>GTK v1.2 Tutorial: GLib</TITLE>
 <LINK HREF="gtk_tut-21.html" REL=next>
 <LINK HREF="gtk_tut-19.html" REL=previous>
 <LINK HREF="gtk_tut.html#toc20" REL=contents>
</HEAD>
<BODY TEXT="#CCCCCC" BGCOLOR="#000000" LINK="#33cc00" VLINK="#009900" ALINK="#FF0000">
<A HREF="gtk_tut-21.html">Next</A>
<A HREF="gtk_tut-19.html">Previous</A>
<A HREF="gtk_tut.html#toc20">Contents</A>
<HR>
<H2><A NAME="sec_glib"></A> <A NAME="s20">20. GLib</A></H2>

<P>GLib is a lower-level library that provides many useful definitions
and functions available for use when creating GDK and GTK
applications. These include definitions for basic types and their
limits, standard macros, type conversions, byte order, memory
allocation, warnings and assertions, message logging, timers, string
utilities, hook functions, a lexical scanner, dynamic loading of
modules, and automatic string completion. A number of data structures
(and their related operations) are also defined, including memory
chunks, doubly-linked lists, singly-linked lists, hash tables, strings
(which can grow dynamically), string chunks (groups of strings),
arrays (which can grow in size as elements are added), balanced binary
trees, N-ary trees, quarks (a two-way association of a string and a
unique integer identifier), keyed data lists (lists of data elements
accessible by a string or integer id), relations and tuples (tables of
data which can be indexed on any number of fields), and caches.
<P>A summary of some of GLib's capabilities follows; not every function,
data structure, or operation is covered here.  For more complete
information about the GLib routines, see the GLib documentation. One
source of GLib documentation is 
<A HREF="http://www.gtk.org/">http://www.gtk.org/</A>.
<P>If you are using a language other than C, you should consult your
language's binding documentation. In some cases your language may
have equivalent functionality built-in, while in other cases it may
not.
<P>
<H2><A NAME="ss20.1">20.1 Definitions</A>
</H2>

<P>Definitions for the extremes of many of the standard types are:
<P>
<BLOCKQUOTE><CODE>
<PRE>
G_MINFLOAT
G_MAXFLOAT
G_MINDOUBLE
G_MAXDOUBLE
G_MINSHORT
G_MAXSHORT
G_MININT
G_MAXINT
G_MINLONG
G_MAXLONG
</PRE>
</CODE></BLOCKQUOTE>
<P>Also, the following typedefs. The ones left unspecified are dynamically set
depending on the architecture. Remember to avoid counting on the size of a
pointer if you want to be portable! E.g., a pointer on an Alpha is 8
bytes, but 4 on Intel 80x86 family CPUs.
<P>
<BLOCKQUOTE><CODE>
<PRE>
char   gchar;
short  gshort;
long   glong;
int    gint;
char   gboolean;

unsigned char   guchar;
unsigned short  gushort;
unsigned long   gulong;
unsigned int    guint;

float   gfloat;
double  gdouble;
long double gldouble;

void* gpointer;

gint8
guint8
gint16
guint16
gint32
guint32
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss20.2">20.2 Doubly Linked Lists</A>
</H2>

<P>The following functions are used to create, manage, and destroy
standard doubly linked lists. Each element in the list contains a
piece of data, together with pointers which link to the previous and
next elements in the list. This enables easy movement in either
direction through the list. The data item is of type "gpointer",
which means the data can be a pointer to your real data or (through
casting) a numeric value (but do not assume that int and gpointer have
the same size!). These routines internally allocate list elements in
blocks, which is more efficient than allocating elements individually.
<P>There is no function to specifically create a list. Instead, simply
create a variable of type GList* and set its value to NULL; NULL is
considered to be the empty list.
<P>To add elements to a list, use the g_list_append(), g_list_prepend(),
g_list_insert(), or g_list_insert_sorted() routines. In all cases
they accept a pointer to the beginning of the list, and return the
(possibly changed) pointer to the beginning of the list. Thus, for
all of the operations that add or remove elements, be sure to save the
returned value!
<P>
<BLOCKQUOTE><CODE>
<PRE>
GList *g_list_append( GList    *list,
                      gpointer  data );
</PRE>
</CODE></BLOCKQUOTE>
<P>This adds a new element (with value <CODE>data</CODE>) onto the end of the
list.
<P>
<BLOCKQUOTE><CODE>
<PRE>
           
GList *g_list_prepend( GList    *list,
                       gpointer  data );
</PRE>
</CODE></BLOCKQUOTE>
<P>This adds a new element (with value <CODE>data</CODE>) to the beginning of the
list.
<P>
<BLOCKQUOTE><CODE>
<PRE>
                
GList *g_list_insert( GList    *list,
                      gpointer  data,
                      gint      position );
</PRE>
</CODE></BLOCKQUOTE>
<P>This inserts a new element (with value data) into the list at the
given position. If position is 0, this is just like g_list_prepend();
if position is less than 0, this is just like g_list_append().
<P>
<BLOCKQUOTE><CODE>
<PRE>
GList *g_list_remove( GList    *list,
                      gpointer  data );
</PRE>
</CODE></BLOCKQUOTE>
<P>This removes the element in the list with the value <CODE>data</CODE>;
if the element isn't there, the list is unchanged.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_list_free( GList *list );
</PRE>
</CODE></BLOCKQUOTE>
<P>This frees all of the memory used by a GList. If the list elements
refer to dynamically-allocated memory, then they should be freed
first.
<P>There are many other GLib functions that support doubly linked lists;
see the glib documentation for more information.  Here are a few of
the more useful functions' signatures:
<P>
<BLOCKQUOTE><CODE>
<PRE>
                   
GList *g_list_remove_link( GList *list,
                           GList *link );

GList *g_list_reverse( GList *list );

GList *g_list_nth( GList *list,
                   gint   n );
                           
GList *g_list_find( GList    *list,
                    gpointer  data );

GList *g_list_last( GList *list );

GList *g_list_first( GList *list );

gint g_list_length( GList *list );

void g_list_foreach( GList    *list,
                     GFunc     func,
                     gpointer  user_data );
</PRE>
</CODE></BLOCKQUOTE>
                                              
<P>
<H2><A NAME="ss20.3">20.3 Singly Linked Lists</A>
</H2>

<P>Many of the above functions for singly linked lists are identical to the
above. Here is a list of some of their operations:
<P>
<BLOCKQUOTE><CODE>
<PRE>
GSList *g_slist_append( GSList   *list,
                        gpointer  data );
                
GSList *g_slist_prepend( GSList   *list,
                         gpointer  data );
                             
GSList *g_slist_insert( GSList   *list,
                        gpointer  data,
                        gint      position );
                             
GSList *g_slist_remove( GSList   *list,
                        gpointer  data );
                             
GSList *g_slist_remove_link( GSList *list,
                             GSList *link );
                             
GSList *g_slist_reverse( GSList *list );

GSList *g_slist_nth( GSList *list,
                     gint    n );
                             
GSList *g_slist_find( GSList   *list,
                      gpointer  data );
                             
GSList *g_slist_last( GSList *list );

gint g_slist_length( GSList *list );

void g_slist_foreach( GSList   *list,
                      GFunc     func,
                      gpointer  user_data );
        
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss20.4">20.4 Memory Management</A>
</H2>

<P>
<BLOCKQUOTE><CODE>
<PRE>
gpointer g_malloc( gulong size );
</PRE>
</CODE></BLOCKQUOTE>
<P>This is a replacement for malloc(). You do not need to check the return
value as it is done for you in this function. If the memory allocation
fails for whatever reasons, your applications will be terminated.
<P>
<BLOCKQUOTE><CODE>
<PRE>
gpointer g_malloc0( gulong size );
</PRE>
</CODE></BLOCKQUOTE>
<P>Same as above, but zeroes the memory before returning a pointer to it.
<P>
<BLOCKQUOTE><CODE>
<PRE>
gpointer g_realloc( gpointer mem,
                    gulong   size );
</PRE>
</CODE></BLOCKQUOTE>
<P>Relocates "size" bytes of memory starting at "mem".  Obviously, the
memory should have been previously allocated.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_free( gpointer mem );
</PRE>
</CODE></BLOCKQUOTE>
<P>Frees memory. Easy one. If <CODE>mem</CODE> is NULL it simply returns.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_mem_profile( void );
</PRE>
</CODE></BLOCKQUOTE>
<P>Dumps a profile of used memory, but requires that you add <CODE>#define
MEM_PROFILE</CODE> to the top of glib/gmem.c and re-make and make install.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_mem_check( gpointer mem );
</PRE>
</CODE></BLOCKQUOTE>
<P>Checks that a memory location is valid. Requires you add <CODE>#define
MEM_CHECK</CODE> to the top of gmem.c and re-make and make install.
<P>
<H2><A NAME="ss20.5">20.5 Timers</A>
</H2>

<P>Timer functions can be used to time operations (e.g., to see how much
time has elapsed). First, you create a new timer with g_timer_new().
You can then use g_timer_start() to start timing an operation,
g_timer_stop() to stop timing an operation, and g_timer_elapsed() to
determine the elapsed time.
<P>
<BLOCKQUOTE><CODE>
<PRE>
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 );
</PRE>
</CODE></BLOCKQUOTE>
                         
<P>
<H2><A NAME="ss20.6">20.6 String Handling</A>
</H2>

<P>GLib defines a new type called a GString, which is similar to a
standard C string but one that grows automatically. Its string data
is null-terminated. What this gives you is protection from buffer
overflow programming errors within your program. This is a very
important feature, and hence I recommend that you make use of
GStrings. GString itself has a simple public definition:
<P>
<BLOCKQUOTE><CODE>
<PRE>
struct GString 
{
  gchar *str; /* Points to the string's current \0-terminated value. */
  gint len; /* Current length */
};
</PRE>
</CODE></BLOCKQUOTE>
<P>As you might expect, there are a number of operations you can do with
a GString.
<P>
<BLOCKQUOTE><CODE>
<PRE>
GString *g_string_new( gchar *init );
</PRE>
</CODE></BLOCKQUOTE>
<P>This constructs a GString, copying the string value of <CODE>init</CODE>
into the GString and returning a pointer to it. NULL may be given as
the argument for an initially empty GString.
<P>
<BLOCKQUOTE><CODE>
<PRE>

void g_string_free( GString *string,
                    gint     free_segment );
</PRE>
</CODE></BLOCKQUOTE>
<P>This frees the memory for the given GString. If <CODE>free_segment</CODE> is
TRUE, then this also frees its character data.
<P>
<BLOCKQUOTE><CODE>
<PRE>
                             
GString *g_string_assign( GString     *lval,
                          const gchar *rval );
</PRE>
</CODE></BLOCKQUOTE>
<P>This copies the characters from rval into lval, destroying the
previous contents of lval. Note that lval will be lengthened as
necessary to hold the string's contents, unlike the standard strcpy()
function.
<P>The rest of these functions should be relatively obvious (the _c
versions accept a character instead of a string):
<P>
<BLOCKQUOTE><CODE>
<PRE>
                     
GString *g_string_truncate( GString *string,
                            gint     len );
                             
GString *g_string_append( GString *string,
                          gchar   *val );
                            
GString *g_string_append_c( GString *string,
                            gchar    c );
        
GString *g_string_prepend( GString *string,
                           gchar   *val );
                             
GString *g_string_prepend_c( GString *string,
                             gchar    c );
        
void g_string_sprintf( GString *string,
                       gchar   *fmt,
                       ...);
        
void g_string_sprintfa ( GString *string,
                         gchar   *fmt,
                         ... );
</PRE>
</CODE></BLOCKQUOTE>
                                                          
<P>
<H2><A NAME="ss20.7">20.7 Utility and Error Functions</A>
</H2>

<P>
<BLOCKQUOTE><CODE>
<PRE>
gchar *g_strdup( const gchar *str );
</PRE>
</CODE></BLOCKQUOTE>
<P>Replacement strdup function.  Copies the original strings contents to
newly allocated memory, and returns a pointer to it.
<P>
<BLOCKQUOTE><CODE>
<PRE>
gchar *g_strerror( gint errnum );
</PRE>
</CODE></BLOCKQUOTE>
<P>I recommend using this for all error messages.  It's much nicer, and more
portable than perror() or others.  The output is usually of the form:
<P>
<BLOCKQUOTE><CODE>
<PRE>
program name:function that failed:file or further description:strerror
</PRE>
</CODE></BLOCKQUOTE>
<P>Here's an example of one such call used in our hello_world program:
<P>
<BLOCKQUOTE><CODE>
<PRE>
g_print("hello_world:open:%s:%s\n", filename, g_strerror(errno));
</PRE>
</CODE></BLOCKQUOTE>
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_error( gchar *format, ... );
</PRE>
</CODE></BLOCKQUOTE>
<P>Prints an error message. The format is just like printf, but it
prepends "** ERROR **: " to your message, and exits the program.  
Use only for fatal errors.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_warning( gchar *format, ... );
</PRE>
</CODE></BLOCKQUOTE>
<P>Same as above, but prepends "** WARNING **: ", and does not exit the
program.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_message( gchar *format, ... );
</PRE>
</CODE></BLOCKQUOTE>
<P>Prints "message: " prepended to the string you pass in.
<P>
<BLOCKQUOTE><CODE>
<PRE>
void g_print( gchar *format, ... );
</PRE>
</CODE></BLOCKQUOTE>
<P>Replacement for printf().
<P>And our last function:
<P>
<BLOCKQUOTE><CODE>
<PRE>
gchar *g_strsignal( gint signum );
</PRE>
</CODE></BLOCKQUOTE>
<P>Prints out the name of the Unix system signal given the signal number.
Useful in generic signal handling functions.
<P>All of the above are more or less just stolen from glib.h.  If anyone cares
to document any function, just send me an email!
<P>
<HR>
<A HREF="gtk_tut-21.html">Next</A>
<A HREF="gtk_tut-19.html">Previous</A>
<A HREF="gtk_tut.html#toc20">Contents</A>
</BODY>
</HTML>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区a| 亚洲蜜臀av乱码久久精品| 不卡视频一二三| 亚洲成人av在线电影| 久久免费看少妇高潮| 欧美影院精品一区| 国产精品一二三| 亚洲电影你懂得| 亚洲三级在线观看| 久久久久久影视| 91精品国产综合久久久久久漫画| 成人a级免费电影| 美女视频黄a大片欧美| 中文字幕一区二区三区不卡| 欧美成人综合网站| 欧美视频一区在线观看| 成人午夜激情视频| 精品一区二区在线观看| 午夜精品123| 亚洲男人电影天堂| 国产精品素人一区二区| 精品久久久网站| 欧美一区二区视频在线观看2022 | 成人精品视频一区二区三区尤物| 日日夜夜精品视频天天综合网| 中文字幕一区二区三区av| 国产欧美一区二区三区沐欲| 欧美成人bangbros| 欧美精品亚洲一区二区在线播放| av激情综合网| av激情亚洲男人天堂| 成人在线综合网站| 黄色日韩网站视频| 久久国产精品99精品国产| 五月婷婷综合激情| 亚洲国产乱码最新视频| 一级做a爱片久久| 国产精品久久久久久久久久久免费看| 久久久久久久性| 久久综合久久综合亚洲| 欧美一级国产精品| 日韩三区在线观看| 日韩午夜激情免费电影| 日韩视频免费直播| 精品乱人伦小说| 欧美精品一区二区三| 久久欧美一区二区| 国产日韩精品一区二区三区在线| 久久久噜噜噜久久人人看 | 有坂深雪av一区二区精品| 中文字幕一区二区三区精华液| 亚洲欧美综合在线精品| 一二三区精品福利视频| 一区二区三区中文字幕电影| 一区二区三区不卡在线观看| 亚洲高清在线视频| 蜜桃久久av一区| 国内外成人在线| 成人黄色小视频| 色综合久久88色综合天天免费| 91在线一区二区三区| 欧美性大战久久久久久久蜜臀| 在线观看免费一区| 777xxx欧美| 国产亚洲欧洲997久久综合 | 国产日韩精品一区二区浪潮av| 久久久精品国产免费观看同学| 久久精品免视看| 亚洲日本在线视频观看| 亚洲1区2区3区4区| 国产一区在线视频| 99精品视频在线观看| 欧美日韩dvd在线观看| 精品成a人在线观看| 国产精品高潮久久久久无| 亚洲一区二区五区| 国产毛片精品视频| 色av综合在线| 久久亚洲一级片| 亚洲免费观看在线观看| 日韩福利视频网| 国产ts人妖一区二区| 欧美日韩精品高清| 欧美国产精品一区| 日韩国产一二三区| 99久久精品免费看国产| 日韩精品在线一区二区| 亚洲免费高清视频在线| 九九在线精品视频| 日本国产一区二区| 久久免费看少妇高潮| 亚洲五码中文字幕| 国产成人av网站| 欧美精品色一区二区三区| 欧美国产一区二区| 日精品一区二区| 不卡一区在线观看| 欧美本精品男人aⅴ天堂| 亚洲精品国久久99热| 蜜桃av一区二区在线观看| 欧洲亚洲精品在线| 日本一区二区三区视频视频| 视频一区视频二区在线观看| 成人黄色大片在线观看| 欧美v日韩v国产v| 亚洲午夜三级在线| 成人av免费在线观看| 精品日韩av一区二区| 亚洲国产精品人人做人人爽| 国产成人免费在线观看不卡| 欧美一级淫片007| 亚洲福利视频一区二区| 91免费观看在线| 日本一区二区视频在线| 伦理电影国产精品| 欧美三级视频在线| 亚洲欧美激情插| 成人精品gif动图一区| 久久―日本道色综合久久| 日韩国产欧美三级| 欧美日韩免费视频| 一区二区三区免费| 91高清视频免费看| 一区二区在线观看视频在线观看| 成人激情小说乱人伦| 国产欧美日韩麻豆91| 国内一区二区在线| 2023国产精品自拍| 国产一区二区在线观看视频| 日韩视频免费观看高清在线视频| 日韩成人av影视| 宅男噜噜噜66一区二区66| 亚洲国产精品一区二区www在线| 欧美亚洲国产一区二区三区| 一区二区三区在线视频播放| 91日韩一区二区三区| 国产精品电影一区二区三区| 成年人午夜久久久| 17c精品麻豆一区二区免费| 成人午夜精品在线| 亚洲日本va午夜在线影院| 91在线一区二区三区| 一区二区三区国产| 欧美日韩国产乱码电影| 午夜欧美电影在线观看| 91精品国产色综合久久久蜜香臀| 日韩国产成人精品| 日韩一级大片在线观看| 精品系列免费在线观看| 久久老女人爱爱| jlzzjlzz国产精品久久| 一区二区在线看| 欧美一区二区视频在线观看| 韩国午夜理伦三级不卡影院| 国产欧美一区二区精品性| 91女人视频在线观看| 亚洲二区视频在线| 精品噜噜噜噜久久久久久久久试看| 国产一区二区三区| 国产精品你懂的| 欧美色综合网站| 久久精品国产久精国产爱| 国产欧美一区二区精品婷婷 | 国产一区三区三区| 亚洲丝袜精品丝袜在线| 7777精品伊人久久久大香线蕉经典版下载 | a在线欧美一区| 亚洲一区二区五区| 久久婷婷一区二区三区| jlzzjlzz国产精品久久| 亚洲成人av电影| www日韩大片| 91久久免费观看| 久久精品国内一区二区三区| 国产精品视频线看| 欧美人与禽zozo性伦| 国产精品一线二线三线精华| 亚洲黄网站在线观看| 精品对白一区国产伦| 色综合久久综合中文综合网| 男女男精品视频网| 成人欧美一区二区三区白人| 制服视频三区第一页精品| 成人黄页在线观看| 蜜桃一区二区三区四区| 亚洲久草在线视频| 久久伊99综合婷婷久久伊| 91成人在线精品| 国产激情一区二区三区四区 | 精品午夜一区二区三区在线观看| 18欧美乱大交hd1984| 精品动漫一区二区三区在线观看 | 久久久久久久久蜜桃| 欧美性受极品xxxx喷水| 国产尤物一区二区| 奇米一区二区三区av| 亚洲黄色小说网站| 国产精品美女一区二区三区 | 99国产一区二区三精品乱码| 久久国产尿小便嘘嘘|