Classes | Files | Defines

Exceptions

Tools and Utilities

Detailed Description

This group contains the exceptions defined in LEMON.

Classes

class  Exception
 Generic exception class. More...
class  IoError
 Input-Output error. More...
class  FormatError
 Format error. More...

Files

file  assert.h
 

Extended assertion handling.


file  error.h
 

Basic exception classes and error handling.


Defines

#define LEMON_ASSERT(exp, msg)
 Macro for assertion with customizable message.
#define LEMON_DEBUG(exp, msg)
 Macro for internal assertions.

Define Documentation

#define LEMON_ASSERT (   exp,
  msg 
)
Value:
(static_cast<void> (!!(exp) ? 0 : (                                   \
    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
                         LEMON_FUNCTION_NAME,                           \
                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))

Macro for assertion with customizable message.

Parameters:
expAn expression that must be convertible to bool. If it is false, then an assertion is raised. The concrete behaviour depends on the settings of the assertion system.
msgA const char* parameter, which can be used to provide information about the circumstances of the failed assertion.

The assertions are enabled in the default behaviour. You can disable them with the following code:

 #define LEMON_DISABLE_ASSERTS

or with compilation parameters:

 g++ -DLEMON_DISABLE_ASSERTS
 make CXXFLAGS='-DLEMON_DISABLE_ASSERTS'

The checking is also disabled when the standard macro NDEBUG is defined.

As a default behaviour the failed assertion prints a short log message to the standard error and aborts the execution.

However, the following modes can be used in the assertion system:

  • LEMON_ASSERT_ABORT The failed assertion prints a short log message to the standard error and aborts the program. It is the default behaviour.
  • LEMON_ASSERT_CUSTOM The user can define own assertion handler function.
         void custom_assert_handler(const char* file, int line,
                                    const char* function, const char* message,
                                    const char* assertion);
    
    The name of the function should be defined as the LEMON_CUSTOM_ASSERT_HANDLER macro name.
         #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler
    
    Whenever an assertion is occured, the custom assertion handler is called with appropiate parameters.

The assertion mode can also be changed within one compilation unit. If the macros are redefined with other settings and the assert.h file is reincluded, then the behaviour is changed appropiately to the new settings.

#define LEMON_DEBUG (   exp,
  msg 
)
Value:
(static_cast<void> (!!(exp) ? 0 : (                                   \
    LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
                         LEMON_FUNCTION_NAME,                           \
                         ::lemon::_assert_bits::cstringify(msg), #exp), 0)))

Macro for internal assertions, it is used in the library to check the consistency of results of algorithms, several pre- and postconditions and invariants. The checking is disabled by default, but it can be turned on with the macro LEMON_ENABLE_DEBUG.

 #define LEMON_ENABLE_DEBUG

or with compilation parameters:

 g++ -DLEMON_ENABLE_DEBUG
 make CXXFLAGS='-DLEMON_ENABLE_DEBUG'

This macro works like the LEMON_ASSERT macro, therefore the current behaviour depends on the settings of LEMON_ASSERT macro.

See also:
LEMON_ASSERT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines