1.6 Further Topics


1.6 Further Topics

GLib has many capabilities that aren't covered here because there just isn't enough space. These include the following:

  • Date and time functions: Would you like to know how many days elapsed between the end of the Thirty Year War and your grandmother's birthday? GLib makes quick work of this type of problem with its conversion utilities.

  • Message logging: Behind g_message() , g_error() , and their friends are several macros that send a log domain and log level along with the usual parameters to the g_log() function. You can define new log domains and log levels, and with g_log_set_handler() , what to do when a message comes through.

  • Quicksort: g_qsort_with_data() is like C's qsort () function, but accommodates an additional data parameter.

  • Singly linked lists: GSList saves a few bytes per node if you don't need to be able to navigate backward in the list.

  • Pointer arrays: If you just want an array of gpointer elements that can grow automatically like GArray , GPtrArray offers a simpler API without all of the element size parameters.

  • Byte arrays: GByteArray arrays are identical to pointer arrays, but with guint8-size elements.

  • String chunks : For efficient allocation and cleanup of a large number of C strings (not GString strings), GStringChunk is available with an API like those of memory chunks.

  • N-ary trees: If you want trees where a node can have more than two children, GLib enables you to build them yourself with the GNode data type.

  • Queues: The popular first in, first out (FIFO) approach is available with GQueue . There are additional routines for double-ended queues.

  • Shell and file utilities: GLib has a number of facilities for working with files, pipes, and processes.

  • Threads: GLib offers portable implementations of threads, thread pools, and interprocess communication (mutual exclusion, async queues, and so on).

  • Dynamic module loader: GModule is a system for loading shared objects into running processes. If you want your program to support plug-ins, take a look at this.

As you can see, GLib is a powerful tool that can't be completely documented in a book like this. However, an experienced programmer can easily get a good sense of how to use everything else by rooting around in the extensive API reference documentation that comes with GLib.




The Official GNOME 2 Developers Guide
The Official GNOME 2 Developers Guide
ISBN: 1593270305
EAN: 2147483647
Year: 2004
Pages: 108

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net