Navit SVN

/work/compile/navit/src/navit/support/glib/gerror.h

00001 /* gerror.h - Error reporting system
00002  *
00003  *  Copyright 2000 Red Hat, Inc.
00004  *
00005  * The Gnome Library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * The Gnome Library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
00017  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  *   Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
00022 #error "Only <glib.h> can be included directly."
00023 #endif
00024 
00025 #ifndef __G_ERROR_H__
00026 #define __G_ERROR_H__
00027 
00028 #include <glib/gquark.h>
00029 
00030 G_BEGIN_DECLS
00031 
00032 typedef struct _GError GError;
00033 
00034 struct _GError
00035 {
00036   GQuark       domain;
00037   gint         code;
00038   gchar       *message;
00039 };
00040 
00041 GError*  g_error_new           (GQuark         domain,
00042                                 gint           code,
00043                                 const gchar   *format,
00044                                 ...) G_GNUC_PRINTF (3, 4);
00045 
00046 GError*  g_error_new_literal   (GQuark         domain,
00047                                 gint           code,
00048                                 const gchar   *message);
00049 
00050 void     g_error_free          (GError        *error);
00051 GError*  g_error_copy          (const GError  *error);
00052 
00053 gboolean g_error_matches       (const GError  *error,
00054                                 GQuark         domain,
00055                                 gint           code);
00056 
00057 /* if (err) *err = g_error_new(domain, code, format, ...), also has
00058  * some sanity checks.
00059  */
00060 void     g_set_error           (GError       **err,
00061                                 GQuark         domain,
00062                                 gint           code,
00063                                 const gchar   *format,
00064                                 ...) G_GNUC_PRINTF (4, 5);
00065 
00066 void     g_set_error_literal   (GError       **err,
00067                                 GQuark         domain,
00068                                 gint           code,
00069                                 const gchar   *message);
00070 
00071 /* if (dest) *dest = src; also has some sanity checks.
00072  */
00073 void     g_propagate_error     (GError       **dest,
00074                                 GError        *src);
00075 
00076 /* if (err && *err) { g_error_free(*err); *err = NULL; } */
00077 void     g_clear_error         (GError       **err);
00078 
00079 /* if (err) prefix the formatted string to the ->message */
00080 void     g_prefix_error               (GError       **err,
00081                                        const gchar   *format,
00082                                        ...) G_GNUC_PRINTF (2, 3);
00083 
00084 /* g_propagate_error then g_error_prefix on dest */
00085 void     g_propagate_prefixed_error   (GError       **dest,
00086                                        GError        *src,
00087                                        const gchar   *format,
00088                                        ...) G_GNUC_PRINTF (3, 4);
00089 
00090 G_END_DECLS
00091 
00092 #endif /* __G_ERROR_H__ */