/usr/include/CGAL/assertions_impl.h is in libcgal-dev 4.11-2build1.
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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | // Copyright (c) 1997
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); 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 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Geert-Jan Giezeman and Sven Schönherr
#ifdef CGAL_HEADER_ONLY
#define CGAL_INLINE_FUNCTION inline
#else
#define CGAL_INLINE_FUNCTION
#endif
#include <CGAL/config.h>
#include <CGAL/assertions.h>
#include <CGAL/assertions_behaviour.h>
#include <CGAL/exceptions.h>
#include <cstdlib>
#include <iostream>
namespace CGAL {
namespace {
#ifdef CGAL_HEADER_ONLY
inline Failure_behaviour& get_static_error_behaviour()
{
static Failure_behaviour _error_behaviour = THROW_EXCEPTION;
return _error_behaviour;
}
inline Failure_behaviour& get_static_warning_behaviour()
{
static Failure_behaviour _warning_behaviour = CONTINUE;
return _warning_behaviour;
}
#else // CGAL_HEADER_ONLY
// behaviour variables
// -------------------
Failure_behaviour _error_behaviour = THROW_EXCEPTION;
Failure_behaviour _warning_behaviour = CONTINUE;
inline Failure_behaviour& get_static_error_behaviour()
{ return _error_behaviour; }
inline Failure_behaviour& get_static_warning_behaviour()
{ return _warning_behaviour; }
#endif // CGAL_HEADER_ONLY
// standard error handlers
// -----------------------
CGAL_INLINE_FUNCTION
void
_standard_error_handler(
const char* what,
const char* expr,
const char* file,
int line,
const char* msg )
{
#if defined(__GNUG__) && !defined(__llvm__)
// After g++ 3.4, std::terminate defaults to printing to std::cerr itself.
if (get_static_error_behaviour() == THROW_EXCEPTION)
return;
#endif
std::cerr << "CGAL error: " << what << " violation!" << std::endl
<< "Expression : " << expr << std::endl
<< "File : " << file << std::endl
<< "Line : " << line << std::endl
<< "Explanation: " << msg << std::endl
<< "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html"
<< std::endl;
}
// standard warning handler
// ------------------------
CGAL_INLINE_FUNCTION
void
_standard_warning_handler( const char *,
const char* expr,
const char* file,
int line,
const char* msg )
{
#if defined(__GNUG__) && !defined(__llvm__)
// After g++ 3.4, std::terminate defaults to printing to std::cerr itself.
if (get_static_warning_behaviour() == THROW_EXCEPTION)
return;
#endif
std::cerr << "CGAL warning: check violation!" << std::endl
<< "Expression : " << expr << std::endl
<< "File : " << file << std::endl
<< "Line : " << line << std::endl
<< "Explanation: " << msg << std::endl
<< "Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html"
<< std::endl;
}
#ifdef CGAL_HEADER_ONLY
inline Failure_function& get_static_error_handler()
{
static Failure_function _error_handler = _standard_error_handler;
return _error_handler;
}
inline Failure_function& get_static_warning_handler()
{
static Failure_function _warning_handler = _standard_warning_handler;
return _warning_handler;
}
#else // CGAL_HEADER_ONLY
// default handler settings
// ------------------------
Failure_function _error_handler = _standard_error_handler;
Failure_function _warning_handler = _standard_warning_handler;
inline Failure_function& get_static_error_handler()
{ return _error_handler; }
inline Failure_function& get_static_warning_handler()
{ return _warning_handler; }
#endif // CGAL_HEADER_ONLY
} // anonymous namespace
// failure functions
// -----------------
CGAL_INLINE_FUNCTION
void
assertion_fail( const char* expr,
const char* file,
int line,
const char* msg)
{
get_static_error_handler()("assertion", expr, file, line, msg);
switch (get_static_error_behaviour()) {
case ABORT:
std::abort();
case EXIT:
std::exit(1); // EXIT_FAILURE
case EXIT_WITH_SUCCESS:
std::exit(0); // EXIT_SUCCESS
case CONTINUE: // The CONTINUE case should not be used anymore.
case THROW_EXCEPTION:
default:
throw Assertion_exception("CGAL", expr, file, line, msg);
}
}
CGAL_INLINE_FUNCTION
void
precondition_fail( const char* expr,
const char* file,
int line,
const char* msg)
{
get_static_error_handler()("precondition", expr, file, line, msg);
switch (get_static_error_behaviour()) {
case ABORT:
std::abort();
case EXIT:
std::exit(1); // EXIT_FAILURE
case EXIT_WITH_SUCCESS:
std::exit(0); // EXIT_SUCCESS
case CONTINUE:
case THROW_EXCEPTION:
default:
throw Precondition_exception("CGAL", expr, file, line, msg);
}
}
CGAL_INLINE_FUNCTION
void
postcondition_fail(const char* expr,
const char* file,
int line,
const char* msg)
{
get_static_error_handler()("postcondition", expr, file, line, msg);
switch (get_static_error_behaviour()) {
case ABORT:
std::abort();
case EXIT:
std::exit(1); // EXIT_FAILURE
case EXIT_WITH_SUCCESS:
std::exit(0); // EXIT_SUCCESS
case CONTINUE:
case THROW_EXCEPTION:
default:
throw Postcondition_exception("CGAL", expr, file, line, msg);
}
}
// warning function
// ----------------
CGAL_INLINE_FUNCTION
void
warning_fail( const char* expr,
const char* file,
int line,
const char* msg)
{
get_static_warning_handler()("warning", expr, file, line, msg);
switch (get_static_warning_behaviour()) {
case ABORT:
std::abort();
case EXIT:
std::exit(1); // EXIT_FAILURE
case EXIT_WITH_SUCCESS:
std::exit(0); // EXIT_SUCCESS
case THROW_EXCEPTION:
throw Warning_exception("CGAL", expr, file, line, msg);
case CONTINUE:
;
}
}
// error handler set functions
// ---------------------------
CGAL_INLINE_FUNCTION
Failure_function
set_error_handler( Failure_function handler)
{
Failure_function result = get_static_error_handler();
get_static_error_handler() = handler;
return result;
}
CGAL_INLINE_FUNCTION
Failure_function
set_warning_handler( Failure_function handler)
{
Failure_function result = get_static_warning_handler();
get_static_warning_handler() = handler;
return result;
}
CGAL_INLINE_FUNCTION
Failure_behaviour
set_error_behaviour(Failure_behaviour eb)
{
Failure_behaviour result = get_static_error_behaviour();
get_static_error_behaviour() = eb;
return result;
}
CGAL_INLINE_FUNCTION
Failure_behaviour
set_warning_behaviour(Failure_behaviour eb)
{
Failure_behaviour result = get_static_warning_behaviour();
get_static_warning_behaviour() = eb;
return result;
}
} //namespace CGAL
|