Go to Overview over all GrAL packages.
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Utility/pre-post-conditions.h File Reference

Some useful macros for checking pre/post conditions. More...

#include <iostream.h>
#include <stdlib.h>

Include dependency graph for pre-post-conditions.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.


Detailed Description

Some useful macros for checking pre/post conditions.

Two different sets of macros are defined:

Example:
 int* f(int* p) {
  REQUIRE((p != 0), "Pointer null!", 1);
  // work on p ...
  ENSURE((p != 0), "Pointer null!", 1);
 }

Definition in file pre-post-conditions.h.


Define Documentation

#define _ERRORLOG   cerr
 

Definition at line 35 of file pre-post-conditions.h.

#define _PRECONDITION_ERROR
 

Value:

_ERRORLOG << "\nERROR in FILE "  << __FILE__ << ", LINE " << __LINE__\
   << "\n(compiled on " << __DATE__ << " at " __TIME__  << " )\n"\
   << "precondition violated:\n"

Definition at line 37 of file pre-post-conditions.h.

#define _POSTCONDITION_ERROR
 

Value:

_ERRORLOG << "\nERROR in FILE "  << __FILE__ << ", LINE " << __LINE__\
   << "\n(compiled on " << __DATE__ << " at " __TIME__  << " )\n"\
                                       << ": postcondition violated:\n"

Definition at line 41 of file pre-post-conditions.h.

#define REQUIRE_ALWAYS condition,
error_msg,
severity       if(! (condition)) { _PRECONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
 

Definition at line 45 of file pre-post-conditions.h.

Referenced by main.

#define ENSURE_ALWAYS condition,
error_msg,
severity       if(! (condition)) { _POSTCONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
 

Definition at line 48 of file pre-post-conditions.h.

#define REQUIRE condition,
error_msg,
severity   
 

Definition at line 60 of file pre-post-conditions.h.

#define ENSURE condition,
error_msg,
severity   
 

Definition at line 61 of file pre-post-conditions.h.


Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:03 2002 for Utilities by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000