gxerror.h

Go to the documentation of this file.
00001 #ifndef __gxerror_h__
00002 #define __gxerror_h__
00003 
00004 #include <glib/gerror.h>
00005 
00006 #include <stdarg.h>
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012   // An allocation failure safe version of g_error_new.
00013   // 
00014   // Returns NULL in there is no memory for allocating a new error
00015   // structure.
00016   // 
00017   // (Note: G_GNUC_PRINTF (3, 4) states that the format index is 3,
00018   // and the argument start index is 4. See glib/gmacros.h for
00019   // details.)
00020   GError* gx_error_new(GQuark         domain,
00021            gint           code,
00022            const gchar   *format,
00023            ...) G_GNUC_PRINTF (3, 4);
00024 
00025   // An allocation failure safe version of g_error_new_literal.
00026   GError* gx_error_new_literal (GQuark         domain,
00027         gint           code,
00028         const gchar   *message);
00029 
00030   // A va_list version of gx_error_new. Note that GLib internally
00031   // defines g_error_new_valist, but does not export it.
00032   GError* gx_error_new_valist(GQuark         domain,
00033             gint           code,
00034             const gchar   *format,
00035             va_list        args);
00036 
00037   // We use the GError API in a non-standard way in that we always accept a NULL ``GError`` pointer and interpret it as an out-of-memory error. This is to avoid trying to allocate a ``GError`` when there is no memory.
00038 #define gx_error_no_memory NULL
00039 
00040 #define gx_error_is(_errorptr, d, c) \
00041   ((_errorptr) && ((_errorptr)->domain == (d)) && ((_errorptr)->code == (c)))
00042 
00043 #ifdef __cplusplus
00044 } /* extern "C" */
00045 #endif
00046 
00047 #endif /* __gxerror_h__ */
00048 
00049 /**
00050 
00051 gxerror.h
00052 
00053 Copyright 2010 Helsinki Institute for Information Technology (HIIT)
00054 and the authors. All rights reserved.
00055 
00056 Authors: Tero Hasu <tero.hasu@hut.fi>
00057 
00058 Permission is hereby granted, free of charge, to any person
00059 obtaining a copy of this software and associated documentation files
00060 (the "Software"), to deal in the Software without restriction,
00061 including without limitation the rights to use, copy, modify, merge,
00062 publish, distribute, sublicense, and/or sell copies of the Software,
00063 and to permit persons to whom the Software is furnished to do so,
00064 subject to the following conditions:
00065 
00066 The above copyright notice and this permission notice shall be
00067 included in all copies or substantial portions of the Software.
00068 
00069 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00070 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00071 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00072 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00073 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00074 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00075 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00076 SOFTWARE.
00077 
00078  **/

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1