Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

pantheios/assert.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        pantheios/assert.h
00003  *
00004  * Purpose:     Pantheios Assertion API.
00005  *
00006  * Created:     8th May 2009
00007  * Updated:     6th November 2010
00008  *
00009  * Thanks to:   markitus82 for requesting this functionality
00010  *
00011  * Home:        http://www.pantheios.org/
00012  *
00013  * Copyright (c) 2009-2010, Matthew Wilson and Synesis Software
00014  * All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are
00018  * met:
00019  *
00020  * - Redistributions of source code must retain the above copyright notice,
00021  *   this list of conditions and the following disclaimer.
00022  * - Redistributions in binary form must reproduce the above copyright
00023  *   notice, this list of conditions and the following disclaimer in the
00024  *   documentation and/or other materials provided with the distribution.
00025  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00026  *   names of any contributors may be used to endorse or promote products
00027  *   derived from this software without specific prior written permission.
00028  *
00029  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00030  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00031  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00032  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00033  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00034  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00035  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00036  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00037  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00038  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00039  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00040  *
00041  * ////////////////////////////////////////////////////////////////////// */
00042 
00043 
00049 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_ASSERT
00050 #define PANTHEIOS_INCL_PANTHEIOS_H_ASSERT
00051 
00052 /* /////////////////////////////////////////////////////////////////////////
00053  * Version information
00054  */
00055 
00056 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00057 # define PANTHEIOS_VER_PANTHEIOS_H_ASSERT_MAJOR     1
00058 # define PANTHEIOS_VER_PANTHEIOS_H_ASSERT_MINOR     1
00059 # define PANTHEIOS_VER_PANTHEIOS_H_ASSERT_REVISION  2
00060 # define PANTHEIOS_VER_PANTHEIOS_H_ASSERT_EDIT      8
00061 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00062 
00063 /* /////////////////////////////////////////////////////////////////////////
00064  * Includes
00065  */
00066 
00067 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
00068 # include <pantheios/pantheios.h>
00069 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
00070 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_FILELINE
00071 # include <pantheios/fileline.h>
00072 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_FILELINE */
00073 
00074 #include <stlsoft/stlsoft.h>
00075 
00076 /* /////////////////////////////////////////////////////////////////////////
00077  * Assertion features
00078  */
00079 
00109 #ifndef PANTHEIOS_ASSERT_SEVERITY_LEVEL
00110 # define PANTHEIOS_ASSERT_SEVERITY_LEVEL    PANTHEIOS_SEV_EMERGENCY
00111 #endif /* !PANTHEIOS_ASSERT_SEVERITY_LEVEL */
00112 
00113 
00128 #define PANTHEIOS_ASSERT(expr)              \
00129                                             \
00130     do                                      \
00131     {                                       \
00132         if(!(expr))                         \
00133         {                                   \
00134             PANTHEIOS_NS_QUAL(pantheios_logassertfail)(PANTHEIOS_ASSERT_SEVERITY_LEVEL, PANTHEIOS_FILELINE_A, "assertion failed: " #expr); \
00135         }                                   \
00136                                             \
00137         STLSOFT_ASSERT(expr);               \
00138     } while(0)
00139 
00140 
00156 #define PANTHEIOS_MESSAGE_ASSERT(expr, msg) \
00157                                             \
00158     do                                      \
00159     {                                       \
00160         if(!(expr))                         \
00161         {                                   \
00162             PANTHEIOS_NS_QUAL(pantheios_logassertfail)(PANTHEIOS_ASSERT_SEVERITY_LEVEL, PANTHEIOS_FILELINE_A, "assertion failed: " #expr "; message: " msg); \
00163         }                                   \
00164                                             \
00165         STLSOFT_MESSAGE_ASSERT(msg, expr);  \
00166     } while(0)
00167 
00168 
00169 /* /////////////////////////////////////////////////////////////////////////
00170  * Inclusion
00171  */
00172 
00173 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00174 # pragma once
00175 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00176 
00177 /* ////////////////////////////////////////////////////////////////////// */
00178 
00179 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_ASSERT */
00180 
00181 /* ///////////////////////////// end of file //////////////////////////// */

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo