/usr/include/diagnostics/throwing_block_annotation.hpp is in libdiagnostics-dev 0.3.3-12build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /*
* Diagnostics - a unified framework for code annotation, logging,
* program monitoring, and unit-testing.
*
* Copyright (C) 2009 Christian Schallhart <christian@schallhart.net>,
* Michael Tautschnig <tautschnig@forsyte.de>
* 2008 model.in.tum.de group, FORSYTE group
* 2006-2007 model.in.tum.de group
* 2002-2005 Christian Schallhart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file diagnostics/macros/throwing_block_annotation.hpp
*
* $Id: throwing_block_annotation.hpp,v 1.11 2005/06/23 09:54:22 esdentem Exp $
*
* @author Christian Schallhart
*
* @brief [LEVEL: beta] @ref DIAGNOSTICS_BASE_THROWING_BLOCK_ENTER
* and @ref DIAGNOSTICS_BASE_THROWING_BLOCK_EXIT
*
* @test diagnostics/macros/throwing_block_annotation.t.cpp
*/
#ifndef DIAGNOSTICS__MACROS__THROWING_BLOCK_ANNOTATION_INCLUDE_GUARD
#define DIAGNOSTICS__MACROS__THROWING_BLOCK_ANNOTATION_INCLUDE_GUARD
// ::diagnostics::logging_facility::log
#include <diagnostics/frame/logging_facility.hpp>
// DIAGNOSTICS_BASE_CONCAT
#include <diagnostics/util/preprocessor.hpp>
/**
* @brief opens a @ref DIAGNOSTICS_BASE_THROWING_BLOCK_EXIT
*/
#define DIAGNOSTICS_BASE_THROWING_BLOCK_ENTER \
do { bool internal__caught_exception=false; \
try {
#define DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER(EXCEP,PRED,TAIL) \
(::std::string("EXPECTED.NAME=\"" #EXCEP "\" EXPECTED.PREDICATE=\"" #PRED "\" ") + TAIL)
#define DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER1(EXCEP,PRED) \
("EXPECTED.NAME=\"" #EXCEP "\" EXPECTED.PREDICATE=\"" #PRED "\"")
#define DIAGNOSTICS_INTERNAL_THROWING_HANDLE_TE0(LEVEL,NR_WHAT,RETHROW,EXCEP,PRED)
#define DIAGNOSTICS_INTERNAL_THROWING_HANDLE_TE1(LEVEL,NR_WHAT,RETHROW,EXCEP,PRED) \
catch(::diagnostics::unittest::Test_Exception & e) { \
DIAGNOSTICS_BASE_LOG(LEVEL, \
::diagnostics::TYPE_WRONG_EXCEPTION, \
NR_WHAT, \
DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER(EXCEP,PRED,\
(::std::string("NAME=\"") + e.name() + "\" WHAT=\"" + e.what() + "\""))); \
if(RETHROW) throw; else internal__caught_exception=true; \
}
/**
* @brief Closes a block which is expected to throw an exception of
* type @a EXCEP.
*
* If an exception of type @a EXCEP occurs which satisfies @a PRED,
* no log message is generated.
*
* If an exception e of type @a EXCEP occurs which does not satisfy @a
* PRED, then a (@a LEVEL, @ref diagnostics::TYPE_WRONG_EXCEPTION, @a NR_WHAT,
* EXPECTED.NAME="#EXCEP" EXPECTED.PREDICATE="#PRED" @a PRED_STR_WHAT(e)) is logged.
*
* If an exception e of a type not being convertible to @a EXCEP but
* of type @a BASE occurs, a (@a LEVEL, @ref diagnostics::TYPE_WRONG_EXCEPTION, @a NR_WHAT,
* EXPECTED.NAME="#EXCEP" EXPECTED.PREDICATE="#PRED" @a STR_WHAT(e)) message is
* logged.
*
* If an exception e of a type not being convertible to @a EXCEP and
* not convertible to @a BASE occurs, a (@a LEVEL, @ref
* diagnostics::TYPE_WRONG_EXCEPTION, @a NR_WHAT,
* EXPECTED.NAME="#EXCEP" EXPECTED.PREDICATE="#PRED") message is logged.
*
* If an exception e of type @ref
* diagnostics::unittest::Test_Exception is raised and @a
* HANDLE_TE_EXLPLICITLY == 1) then a (@ a LEVEL, @ref
* diagnostics::TYPE_WRONG_EXCEPTION, @a NR_WHAT,
* EXPECTED.NAME="#EXCEP" EXPECTED.PREDICATE="#PRED" NAME="e.name()" WHAT="e.what()"
* message is logged.
*
* In all three of the above cases, if @a RETHROW is true, the
* exception is rethrown, elsewise it is dropped.
*
* If no exception is raised, then (@a LEVEL, @ref
* diagnostics::TYPE_MISSING_EXCEPTION, @a NR_WHAT
* EXPECTED.NAME="#EXCEP" EXPECTED.PREDICATE="#PRED"
* message is logged.
*/
#define DIAGNOSTICS_BASE_THROWING_BLOCK_EXIT(LEVEL,NR_WHAT,EXCEP,PRED,PRED_STR_WHAT,RETHROW,HANDLE_TE_EXLPLICITLY,BASE,STR_WHAT) \
} \
catch(EXCEP & e) { \
if(!(PRED)) { \
DIAGNOSTICS_BASE_LOG((LEVEL), \
::diagnostics::TYPE_WRONG_EXCEPTION, \
(NR_WHAT), \
DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER(EXCEP,PRED,PRED_STR_WHAT(e))); \
if(RETHROW) throw; else internal__caught_exception=true; \
} \
else { \
if(RETHROW) throw; else internal__caught_exception=true; \
} \
} \
DIAGNOSTICS_BASE_CONCAT(DIAGNOSTICS_INTERNAL_THROWING_HANDLE_TE,HANDLE_TE_EXLPLICITLY)((LEVEL),(NR_WHAT),(RETHROW),EXCEP,PRED) \
catch(BASE & e) { \
DIAGNOSTICS_BASE_LOG((LEVEL), \
::diagnostics::TYPE_WRONG_EXCEPTION, \
(NR_WHAT), \
DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER(EXCEP,PRED,STR_WHAT(e))); \
if(RETHROW) throw; else internal__caught_exception=true; \
} \
catch(...) { \
DIAGNOSTICS_BASE_LOG((LEVEL),::diagnostics::TYPE_WRONG_EXCEPTION,(NR_WHAT), \
DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER1(EXCEP,PRED)); \
if(RETHROW) throw; else internal__caught_exception=true; \
} \
if(!internal__caught_exception) { \
DIAGNOSTICS_BASE_LOG((LEVEL),::diagnostics::TYPE_MISSING_EXCEPTION,(NR_WHAT), \
DIAGNOSTICS_INTERNAL_WHAT_STRING_BUILDER1(EXCEP,PRED)); \
} } while(false)
#endif
// vim:ts=4:sw=4
|