Loading...
Searching...
No Matches
Assure.h File Reference

A collection of assert function wrappers. More...

`#include <unistd.h>`
`#include <errno.h>`
`#include <signal.h>`
`#include "assa/Logger.h"`

Go to the source code of this file.

## Macros

#define | Assure_exit(exp_)
| Macro that makes program exit if assert fails.
#define | Assure_return(exp_)
| Test condition and return bool from a function if assertion fails.
#define | Assure_return_void(exp_)
| Test condition and return from a function immediately if assertion fails.
#define | Assure_return_value(exp_, value_)
| Test condition and return value_ from a function if assertion fails.

## Detailed Description

A collection of assert function wrappers.

Definition in file Assure.h.

## Macro Definition Documentation

## Assure_exit

#define Assure_exit | ( |  | exp_ | ) |

Value:
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Aborted False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
::raise( SIGTERM ); \
} \
} while (0)
ASSA::ASSAERR
@ ASSAERR
ASSA and system errors.
Definition LogMask.h:34

Macro that makes program exit if assert fails.

assert a la ASSA. If expression exp_ is evaluated to false, error message is logged and current process is terminated with SIGTERM signal.

Parameters

  exp_ | expression to evaluate

Definition at line 39 of file Assure.h.

#define Assure_exit( exp_ ) \
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Aborted False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
::raise( SIGTERM ); \
} \
} while (0)

Referenced by ASSA::Semaphore::close(), ASSA::Semaphore::create(), ASSA::FileLogger::handle_rollover(), ASSA::RemoteLogger::log_msg(), ASSA::Semaphore::op(), ASSA::Semaphore::open(), and ASSA::Semaphore::remove().

## Assure_return

#define Assure_return | ( |  | exp_ | ) |

Value:
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return (false); \
} \
} while (0)

Test condition and return bool from a function if assertion fails.

Expression exp_ is evaluated and tested for the truth. If expression is false, error message with file name and line number is logged to the log file, and program control is returned back from current execution scope with return value equal to FALSE.

Parameters

  exp_ | expression to evaluate

Returns
  FALSE if expression evaluates to false; if expression happens to evaluate to TRUE, Assure_return() DOES NOT return - program continues its natural execution flow.

Definition at line 64 of file Assure.h.

#define Assure_return(exp_) \
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return (false); \
} \
} while (0)

Referenced by ASSA::IPv4Socket::bind(), ASSA::Reactor::registerIOHandler(), ASSA::Reactor::registerTimerHandler(), and ASSA::Reactor::removeIOHandler().

## Assure_return_value

#define Assure_return_value | ( |  | exp_,
|  |  | value_ )

Value:
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return (value_); \
} \
} while (0)

Test condition and return value_ from a function if assertion fails.

Expression exp_ is evaluated and tested for the truth. If expression is false, error message with file name and line number is logged to the log file, and program control is returned back from current execution scope with return value equal to value_.

Parameters

  exp_ | expression to evaluate
  value_ | value to return

Returns
  value_ if expression evaluates to false; if expression happens to evaluate to TRUE, Assure_return_value() DOES NOT return - program continues its natural execution flow.

Definition at line 109 of file Assure.h.

#define Assure_return_value(exp_,value_) \
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return (value_); \
} \
} while (0)

## Assure_return_void

#define Assure_return_void | ( |  | exp_ | ) |

Value:
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return; \
} \
} while (0)

Test condition and return from a function immediately if assertion fails.

Expression exp_ is evaluated and tested for the truth. If expression is false, error message with file name and line number is logged to the log file, and program control is returned back from current execution scope.

Parameters

  exp_ | expression to evaluate

Definition at line 84 of file Assure.h.

#define Assure_return_void(exp_) \
do { \
if ( !(exp_) ) { \
DL((ASSA::ASSAERR,"Assure Returned False Expression!\n")); \
DL((ASSA::ASSAERR,"Error on line %d in file %s\n", __LINE__, __FILE__)); \
return; \
} \
} while (0)