Kindr
Kinematics and Dynamics for Robotics
assert_macros.hpp File Reference
#include <stdexcept>
#include <sstream>
#include <typeinfo>
#include "source_file_pos.hpp"
Include dependency graph for assert_macros.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 kindr
 

Macros

#define KINDR_DEFINE_EXCEPTION(exceptionName, exceptionParent)
 Macro for defining an exception with a given parent. More...
 
#define KINDR_THROW(exceptionType, message)
 
#define KINDR_THROW_SFP(exceptionType, SourceFilePos, message)
 
#define KINDR_ASSERT_TRUE(exceptionType, condition, message)
 
#define KINDR_ASSERT_FALSE(exceptionType, condition, message)
 
#define KINDR_ASSERT_GE_LT(exceptionType, value, lowerBound, upperBound, message)
 
#define KINDR_ASSERT_LT(exceptionType, value, upperBound, message)
 
#define KINDR_ASSERT_GE(exceptionType, value, lowerBound, message)
 
#define KINDR_ASSERT_LE(exceptionType, value, upperBound, message)
 
#define KINDR_ASSERT_GT(exceptionType, value, lowerBound, message)
 
#define KINDR_ASSERT_EQ(exceptionType, value, testValue, message)
 
#define KINDR_ASSERT_NE(exceptionType, value, testValue, message)
 
#define KINDR_ASSERT_NEAR(exceptionType, value, testValue, abs_error, message)
 
#define KINDR_THROW_DBG(exceptionType, message)
 
#define KINDR_ASSERT_TRUE_DBG(exceptionType, condition, message)
 
#define KINDR_ASSERT_FALSE_DBG(exceptionType, condition, message)
 
#define KINDR_ASSERT_DBG_RE(condition, message)   KINDR_ASSERT_DBG(std::runtime_error, condition, message)
 
#define KINDR_ASSERT_GE_LT_DBG(exceptionType, value, lowerBound, upperBound, message)
 
#define KINDR_ASSERT_LT_DBG(exceptionType, value, upperBound, message)
 
#define KINDR_ASSERT_GE_DBG(exceptionType, value, lowerBound, message)
 
#define KINDR_ASSERT_LE_DBG(exceptionType, value, upperBound, message)
 
#define KINDR_ASSERT_GT_DBG(exceptionType, value, lowerBound, message)
 
#define KINDR_ASSERT_EQ_DBG(exceptionType, value, testValue, message)
 
#define KINDR_ASSERT_NE_DBG(exceptionType, value, testValue, message)
 
#define KINDR_ASSERT_NEAR_DBG(exceptionType, value, testValue, abs_error, message)
 
#define KINDR_OUT(X)   std::cout << #X << ": " << (X) << std::endl
 

Functions

template<typename KINDR_EXCEPTION_T >
void kindr::kindr_assert_throw (bool assert_condition, std::string message, kindr::internal::source_file_pos sfp)
 

Macro Definition Documentation

#define KINDR_ASSERT_DBG_RE (   condition,
  message 
)    KINDR_ASSERT_DBG(std::runtime_error, condition, message)

Definition at line 220 of file assert_macros.hpp.

#define KINDR_ASSERT_EQ (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) != (testValue)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 167 of file assert_macros.hpp.

#define KINDR_ASSERT_EQ_DBG (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) != (testValue)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 270 of file assert_macros.hpp.

