ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Classes | Namespaces | Functions
tools.hpp File Reference
#include <assert.h>
#include <typeinfo>
Include dependency graph for tools.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  DbgTypeDemangler
 

Namespaces

 aworx
 
 aworx::lib
 

Macros

C/C++ Preprocessor Helper Macros

The following macros are fundamental and building blocks for other macros.

#define ALIB_COMMA   ,
 
#define ALIB_COMMA_DBG   ,
 
#define ALIB_CONCAT(a, b)   a ## b
 
#define ALIB_EMPTY
 
#define ALIB_IDENTIFIER(prefix)
 
#define ALIB_NSTRINGIFY(a)
 
#define ALIB_STATIC_ASSERT(CondVariable, Cond, Message)
 
#define ALIB_STATIC_DENY(CondVariable, Cond, Message)
 
#define ALIB_STRINGIFY(a)
 
C/C++ Language And Linkage Macros

The macros listed here are supporting C++ compilation and linking control and language specific utilities.

#define ALIB_CALLER   __FILE__, __LINE__, __func__
 
#define ALIB_CALLER_NULLED   ALIB_CALLER
 
#define ALIB_CALLER_PRUNED   ALIB_CALLER
 
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 *topic, const char *msg, const int intValue)
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *topic, const char *msg1=nullptr, const char *msg2=nullptr, const char *msg3=nullptr, const char *msg4=nullptr, const char *msg5=nullptr)
 

Detailed Description


This header file is part of the ALib C++ Library. It does neither belong to a fileset, nor to a specific module of ALib, but is included in any ALib Distribution.

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

Note
To reduce complexity, this header is not shown in inclusion graphs of this documentation.

Definition in file tools.hpp.