ParameterHandler
A library that handles parameters at runtime.
assert_macros.hpp File Reference
#include <stdexcept>
#include <sstream>
#include <typeinfo>
#include <iostream>
#include <stdarg.h>
#include "message_logger/common/source_file_pos.hpp"
Include dependency graph for assert_macros.hpp:
This graph shows which files directly or indirectly include this file:

Namespaces

 message_logger
 
 message_logger::common
 

Macros

#define MELO_DEFINE_EXCEPTION(exceptionName, exceptionParent)
 Macro for defining an exception with a given parent. More...
 
#define MELO_THROW(exceptionType, message)
 
#define MELO_THROW_SFP(exceptionType, SourceFilePos, message)
 
#define MELO_ASSERT_TRUE(exceptionType, condition, message)
 
#define MELO_ASSERT_FALSE(exceptionType, condition, message)
 
#define MELO_ASSERT_GE_LT(exceptionType, value, lowerBound, upperBound, message)
 
#define MELO_ASSERT_LT(exceptionType, value, upperBound, message)
 
#define MELO_ASSERT_GE(exceptionType, value, lowerBound, message)
 
#define MELO_ASSERT_LE(exceptionType, value, upperBound, message)
 
#define MELO_ASSERT_GT(exceptionType, value, lowerBound, message)
 
#define MELO_ASSERT_EQ(exceptionType, value, testValue, message)
 
#define MELO_ASSERT_NE(exceptionType, value, testValue, message)
 
#define MELO_ASSERT_NEAR(exceptionType, value, testValue, abs_error, message)
 
#define MELO_OUT(X)   std::cout << #X << ": " << (X) << std::endl
 
#define MELO_THROW_DBG(exceptionType, message)
 
#define MELO_ASSERT_TRUE_DBG(exceptionType, condition, message)
 
#define MELO_ASSERT_FALSE_DBG(exceptionType, condition, message)
 
#define MELO_ASSERT_DBG_RE(condition, message)   MELO_ASSERT_DBG(std::runtime_error, condition, message)
 
#define MELO_ASSERT_GE_LT_DBG(exceptionType, value, lowerBound, upperBound, message)
 
#define MELO_ASSERT_LT_DBG(exceptionType, value, upperBound, message)
 
#define MELO_ASSERT_GE_DBG(exceptionType, value, lowerBound, message)
 
#define MELO_ASSERT_LE_DBG(exceptionType, value, upperBound, message)
 
#define MELO_ASSERT_GT_DBG(exceptionType, value, lowerBound, message)
 
#define MELO_ASSERT_EQ_DBG(exceptionType, value, testValue, message)
 
#define MELO_ASSERT_NE_DBG(exceptionType, value, testValue, message)
 
#define MELO_ASSERT_NEAR_DBG(exceptionType, value, testValue, abs_error, message)
 
#define MELO_OUT_DBG(X)   std::cout << #X << ": " << (X) << std::endl
 

Functions

template<typename Exception_ >
void message_logger::common::melo_assert_throw (bool assert_condition, std::string message, message_logger::common::internal::source_file_pos sfp)
 

Detailed Description

Author
Christian Gehring
Date
Dec, 2014

Macro Definition Documentation

#define MELO_ASSERT_DBG_RE (   condition,
  message 
)    MELO_ASSERT_DBG(std::runtime_error, condition, message)
#define MELO_ASSERT_EQ (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) != (testValue)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_EQ_DBG (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) != (testValue)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_FALSE (   exceptionType,
  condition,
  message 
)
Value:
if((condition)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert( not " << #condition << ") failed: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_FALSE_DBG (   exceptionType,
  condition,
  message 
)
Value:
if((condition)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert( not " << #condition << ") failed: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GE (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) < (lowerBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " >= " << #lowerBound << ") failed [" << (value) << " >= " << (lowerBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GE_DBG (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) < (lowerBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " >= " << #lowerBound << ") failed [" << (value) << " >= " << (lowerBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GE_LT (   exceptionType,
  value,
  lowerBound,
  upperBound,
  message 
)
Value:
if((value) < (lowerBound) || (value) >= (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #lowerBound << " <= " << #value << " < " << #upperBound << ") failed [" << (lowerBound) << " <= " << (value) << " < " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GE_LT_DBG (   exceptionType,
  value,
  lowerBound,
  upperBound,
  message 
)
Value:
if((value) < (lowerBound) || (value) >= (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #lowerBound << " <= " << #value << " < " << #upperBound << ") failed [" << (lowerBound) << " <= " << (value) << " < " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GT (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) <= (lowerBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " > " << #lowerBound << ") failed [" << (value) << " > " << (lowerBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_GT_DBG (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) <= (lowerBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " > " << #lowerBound << ") failed [" << (value) << " > " << (lowerBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_LE (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) > (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " <= " << #upperBound << ") failed [" << (value) << " <= " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_LE_DBG (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) > (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " <= " << #upperBound << ") failed [" << (value) << " <= " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_LT (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) >= (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " < " << #upperBound << ") failed [" << (value) << " < " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_LT_DBG (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) >= (upperBound)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " < " << #upperBound << ") failed [" << (value) << " < " << (upperBound) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_NE (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) == (testValue)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " != " << #testValue << ") failed [" << (value) << " != " << (testValue) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_NE_DBG (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) == (testValue)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " != " << #testValue << ") failed [" << (value) << " != " << (testValue) << "]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_NEAR (   exceptionType,
  value,
  testValue,
  abs_error,
  message 
)
Value:
if(!(fabs((testValue) - (value)) <= fabs(abs_error))) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << " (" << fabs((testValue) - (value)) << " > " << fabs(abs_error) << ")]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_NEAR_DBG (   exceptionType,
  value,
  testValue,
  abs_error,
  message 
)
Value:
if(!(fabs((testValue) - (value)) <= fabs(abs_error))) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << " (" << fabs((testValue) - (value)) << " > " << fabs(abs_error) << ")]: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_TRUE (   exceptionType,
  condition,
  message 
)
Value:
if(!(condition)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "assert(" << #condition << ") failed: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_ASSERT_TRUE_DBG (   exceptionType,
  condition,
  message 
)
Value:
if(!(condition)) \
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << "debug assert(" << #condition << ") failed: " << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_DEFINE_EXCEPTION (   exceptionName,
  exceptionParent 
)
Value:
class exceptionName : public exceptionParent { \
public: \
exceptionName(const char * message) : exceptionParent(message) {} \
exceptionName(std::string const & message) : exceptionParent(message) {} \
virtual ~exceptionName() throw() {} \
};

Macro for defining an exception with a given parent.

#define MELO_OUT (   X)    std::cout << #X << ": " << (X) << std::endl
#define MELO_OUT_DBG (   X)    std::cout << #X << ": " << (X) << std::endl
#define MELO_THROW (   exceptionType,
  message 
)
Value:
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_THROW_DBG (   exceptionType,
  message 
)
Value:
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, melo_assert_stringstream.str()); \
}
#define MELO_THROW_SFP (   exceptionType,
  SourceFilePos,
  message 
)
Value:
{ \
std::stringstream melo_assert_stringstream; \
melo_assert_stringstream << message; \
message_logger::common::internal::melo_throw_exception<exceptionType>("[" #exceptionType "] ", SourceFilePos, melo_assert_stringstream.str()); \
}