Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

Pantheios Assertion API


Detailed Description

Pantheios Assertion API.

This API allows you to combine traditional assert()-based programming with diagnostic logging, using the PANTHEIOS_ASSERT() macro.

  int main()
  {
    PANTHEIOS_ASSERT(false); // Will assert, and will log

    return 0;
  }


Defines

#define PANTHEIOS_ASSERT_SEVERITY_LEVEL   PANTHEIOS_SEV_EMERGENCY
 The level at which log statements will be submitted by PANTHEIOS_ASSERT and PANTHEIOS_MESSAGE_ASSERT.
#define PANTHEIOS_ASSERT(expr)
 Defines an assertion construct for runtime verification.
#define PANTHEIOS_MESSAGE_ASSERT(expr, msg)
 Defines an assertion construct for runtime verification.


Define Documentation

#define PANTHEIOS_ASSERT ( expr   ) 

Value:

\
    do                                      \
    {                                       \
        if(!(expr))                         \
        {                                   \
            PANTHEIOS_NS_QUAL(pantheios_logassertfail)(PANTHEIOS_ASSERT_SEVERITY_LEVEL, PANTHEIOS_FILELINE_A, "assertion failed: " #expr); \
        }                                   \
                                            \
        STLSOFT_ASSERT(expr);               \
    } while(0)
Defines an assertion construct for runtime verification.

Parameters:
expr Must be non-zero, or an assertion will be fired
If the expression evaluates to false a log statement will be submitted at the PANTHEIOS_ASSERT_SEVERITY_LEVEL severity level, and emitted if that level is currently switched on. The expression will also be subjected to an assert, via STLSOFT_ASSERT()
Examples:
cpp/contract/example.cpp.contract.PANTHEIOS_ASSERT/example.cpp.contract.PANTHEIOS_ASSERT.cpp.

#define PANTHEIOS_ASSERT_SEVERITY_LEVEL   PANTHEIOS_SEV_EMERGENCY

The level at which log statements will be submitted by PANTHEIOS_ASSERT and PANTHEIOS_MESSAGE_ASSERT.

Defaults to PANTHEIOS_SEV_EMERGENCY

#define PANTHEIOS_MESSAGE_ASSERT ( expr,
msg   ) 

Value:

\
    do                                      \
    {                                       \
        if(!(expr))                         \
        {                                   \
            PANTHEIOS_NS_QUAL(pantheios_logassertfail)(PANTHEIOS_ASSERT_SEVERITY_LEVEL, PANTHEIOS_FILELINE_A, "assertion failed: " #expr "; message: " msg); \
        }                                   \
                                            \
        STLSOFT_MESSAGE_ASSERT(msg, expr);  \
    } while(0)
Defines an assertion construct for runtime verification.

Parameters:
expr Must be non-zero, or an assertion will be fired
msg The message that will be associated with the output if the assertion fires
If the expression evaluates to false a log statement will be submitted at the PANTHEIOS_ASSERT_SEVERITY_LEVEL severity level, and emitted if that level is currently switched on. The expression will also be subjected to an assert, via STLSOFT_MESSAGE_ASSERT()
Examples:
cpp/contract/example.cpp.contract.PANTHEIOS_MESSAGE_ASSERT/example.cpp.contract.PANTHEIOS_MESSAGE_ASSERT.cpp.


pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo