COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon-main for lemon/assert.h


Ignore:
Timestamp:
07/13/08 20:51:02 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/assert.h

    r142 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    2929
    3030  inline void assert_fail_log(const char *file, int line, const char *function,
    31                               const char *message, const char *assertion)
     31                              const char *message, const char *assertion)
    3232  {
    3333    std::cerr << file << ":" << line << ": ";
     
    4141
    4242  inline void assert_fail_abort(const char *file, int line,
    43                                 const char *function, const char* message,
    44                                 const char *assertion)
     43                                const char *function, const char* message,
     44                                const char *assertion)
    4545  {
    4646    assert_fail_log(file, line, function, message, assertion);
     
    4949
    5050  namespace _assert_bits {
    51    
    52    
     51
     52
    5353    inline const char* cstringify(const std::string& str) {
    5454      return str.c_str();
     
    5757    inline const char* cstringify(const char* str) {
    5858      return str;
    59     }   
     59    }
    6060  }
    6161}
     
    6767#undef LEMON_DEBUG
    6868
    69 #if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
    70   (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
     69#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
     70  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
    7171  (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    7272#error "LEMON assertion system is not set properly"
    7373#endif
    7474
    75 #if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
    76      (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    77      (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    78      defined(LEMON_ENABLE_ASSERTS)) &&                  \
    79   (defined(LEMON_DISABLE_ASSERTS) ||                    \
     75#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
     76     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
     77     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||        \
     78     defined(LEMON_ENABLE_ASSERTS)) &&                        \
     79  (defined(LEMON_DISABLE_ASSERTS) ||                        \
    8080   defined(NDEBUG))
    8181#error "LEMON assertion system is not set properly"
     
    137137/// \endcode
    138138/// The checking is also disabled when the standard macro \c NDEBUG is defined.
    139 /// 
     139///
    140140/// The LEMON assertion system has a wide range of customization
    141141/// properties. As a default behaviour the failed assertion prints a
    142142/// short log message to the standard error and aborts the execution.
    143143///
    144 /// The following modes can be used in the assertion system: 
     144/// The following modes can be used in the assertion system:
    145145///
    146146/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
     
    156156///   \endcode
    157157///   The name of the function should be defined as the \c
    158 ///   LEMON_CUSTOM_ASSERT_HANDLER macro name. 
     158///   LEMON_CUSTOM_ASSERT_HANDLER macro name.
    159159///   \code
    160160///     #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler
     
    167167/// \ref lemon/assert.h "assert.h" file is reincluded, then the
    168168/// behaviour is changed appropiately to the new settings.
    169 #  define LEMON_ASSERT(exp, msg)                                        \
    170   (static_cast<void> (!!(exp) ? 0 : (                                   \
    171     LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
    172                          LEMON_FUNCTION_NAME,                           \
    173                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
     169#  define LEMON_ASSERT(exp, msg)                                        \
     170  (static_cast<void> (!!(exp) ? 0 : (                                        \
     171    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                                \
     172                         LEMON_FUNCTION_NAME,                                \
     173                        ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
    174174
    175175/// \ingroup exceptions
     
    183183/// \endcode
    184184///
    185 /// \see LEMON_ASSERT 
    186 #  define LEMON_FIXME(msg)                                              \
    187   (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
    188                         ::lemon::_assert_bits::cstringify(msg),         \
    189                         static_cast<const char*>(0)))
     185/// \see LEMON_ASSERT
     186#  define LEMON_FIXME(msg)                                                \
     187  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
     188                        ::lemon::_assert_bits::cstringify(msg),                \
     189                        static_cast<const char*>(0)))
    190190
    191191/// \ingroup exceptions
     
    211211/// macro.
    212212///
    213 /// \see LEMON_ASSERT 
    214 #  define LEMON_DEBUG(exp, msg)                                         \
    215   (static_cast<void> (!!(exp) ? 0 : (                                   \
     213/// \see LEMON_ASSERT
     214#  define LEMON_DEBUG(exp, msg)                                                \
     215  (static_cast<void> (!!(exp) ? 0 : (                                        \
    216216    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
    217                          LEMON_FUNCTION_NAME,                           \
    218                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
     217                         LEMON_FUNCTION_NAME,                                \
     218                        ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
    219219
    220220#else
     
    225225#    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
    226226#  else
    227 #    define LEMON_ASSERT(exp, msg)                                      \
    228        (static_cast<void> (!!(exp) ? 0 : (                              \
     227#    define LEMON_ASSERT(exp, msg)                                        \
     228       (static_cast<void> (!!(exp) ? 0 : (                                \
    229229        LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                        \
    230                              LEMON_FUNCTION_NAME,                       \
    231                              ::lemon::_assert_bits::cstringify(msg),    \
    232                              #exp), 0)))
    233 #    define LEMON_FIXME(msg)                                            \
    234        (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
    235                              ::lemon::_assert_bits::cstringify(msg),    \
    236                              static_cast<const char*>(0)))
     230                             LEMON_FUNCTION_NAME,                        \
     231                             ::lemon::_assert_bits::cstringify(msg),        \
     232                             #exp), 0)))
     233#    define LEMON_FIXME(msg)                                                \
     234       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
     235                             ::lemon::_assert_bits::cstringify(msg),        \
     236                             static_cast<const char*>(0)))
    237237
    238238#    if LEMON_ENABLE_DEBUG
     
    241241           LEMON_ASSERT_HANDLER(__FILE__, __LINE__,  \
    242242                                LEMON_FUNCTION_NAME, \
    243                                 ::lemon::_assert_bits::cstringify(msg), \
    244                                 #exp), 0)))
     243                                ::lemon::_assert_bits::cstringify(msg),        \
     244                                #exp), 0)))
    245245#    else
    246246#      define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
Note: See TracChangeset for help on using the changeset viewer.