|
C/C++ Library, mos@ua 1.0
cpplib-mos
|
Design-by-Contract module for C/C++. More...
Modules | |
| DbC-DEM | |
| The following macros are an approximation to implement a Disciplined Exception Mechanism using only the language preprocessor. | |
Files | |
| file | dbc.h |
| Design-by-Contract module. | |
Data Structures | |
| struct | DbC_Error |
| DbC exceptions throw a pointer to this structure. More... | |
Macros | |
| #define | PRECONDITION_ERROR |
| Integer value for a precondition error code. | |
| #define | POSTCONDITION_ERROR |
| Integer value for a postcondition error code. | |
| #define | INVARIANT_ERROR |
| Integer value for an invariant error code. | |
| #define | CHECK_ERROR |
| Integer value for a check error code. | |
| #define | check(condition, message) |
| Checks the verification of an general algorithm assertion. | |
| #define | require(condition, message) |
| Checks the verification of a precondition. | |
| #define | ensure(condition, message) |
| Checks the verification of a postcondition. | |
| #define | invariant(condition, message) |
| Checks the verification of an invariant. | |
| #define | IS_DbC_ERROR(e) |
| checks if it is a DbC error code | |
| #define | DbC_ERROR_2_STR(e) |
| Converts DbC error code to a string. | |
Design-by-Contract module for C/C++.
This module gives an alternative support for DbC in C++.
When compared with assert.h this module offers the following functionalities:
EXIT_POLICY (default): describes the failed assertion in stderr (with the identification and the precise location of the assertion), generates a segmentation fault (enabling a stack trace within a debugger like gdb), and exits program execution;EXCEPTION_POLICY: throws a DbC_Error* exception with the description of the failed assertion.Debug settings:
assert.h, this module accepts NDEBUG macro definition to disable all assertion run-time verification.NDEBUG_CHECKS, NDEBUG_PRECONDITIONS, NDEBUG_POSTCONDITIONS, and NDEBUG_INVARIANTS.DEBUG_ONLY_PRECONDITIONS ensures that only precondition debugging remains active (regardless of other debug definitions).| #define check | ( | condition, | |
| message | |||
| ) |
Checks the verification of an general algorithm assertion.
This assertion verification can be disabled at compile time by defining the macro NDEBUG_CHECKS.
| [in] | condition | [int] expression to assert its truthness |
| [in] | message | [char*] text to be presented with error information when the assertion fails |
| #define require | ( | condition, | |
| message | |||
| ) |
Checks the verification of a precondition.
This assertion verification can be disabled at compile time by defining the macro NDEBUG_PRECONDITIONS.
| [in] | condition | [int] expression to assert its truthness |
| [in] | message | [char*] text to be presented with error information when the assertion fails |
| #define ensure | ( | condition, | |
| message | |||
| ) |
Checks the verification of a postcondition.
This assertion verification can be disabled at compile time by defining the macro NDEBUG_POSTCONDITIONS.
| [in] | condition | [int] expression to assert its truthness |
| [in] | message | [char*] text to be presented with error information when the assertion fails |
| #define invariant | ( | condition, | |
| message | |||
| ) |
Checks the verification of an invariant.
This assertion verification can be disabled at compile time by defining the macro NDEBUG_INVARIANTS.
| [in] | condition | [int] expression to assert its truthness |
| [in] | message | [char*] text to be presented with error information when the assertion fails |
| #define IS_DbC_ERROR | ( | e | ) |
checks if it is a DbC error code
| [in] | e | [int] integer error value |
| #define DbC_ERROR_2_STR | ( | e | ) |
Converts DbC error code to a string.
| [in] | e | [int] integer error value |