00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ERS_PRECONDITION
00011
00012 #include <stdio.h>
00013 #include "ers/Assertion.h"
00014
00015 namespace ers {
00016
00024 class Precondition : public Assertion {
00025 protected:
00026 virtual std::string build_message(const char* condition_text, const std::string &message, bool constant_expression = false) throw() ;
00027 Precondition(const Context &context, severity_t s);
00028 public:
00029 static const char* const PRECONDITION_CLASS ;
00030 Precondition();
00031 Precondition(const Context &context, severity_t s, const char*condition, const std::string &message , bool constant_expression=false) ;
00032 virtual const char*get_class_name() const throw();
00033 } ;
00034 }
00035
00036
00044 #ifndef N_ERS_ASSERT
00045 #ifdef __GNUC__
00046 #define ERS_PRECONDITION(expr,...) { if(!(expr)) { char precondition_buffer[256] ; snprintf(precondition_buffer,256, __VA_ARGS__) ; ers::Precondition failed_precondition(ERS_HERE,ers::error,#expr,precondition_buffer,__builtin_constant_p(expr)) ; throw failed_precondition ; } }
00047 #else
00048 #define ERS_PRECONDITION(expr,...) { if(!(expr)) { char precondition_buffer[256] ; snprintf(precondition_buffer,256, __VA_ARGS__) ; ers::Precondition failed_precondition(ERS_HERE,ers::error,#expr,precondition_buffer,false) ; throw failed_precondition ; } }
00049 #endif
00050 #else
00051 #define ERS_PRECONDITION(expr,...)
00052 #endif
00053
00054 #endif
00055