ALib C++ Library
Library Version: 1912 R0
Documentation generated by doxygen
Namespaces | Functions
assert.hpp File Reference
#include "alib/lib/fs_integers/integers.hpp"
#include "alib/lib/fs_debug/assert.hpp"
#include <assert.h>
Include dependency graph for assert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 aworx
 
 aworx::lib
 

Macros

Debug Assertions, Warnings and Errors

The macros listed here are defined in two different versions, depending on the ALib distribution. With single ALib Modules that do not incorporate class aworx::lib::results::Report and family, namespace function aworx::lib::DbgSimpleALibMsg (and overloads) are used to write the messages. The default implementation of this message invokes assert(false) if the message is of error type.
There is a very simple "plug-in" concept in place that allows to redirect this method to a user defined one which may act differently.

If class report is included in the selected ALib distribution, two things happen:

  • the aforementioned plug-in is implemented and an ALib Report is generated inside the plug-in function.
  • The macros themselves are redefined to directly use the ALib Report facility. Such redefinition happens "in the middle" of header inclusion (as early as possible), with the effect that most classes of ALib are compiled using the simple version, but still use the mechanics of ALib Reports. Other parts of ALib classes, and of-course all user code, will have the more sophisticated, report-based versions of the macros in place. The huge advantage of them is, that those accept an arbitrary list of arguments which are boxed and passed to a formatter. This allows to easily compose detailed and formatted debug messages.

If also module ALox is compiled into the library, then a plug-in that uses ALox for the message output is used. See class ALoxReportWriter for more information.

#define ALIB_ASSERT(cond)   { if(!(cond)) ALIB_ERROR( "Assertion Failed" ); }
 
#define ALIB_ASSERT_ERROR(cond, ...)   { if(!(cond)) ALIB_ERROR( __VA_ARGS__ ); }
 
#define ALIB_ASSERT_MESSAGE(cond, ...)   { if(!(cond)) ALIB_MESSAGE( __VA_ARGS__ ); }
 
#define ALIB_ASSERT_RESULT_EQUALS( func, value)   { auto result= func; assert(result == value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_GREATER_THAN(func, value)   { auto result= func; assert(result > value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_LESS_THAN( func, value)   { auto result= func; assert(result < value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_NOT_EQUALS( func, value)   { auto result= func; assert(result != value); ((void) result); }
 
#define ALIB_ASSERT_WARNING(cond, ...)   { if(!(cond)) ALIB_WARNING( __VA_ARGS__ ); }
 
#define ALIB_ERROR(...)   { aworx::lib::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 0, __VA_ARGS__); }
 
#define ALIB_MESSAGE(...)   { aworx::lib::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 2, __VA_ARGS__); }
 
#define ALIB_WARNING(...)   { aworx::lib::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 1, __VA_ARGS__); }
 

Functions

ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *msg, const integer intValue)
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *msg1, const char *msg2=nullptr, const char *msg3=nullptr, const char *msg4=nullptr, const char *msg5=nullptr)
 

Detailed Description


This header file is part of file set Debug of the ALib C++ Library.

© 2013-2019 A-Worx GmbH, Germany. Published under Boost Software License.

Definition in file assert.hpp.