xmscore
1.0
|
Functions and macros for assertion and checking for errors. More...
#include <boost/preprocessor/facilities/overload.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#include <xmscore/misc/XmLog.h>
Go to the source code of this file.
Macros | |
#define | XM_LIKELY(x) (!!(x)) |
Like Mozilla's NS_LIKELY in their Likely.h file. | |
#define | XM_UNLIKELY(x) (!!(x)) |
Like Mozilla's NS_LIKELY in their Likely.h file. | |
#define | XM_FAILED(_xmresult) ((bool)XM_UNLIKELY(XM_FAILED_impl(_xmresult))) |
macro | |
#define | XM_SUCCEEDED(_xmresult) ((bool)XM_LIKELY(!XM_FAILED_impl(_xmresult))) |
macro | |
#define | XM_ASSERT(x) ((void)0) |
Does a regular ASSERT if xmAsserting, otherwise does nothing. | |
#define | XM_ENSURE_SUCCESS_5(x, ret, lvl, msg, ast) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_3(x, ret, ast) XM_ENSURE_SUCCESS_5(x, ret, xmlog::debug, "XM_ENSURE_SUCCESS(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS(...) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_NO_ASSERT(...) |
Returns ret if x evaluates to xms::XR_FAILURE and logs. More... | |
#define | XM_ENSURE_SUCCESS_T_5(x, ret, lvl, msg, ast) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_T_3(x, ret, ast) XM_ENSURE_SUCCESS_T_5(x, ret, xmlog::debug, "XM_ENSURE_SUCCESS_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_T(...) |
Throws ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_T_NO_ASSERT(...) |
Throws ret if x evaluates to xms::XR_FAILURE and logs. More... | |
#define | XM_ENSURE_SUCCESS_VOID_4(x, lvl, msg, ast) |
Returns (void) if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_VOID_2(x, ast) XM_ENSURE_SUCCESS_VOID_4(x, xmlog::debug, "XM_ENSURE_SUCCESS_VOID(" #x ") failed", ast) |
Returns (void) if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_VOID(...) |
Returns (void) if x evaluates to xms::XR_FAILURE, logs, and optionally asserts. More... | |
#define | XM_ENSURE_SUCCESS_VOID_NO_ASSERT(...) |
Returns (void) if x evaluates to xms::XR_FAILURE and logs. More... | |
#define | XM_ENSURE_TRUE_5(x, ret, lvl, msg, ast) |
Returns ret if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_3(x, ret, ast) XM_ENSURE_TRUE_5(x, ret, xmlog::debug, "XM_ENSURE_TRUE(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_2(x, ast) XM_ENSURE_TRUE_VOID_2(x, ast) |
Returns (void) if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE(...) |
Returns (void) if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_NO_ASSERT(...) |
Returns (void) if x evaluates to false and logs. More... | |
#define | XM_ENSURE_TRUE_T_5(x, ret, lvl, msg, ast) |
Throws ret if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_T_3(x, ret, ast) XM_ENSURE_TRUE_T_5(x, ret, xmlog::debug, "XM_ENSURE_TRUE_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_T(...) |
Throws ret if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_T_NO_ASSERT(...) |
Throws ret if x evaluates to false and logs. More... | |
#define | XM_ENSURE_TRUE_VOID_4(x, lvl, msg, ast) |
Returns (void) if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_VOID_2(x, ast) XM_ENSURE_TRUE_VOID_4(x, xmlog::debug, "XM_ENSURE_TRUE_VOID(" #x ") failed", ast) |
Returns (void) if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_VOID(...) |
Returns (void) if x evaluates to false , logs, and optionally asserts. More... | |
#define | XM_ENSURE_TRUE_VOID_NO_ASSERT(...) |
Returns (void) if x evaluates to false and logs. More... | |
#define | XM_ENSURE_FALSE_5(x, ret, lvl, msg, ast) XM_ENSURE_TRUE_5(!(x), ret, lvl, msg, ast) |
Returns ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_3(x, ret, ast) XM_ENSURE_FALSE_5(x, ret, xmlog::debug, "XM_ENSURE_FALSE(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE(...) |
Returns ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_NO_ASSERT(...) |
Returns ret if x evaluates to true and logs. More... | |
#define | XM_ENSURE_FALSE_T_5(x, ret, lvl, msg, ast) XM_ENSURE_TRUE_T(!(x), ret, lvl, msg, ast) |
Throws ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_T_3(x, ret, ast) XM_ENSURE_FALSE_T_5(x, ret, xmlog::debug, "XM_ENSURE_FALSE_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_T(...) |
Throws ret if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_T_NO_ASSERT(...) |
Throws ret if x evaluates to true and logs. More... | |
#define | XM_ENSURE_FALSE_VOID_4(x, lvl, msg, ast) XM_ENSURE_TRUE_VOID_4(!(x), lvl, msg, ast) |
Returns (void) if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_VOID_2(x, ast) XM_ENSURE_FALSE_VOID_4(x, xmlog::debug, "XM_ENSURE_FALSE_VOID(" #x ") failed", ast) |
Returns (void) if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_VOID(...) |
Returns (void) if x evaluates to true , logs, and optionally asserts. More... | |
#define | XM_ENSURE_FALSE_VOID_NO_ASSERT(...) |
Returns (void) if x evaluates to true and logs. More... | |
#define | XM_RETURN_XMRESULT(x) |
Returns XR_SUCCESS if cond == true, else XR_FAILURE. Useful to convert a true/false return value into an xmresult return value. More... | |
Enumerations | |
enum | xms::xmresult { XR_SUCCESS = 0, XR_FAILURE = 1 } |
Like Mozilla's nsresult. | |
Functions | |
bool & | xms::xmAsserting () |
Stores whether we want XM_ASSERT to do something or not. More... | |
unsigned int | xms::XM_FAILED_impl (xmresult _xmresult) |
Like Mozilla's NS_FAILED in their nsError.h file. More... | |
Functions and macros for assertion and checking for errors.
Definition in file XmError.h.
#define XM_ENSURE_FALSE | ( | ... | ) |
#define XM_ENSURE_FALSE_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_FALSE_5(x, ret, xmlog::debug, "XM_ENSURE_FALSE(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to true
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to true (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_FALSE_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) | XM_ENSURE_TRUE_5(!(x), ret, lvl, msg, ast) |
Returns ret if x evaluates to true
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to true (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_FALSE_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_FALSE_T | ( | ... | ) |
#define XM_ENSURE_FALSE_T_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_FALSE_T_5(x, ret, xmlog::debug, "XM_ENSURE_FALSE_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to true
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to true (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_FALSE_T_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) | XM_ENSURE_TRUE_T(!(x), ret, lvl, msg, ast) |
Throws ret if x evaluates to true
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to true (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_FALSE_T_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_FALSE_VOID | ( | ... | ) |
#define XM_ENSURE_FALSE_VOID_2 | ( | x, | |
ast | |||
) | XM_ENSURE_FALSE_VOID_4(x, xmlog::debug, "XM_ENSURE_FALSE_VOID(" #x ") failed", ast) |
#define XM_ENSURE_FALSE_VOID_4 | ( | x, | |
lvl, | |||
msg, | |||
ast | |||
) | XM_ENSURE_TRUE_VOID_4(!(x), lvl, msg, ast) |
Returns (void) if x evaluates to true
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_FALSE_VOID_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_SUCCESS | ( | ... | ) |
#define XM_ENSURE_SUCCESS_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_SUCCESS_5(x, ret, xmlog::debug, "XM_ENSURE_SUCCESS(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.
[in] | x | Expression that evaluates to xms::xmresult. |
[in] | ret | Value returned if x evaluates to xms::XR_FAILURE (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_SUCCESS_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.
[in] | x | Expression that evaluates to xms::xmresult. |
[in] | ret | Value returned if x evaluates to xms::XR_FAILURE (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_SUCCESS_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_SUCCESS_T | ( | ... | ) |
#define XM_ENSURE_SUCCESS_T_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_SUCCESS_T_5(x, ret, xmlog::debug, "XM_ENSURE_SUCCESS_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.
[in] | x | Expression that evaluates to xms::xmresult. |
[in] | ret | Value returned if x evaluates to xms::XR_FAILURE (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_SUCCESS_T_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) |
Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.
[in] | x | Expression that evaluates to xms::xmresult. |
[in] | ret | Value returned if x evaluates to xms::XR_FAILURE (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_SUCCESS_T_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_SUCCESS_VOID | ( | ... | ) |
#define XM_ENSURE_SUCCESS_VOID_2 | ( | x, | |
ast | |||
) | XM_ENSURE_SUCCESS_VOID_4(x, xmlog::debug, "XM_ENSURE_SUCCESS_VOID(" #x ") failed", ast) |
#define XM_ENSURE_SUCCESS_VOID_4 | ( | x, | |
lvl, | |||
msg, | |||
ast | |||
) |
Returns (void) if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_SUCCESS_VOID in their nsDebug.h file.
[in] | x | Expression that evaluates to xms::xmresult. |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_SUCCESS_VOID_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_TRUE | ( | ... | ) |
#define XM_ENSURE_TRUE_2 | ( | x, | |
ast | |||
) | XM_ENSURE_TRUE_VOID_2(x, ast) |
#define XM_ENSURE_TRUE_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_TRUE_5(x, ret, xmlog::debug, "XM_ENSURE_TRUE(" #x ", " #ret ") failed", ast) |
Returns ret if x evaluates to false
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to false (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_TRUE_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) |
Returns ret if x evaluates to false
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to false (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_TRUE_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_TRUE_T | ( | ... | ) |
#define XM_ENSURE_TRUE_T_3 | ( | x, | |
ret, | |||
ast | |||
) | XM_ENSURE_TRUE_T_5(x, ret, xmlog::debug, "XM_ENSURE_TRUE_T(" #x ", " #ret ") failed", ast) |
Throws ret if x evaluates to false
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to false (any type). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_TRUE_T_5 | ( | x, | |
ret, | |||
lvl, | |||
msg, | |||
ast | |||
) |
Throws ret if x evaluates to false
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | ret | Value returned if x evaluates to false (any type). |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_TRUE_T_NO_ASSERT | ( | ... | ) |
#define XM_ENSURE_TRUE_VOID | ( | ... | ) |
#define XM_ENSURE_TRUE_VOID_2 | ( | x, | |
ast | |||
) | XM_ENSURE_TRUE_VOID_4(x, xmlog::debug, "XM_ENSURE_TRUE_VOID(" #x ") failed", ast) |
#define XM_ENSURE_TRUE_VOID_4 | ( | x, | |
lvl, | |||
msg, | |||
ast | |||
) |
Returns (void) if x evaluates to false
, logs, and optionally asserts.
Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.
[in] | x | Expression that evaluates to a bool true or false . |
[in] | lvl | Log level xmlog::LogLevelEnum. |
[in] | msg | Log message (std::string ). |
[in] | ast | Asserts if true (bool ). |
#define XM_ENSURE_TRUE_VOID_NO_ASSERT | ( | ... | ) |
#define XM_RETURN_XMRESULT | ( | x | ) |
Returns XR_SUCCESS if cond == true, else XR_FAILURE. Useful to convert a true/false return value into an xmresult return value.
[in] | x | Expression to be evaluated (expression of any type). |
|
inline |
Like Mozilla's NS_FAILED in their nsError.h file.
_xmresult | result to test |
Definition at line 50 of file XmError.h.
References xms::XM_FAILED_impl().
Referenced by xms::XM_FAILED_impl().
bool & xms::xmAsserting | ( | ) |
Stores whether we want XM_ASSERT to do something or not.
Definition at line 32 of file XmError.cpp.
References xms::xmAsserting().
Referenced by XmErrorUnitTests::test_XM_ASSERT(), and xms::xmAsserting().