#define KINDR_ASSERT_FALSE (   exceptionType,
  condition,
  message 
)
Value:
if((condition)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert( not " << #condition << ") failed: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 111 of file assert_macros.hpp.

#define KINDR_ASSERT_FALSE_DBG (   exceptionType,
  condition,
  message 
)
Value:
if((condition)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert( not " << #condition << ") failed: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 211 of file assert_macros.hpp.

#define KINDR_ASSERT_GE (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) < (lowerBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " >= " << #lowerBound << ") failed [" << (value) << " >= " << (lowerBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 139 of file assert_macros.hpp.

#define KINDR_ASSERT_GE_DBG (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) < (lowerBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " >= " << #lowerBound << ") failed [" << (value) << " >= " << (lowerBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 242 of file assert_macros.hpp.

#define KINDR_ASSERT_GE_LT (   exceptionType,
  value,
  lowerBound,
  upperBound,
  message 
)
Value:
if((value) < (lowerBound) || (value) >= (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #lowerBound << " <= " << #value << " < " << #upperBound << ") failed [" << (lowerBound) << " <= " << (value) << " < " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 121 of file assert_macros.hpp.

#define KINDR_ASSERT_GE_LT_DBG (   exceptionType,
  value,
  lowerBound,
  upperBound,
  message 
)
Value:
if((value) < (lowerBound) || (value) >= (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #lowerBound << " <= " << #value << " < " << #upperBound << ") failed [" << (lowerBound) << " <= " << (value) << " < " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 222 of file assert_macros.hpp.

#define KINDR_ASSERT_GT (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) <= (lowerBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " > " << #lowerBound << ") failed [" << (value) << " > " << (lowerBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 157 of file assert_macros.hpp.

#define KINDR_ASSERT_GT_DBG (   exceptionType,
  value,
  lowerBound,
  message 
)
Value:
if((value) <= (lowerBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " > " << #lowerBound << ") failed [" << (value) << " > " << (lowerBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 260 of file assert_macros.hpp.

#define KINDR_ASSERT_LE (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) > (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " <= " << #upperBound << ") failed [" << (value) << " <= " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 149 of file assert_macros.hpp.

#define KINDR_ASSERT_LE_DBG (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) > (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " <= " << #upperBound << ") failed [" << (value) << " <= " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 252 of file assert_macros.hpp.

#define KINDR_ASSERT_LT (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) >= (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " < " << #upperBound << ") failed [" << (value) << " < " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 131 of file assert_macros.hpp.

#define KINDR_ASSERT_LT_DBG (   exceptionType,
  value,
  upperBound,
  message 
)
Value:
if((value) >= (upperBound)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " < " << #upperBound << ") failed [" << (value) << " < " << (upperBound) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 232 of file assert_macros.hpp.

#define KINDR_ASSERT_NE (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) == (testValue)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " != " << #testValue << ") failed [" << (value) << " != " << (testValue) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 175 of file assert_macros.hpp.

#define KINDR_ASSERT_NE_DBG (   exceptionType,
  value,
  testValue,
  message 
)
Value:
if((value) == (testValue)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " != " << #testValue << ") failed [" << (value) << " != " << (testValue) << "]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 279 of file assert_macros.hpp.

#define KINDR_ASSERT_NEAR (   exceptionType,
  value,
  testValue,
  abs_error,
  message 
)
Value:
if(!(fabs((testValue) - (value)) <= fabs(abs_error))) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << " (" << fabs((testValue) - (value)) << " > " << fabs(abs_error) << ")]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 183 of file assert_macros.hpp.

#define KINDR_ASSERT_NEAR_DBG (   exceptionType,
  value,
  testValue,
  abs_error,
  message 
)
Value:
if(!(fabs((testValue) - (value)) <= fabs(abs_error))) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #value << " == " << #testValue << ") failed [" << (value) << " == " << (testValue) << " (" << fabs((testValue) - (value)) << " > " << fabs(abs_error) << ")]: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__,kindr_assert_stringstream.str()); \
}

Definition at line 289 of file assert_macros.hpp.

#define KINDR_ASSERT_TRUE (   exceptionType,
  condition,
  message 
)
Value:
if(!(condition)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "assert(" << #condition << ") failed: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 103 of file assert_macros.hpp.

#define KINDR_ASSERT_TRUE_DBG (   exceptionType,
  condition,
  message 
)
Value:
if(!(condition)) \
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << "debug assert(" << #condition << ") failed: " << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 203 of file assert_macros.hpp.

#define KINDR_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.

Definition at line 40 of file assert_macros.hpp.

#define KINDR_OUT (   X)    std::cout << #X << ": " << (X) << std::endl

Definition at line 298 of file assert_macros.hpp.

#define KINDR_THROW (   exceptionType,
  message 
)
Value:
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 90 of file assert_macros.hpp.

#define KINDR_THROW_DBG (   exceptionType,
  message 
)
Value:
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", __FUNCTION__,__FILE__,__LINE__, kindr_assert_stringstream.str()); \
}

Definition at line 195 of file assert_macros.hpp.

#define KINDR_THROW_SFP (   exceptionType,
  SourceFilePos,
  message 
)
Value:
{ \
std::stringstream kindr_assert_stringstream; \
kindr_assert_stringstream << message; \
kindr::internal::kindr_throw_exception<exceptionType>("[" #exceptionType "] ", SourceFilePos, kindr_assert_stringstream.str()); \
}

Definition at line 97 of file assert_macros.hpp.