lemon/assert.h
changeset 209 765619b7cbb2
parent 142 8b703d177341
child 210 81cfc04531e8
     1.1 --- a/lemon/assert.h	Sun Jul 13 16:46:56 2008 +0100
     1.2 +++ b/lemon/assert.h	Sun Jul 13 19:51:02 2008 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4 -/* -*- C++ -*-
     1.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
     1.6   *
     1.7 - * This file is a part of LEMON, a generic C++ optimization library
     1.8 + * This file is a part of LEMON, a generic C++ optimization library.
     1.9   *
    1.10   * Copyright (C) 2003-2008
    1.11   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.12 @@ -28,7 +28,7 @@
    1.13  namespace lemon {
    1.14  
    1.15    inline void assert_fail_log(const char *file, int line, const char *function,
    1.16 -			      const char *message, const char *assertion)
    1.17 +                              const char *message, const char *assertion)
    1.18    {
    1.19      std::cerr << file << ":" << line << ": ";
    1.20      if (function)
    1.21 @@ -40,23 +40,23 @@
    1.22    }
    1.23  
    1.24    inline void assert_fail_abort(const char *file, int line,
    1.25 -				const char *function, const char* message,
    1.26 -				const char *assertion)
    1.27 +                                const char *function, const char* message,
    1.28 +                                const char *assertion)
    1.29    {
    1.30      assert_fail_log(file, line, function, message, assertion);
    1.31      std::abort();
    1.32    }
    1.33  
    1.34    namespace _assert_bits {
    1.35 -    
    1.36 -    
    1.37 +
    1.38 +
    1.39      inline const char* cstringify(const std::string& str) {
    1.40        return str.c_str();
    1.41      }
    1.42  
    1.43      inline const char* cstringify(const char* str) {
    1.44        return str;
    1.45 -    }    
    1.46 +    }
    1.47    }
    1.48  }
    1.49  
    1.50 @@ -66,17 +66,17 @@
    1.51  #undef LEMON_FIXME
    1.52  #undef LEMON_DEBUG
    1.53  
    1.54 -#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +		\
    1.55 -  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +		\
    1.56 +#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
    1.57 +  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
    1.58    (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    1.59  #error "LEMON assertion system is not set properly"
    1.60  #endif
    1.61  
    1.62 -#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +		\
    1.63 -     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +		\
    1.64 -     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||	\
    1.65 -     defined(LEMON_ENABLE_ASSERTS)) &&			\
    1.66 -  (defined(LEMON_DISABLE_ASSERTS) ||			\
    1.67 +#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
    1.68 +     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
    1.69 +     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||        \
    1.70 +     defined(LEMON_ENABLE_ASSERTS)) &&                        \
    1.71 +  (defined(LEMON_DISABLE_ASSERTS) ||                        \
    1.72     defined(NDEBUG))
    1.73  #error "LEMON assertion system is not set properly"
    1.74  #endif
    1.75 @@ -136,12 +136,12 @@
    1.76  /// make CXXFLAGS='-DLEMON_DISABLE_ASSERTS'
    1.77  /// \endcode
    1.78  /// The checking is also disabled when the standard macro \c NDEBUG is defined.
    1.79 -/// 
    1.80 +///
    1.81  /// The LEMON assertion system has a wide range of customization
    1.82  /// properties. As a default behaviour the failed assertion prints a
    1.83  /// short log message to the standard error and aborts the execution.
    1.84  ///
    1.85 -/// The following modes can be used in the assertion system: 
    1.86 +/// The following modes can be used in the assertion system:
    1.87  ///
    1.88  /// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
    1.89  ///   message to the standard error and continues the execution.
    1.90 @@ -155,7 +155,7 @@
    1.91  ///                                const char* message, const char* assertion);
    1.92  ///   \endcode
    1.93  ///   The name of the function should be defined as the \c
    1.94 -///   LEMON_CUSTOM_ASSERT_HANDLER macro name. 
    1.95 +///   LEMON_CUSTOM_ASSERT_HANDLER macro name.
    1.96  ///   \code
    1.97  ///     #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler
    1.98  ///   \endcode
    1.99 @@ -166,11 +166,11 @@
   1.100  /// If the macros are redefined with other settings and the
   1.101  /// \ref lemon/assert.h "assert.h" file is reincluded, then the
   1.102  /// behaviour is changed appropiately to the new settings.
   1.103 -#  define LEMON_ASSERT(exp, msg)					\
   1.104 -  (static_cast<void> (!!(exp) ? 0 : (					\
   1.105 -    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,				\
   1.106 -			 LEMON_FUNCTION_NAME,				\
   1.107 -			 ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   1.108 +#  define LEMON_ASSERT(exp, msg)                                        \
   1.109 +  (static_cast<void> (!!(exp) ? 0 : (                                        \
   1.110 +    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                                \
   1.111 +                         LEMON_FUNCTION_NAME,                                \
   1.112 +                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   1.113  
   1.114  /// \ingroup exceptions
   1.115  ///
   1.116 @@ -182,11 +182,11 @@
   1.117  ///   LEMON_ASSERT(false, msg);
   1.118  /// \endcode
   1.119  ///
   1.120 -/// \see LEMON_ASSERT 
   1.121 -#  define LEMON_FIXME(msg)						\
   1.122 -  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,	\
   1.123 -			::lemon::_assert_bits::cstringify(msg),		\
   1.124 -			static_cast<const char*>(0)))
   1.125 +/// \see LEMON_ASSERT
   1.126 +#  define LEMON_FIXME(msg)                                                \
   1.127 +  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   1.128 +                        ::lemon::_assert_bits::cstringify(msg),                \
   1.129 +                        static_cast<const char*>(0)))
   1.130  
   1.131  /// \ingroup exceptions
   1.132  ///
   1.133 @@ -210,12 +210,12 @@
   1.134  /// current behaviour depends on the settings of \c LEMON_ASSERT
   1.135  /// macro.
   1.136  ///
   1.137 -/// \see LEMON_ASSERT 
   1.138 -#  define LEMON_DEBUG(exp, msg)						\
   1.139 -  (static_cast<void> (!!(exp) ? 0 : (					\
   1.140 +/// \see LEMON_ASSERT
   1.141 +#  define LEMON_DEBUG(exp, msg)                                                \
   1.142 +  (static_cast<void> (!!(exp) ? 0 : (                                        \
   1.143      LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
   1.144 -			 LEMON_FUNCTION_NAME,				\
   1.145 -			 ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   1.146 +                         LEMON_FUNCTION_NAME,                                \
   1.147 +                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   1.148  
   1.149  #else
   1.150  
   1.151 @@ -224,24 +224,24 @@
   1.152  #    define LEMON_FIXME(msg) (static_cast<void>(0))
   1.153  #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   1.154  #  else
   1.155 -#    define LEMON_ASSERT(exp, msg)					\
   1.156 -       (static_cast<void> (!!(exp) ? 0 : (				\
   1.157 +#    define LEMON_ASSERT(exp, msg)                                        \
   1.158 +       (static_cast<void> (!!(exp) ? 0 : (                                \
   1.159          LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                        \
   1.160 -			     LEMON_FUNCTION_NAME,			\
   1.161 -			     ::lemon::_assert_bits::cstringify(msg),	\
   1.162 -			     #exp), 0)))
   1.163 -#    define LEMON_FIXME(msg)						\
   1.164 -       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,	\
   1.165 -			     ::lemon::_assert_bits::cstringify(msg),	\
   1.166 -			     static_cast<const char*>(0)))
   1.167 +                             LEMON_FUNCTION_NAME,                        \
   1.168 +                             ::lemon::_assert_bits::cstringify(msg),        \
   1.169 +                             #exp), 0)))
   1.170 +#    define LEMON_FIXME(msg)                                                \
   1.171 +       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   1.172 +                             ::lemon::_assert_bits::cstringify(msg),        \
   1.173 +                             static_cast<const char*>(0)))
   1.174  
   1.175  #    if LEMON_ENABLE_DEBUG
   1.176  #      define LEMON_DEBUG(exp, msg)
   1.177           (static_cast<void> (!!(exp) ? 0 : (         \
   1.178             LEMON_ASSERT_HANDLER(__FILE__, __LINE__,  \
   1.179                                  LEMON_FUNCTION_NAME, \
   1.180 -				::lemon::_assert_bits::cstringify(msg),	\
   1.181 -				#exp), 0)))
   1.182 +                                ::lemon::_assert_bits::cstringify(msg),        \
   1.183 +                                #exp), 0)))
   1.184  #    else
   1.185  #      define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   1.186  #    endif