kleopatra
Go to the documentation of this file.
33 #ifndef __KLEOPATRA_UTILS_KLEO_ASSERT_H__
34 #define __KLEOPATRA_UTILS_KLEO_ASSERT_H__
36 #include <kleo/exception.h>
38 #include <boost/preprocessor/stringize.hpp>
42 #define kleo_assert_fail_impl( cond, file, line ) \
43 throw Kleo::Exception( gpg_error( GPG_ERR_INTERNAL ), \
44 "assertion \"" #cond "\" failed at " file ":" BOOST_PP_STRINGIZE( line ) )
45 #define kleo_assert_fail_impl_func( cond, file, line, func ) \
46 throw Kleo::Exception( gpg_error( GPG_ERR_INTERNAL ), \
47 std::string( "assertion \"" #cond "\" failed in " ) + func + " (" file ":" BOOST_PP_STRINGIZE( line ) ")" )
49 #define kleo_assert_impl( cond, file, line ) \
51 else kleo_assert_fail_impl( cond, file, line )
52 #define kleo_assert_impl_func( cond, file, line, func ) \
54 else kleo_assert_fail_impl_func( cond, file, line, func )
63 #if defined (__GNUC_PREREQ)
64 # define KLEO_GNUC_PREREQ __GNUC_PREREQ
65 #elif defined (__MINGW_GNUC_PREREQ)
66 # define KLEO_GNUC_PREREQ __MINGW_GNUC_PREREQ
68 # define KLEO_GNUC_PREREQ(maj, min) 0
71 #if KLEO_GNUC_PREREQ(2, 6)
72 # define kleo_assert( cond ) kleo_assert_impl_func( cond, __FILE__, __LINE__, __PRETTY_FUNCTION__ )
73 # define kleo_assert_fail( cond ) kleo_assert_fail_impl_func( cond, __FILE__, __LINE__, __PRETTY_FUNCTION__ )
74 # define notImplemented() throw Exception( gpg_error( GPG_ERR_NOT_IMPLEMENTED ), __PRETTY_FUNCTION__ )
75 #elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
76 # define kleo_assert( cond ) kleo_assert_impl_func( cond, __FILE__, __LINE__, __func__ )
77 # define kleo_assert_fail( cond ) kleo_assert_fail_impl_func( cond, __FILE__, __LINE__, __func__ )
78 # define notImplemented() throw Exception( gpg_error( GPG_ERR_NOT_IMPLEMENTED ), __func__ )
81 #undef KLEO_GNUC_PREREQ
84 # define kleo_assert( cond ) kleo_assert_impl( cond, __FILE__, __LINE__ )
87 #ifndef kleo_assert_fail
88 # define kleo_assert_fail( cond ) kleo_assert_fail_impl( cond, __FILE__, __LINE__ )
91 #ifndef notImplemented
92 # define notImplemented() kleo_assert( !"Sorry, not yet implemented" )
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:41 by
doxygen 1.8.7 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.