mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 01:51:49 +08:00
REWORKed JKQTPASSERT_M() und JKQTPASSERT() macros (removed unnecessary helper functions)
This commit is contained in:
parent
220e2b5bb7
commit
7cf2990f08
@ -67,100 +67,13 @@ class JKQTCOMMON_LIB_EXPORT JKQTPAutoOutputTimer : public QElapsedTimer
|
||||
};
|
||||
|
||||
|
||||
/** \brief dynamic assertion, throws a \c std::runtime_error exception if \a condition is \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*
|
||||
* \param condition the condition to check
|
||||
* \param message a user-provided error message
|
||||
* \param expression the expression (as a string) that was used to calculate \a condition
|
||||
* \param file filename where the exception occured
|
||||
* \param line line in file \a file where the exception occured
|
||||
*
|
||||
* \see JKQTPASSERT_M(), JKQTPASSERT() for macros that use this function and automatically stringify the expression and add file and line
|
||||
*/
|
||||
inline void jkqtp_assert(bool condition, const std::string& message, const std::string expression, const std::string& file, int line)
|
||||
{
|
||||
if (!condition) {
|
||||
throw std::runtime_error(message+" (expression: "+expression+", file: "+file+":"+std::to_string(line)+")");
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief dynamic assertion, throws a \c std::runtime_error exception if \a condition is \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*
|
||||
* \param condition the condition to check
|
||||
* \param message a user-provided error message
|
||||
* \param expression the expression (as a string) that was used to calculate \a condition
|
||||
* \param file filename where the exception occured
|
||||
* \param line line in file \a file where the exception occured
|
||||
* \param function calling function
|
||||
*
|
||||
* \see JKQTPASSERT_M(), JKQTPASSERT() for macros that use this function and automatically stringify the expression and add file and line
|
||||
*/
|
||||
inline void jkqtp_assert(bool condition, const std::string& message, const std::string expression, const std::string& file, int line, const std::string& function)
|
||||
{
|
||||
if (!condition) {
|
||||
throw std::runtime_error(message+" (expression: "+expression+", function: "+function+", file: "+file+":"+std::to_string(line)+")");
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief dynamic assertion, throws a \c std::runtime_error exception if \a condition is \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*
|
||||
* \param condition the condition to check
|
||||
* \param expression the expression (as a string) that was used to calculate \a condition
|
||||
* \param file filename where the exception occured
|
||||
* \param line line in file \a file where the exception occured
|
||||
* \param function calling function
|
||||
*
|
||||
* \see JKQTPASSERT_M(), JKQTPASSERT() for macros that use this function and automatically stringify the expression and add file and line
|
||||
*/
|
||||
inline void jkqtp_assert(bool condition, const std::string expression, const std::string& file, int line, const std::string& function)
|
||||
{
|
||||
if (!condition) {
|
||||
throw std::runtime_error("assertion failed (expression: "+expression+", function: "+function+", file: "+file+":"+std::to_string(line)+")");
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief dynamic assertion, throws a \c std::runtime_error exception if \a condition is \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*
|
||||
* \param condition the condition to check
|
||||
* \param expression the expression (as a string) that was used to calculate \a condition
|
||||
* \param file filename where the exception occured
|
||||
* \param line line in file \a file where the exception occured
|
||||
*
|
||||
* \see JKQTPASSERT_M(), JKQTPASSERT() for macros that use this function and automatically stringify the expression and add file and line
|
||||
*/
|
||||
inline void jkqtp_assert(bool condition, const std::string expression, const std::string& file, int line)
|
||||
{
|
||||
if (!condition) {
|
||||
throw std::runtime_error("assertion failed (expression: "+expression+", file: "+file+":"+std::to_string(line)+")");
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief dynamic assertion, throws a \c std::runtime_error exception if \a condition is \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*
|
||||
* \param condition the condition to check
|
||||
* \param message a user-provided error message
|
||||
*
|
||||
* \see JKQTPASSERT_M(), JKQTPASSERT()
|
||||
*/
|
||||
inline void jkqtp_assert(bool condition, const std::string& message)
|
||||
{
|
||||
if (!condition) {
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief dynamic assertion, throws an exception with the given \a message, when the given condition \a condition evaluates to \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*/
|
||||
#define JKQTPASSERT_M(condition, message) jkqtp_assert(condition, message, #condition, __FILE__, __LINE__, __FUNCTION__)
|
||||
#define JKQTPASSERT_M(condition, message) { if (!(condition)) throw std::runtime_error(std::string(message)+" (expression: "+std::string(#condition)+", function: "+std::string(__FUNCTION__)+", file: "+std::string(__FILE__)+":"+std::to_string(__LINE__)+")"); }
|
||||
/** \brief dynamic assertion, throws an exception with the given \a message, when the given condition \a condition evaluates to \c false
|
||||
* \ingroup jkqtptools_debugging
|
||||
*/
|
||||
#define JKQTPASSERT(condition) jkqtp_assert(condition, #condition, __FILE__, __LINE__, __FUNCTION__)
|
||||
#define JKQTPASSERT(condition) { if (!(condition)) throw std::runtime_error("assertion failed (expression: "+std::string(#condition)+", function: "+std::string(__FUNCTION__)+", file: "+std::string(__FILE__)+":"+std::to_string(__LINE__)+")"); }
|
||||
|
||||
#endif // JKQTPDEBUGGINGTOOLS_H_INCLUDED
|
||||
|
Loading…
Reference in New Issue
Block a user