xmscore  1.0
XmError.h File Reference

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...
 

Detailed Description

Functions and macros for assertion and checking for errors.

Definition in file XmError.h.

Macro Definition Documentation

◆ XM_ENSURE_FALSE

#define XM_ENSURE_FALSE (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns ret if x evaluates to true, logs, and optionally asserts.

Definition at line 410 of file XmError.h.

◆ XM_ENSURE_FALSE_3

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to true (any type).
[in]astAsserts if true (bool).

Definition at line 404 of file XmError.h.

◆ XM_ENSURE_FALSE_5

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to true (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 394 of file XmError.h.

◆ XM_ENSURE_FALSE_NO_ASSERT

#define XM_ENSURE_FALSE_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns ret if x evaluates to true and logs.

Definition at line 416 of file XmError.h.

◆ XM_ENSURE_FALSE_T

#define XM_ENSURE_FALSE_T (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_T_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to true, logs, and optionally asserts.

Definition at line 446 of file XmError.h.

◆ XM_ENSURE_FALSE_T_3

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to true (any type).
[in]astAsserts if true (bool).

Definition at line 440 of file XmError.h.

◆ XM_ENSURE_FALSE_T_5

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to true (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 430 of file XmError.h.

◆ XM_ENSURE_FALSE_T_NO_ASSERT

#define XM_ENSURE_FALSE_T_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_T_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to true and logs.

Definition at line 453 of file XmError.h.

◆ XM_ENSURE_FALSE_VOID

#define XM_ENSURE_FALSE_VOID (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_VOID_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to true, logs, and optionally asserts.

Definition at line 482 of file XmError.h.

◆ XM_ENSURE_FALSE_VOID_2

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

Like Mozilla's NS_ENSURE_FALSE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]astAsserts if true (bool).

Definition at line 476 of file XmError.h.

◆ XM_ENSURE_FALSE_VOID_4

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 467 of file XmError.h.

◆ XM_ENSURE_FALSE_VOID_NO_ASSERT

#define XM_ENSURE_FALSE_VOID_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_FALSE_VOID_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to true and logs.

Definition at line 489 of file XmError.h.

◆ XM_ENSURE_SUCCESS

#define XM_ENSURE_SUCCESS (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.

Definition at line 112 of file XmError.h.

◆ XM_ENSURE_SUCCESS_3

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

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]retValue returned if x evaluates to xms::XR_FAILURE (any type).
[in]astAsserts if true (bool).

Definition at line 106 of file XmError.h.

◆ XM_ENSURE_SUCCESS_5

#define XM_ENSURE_SUCCESS_5 (   x,
  ret,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
xms::xmresult __rv = x; /* Don't evaluate |x| more than once */ \
if (XM_FAILED(__rv)) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_SUCCESS(" #x ", " #ret ") failed"); */ \
return ret; \
} \
} while (xms::XM0)
#define XM_FAILED(_xmresult)
macro
Definition: XmError.h:55

Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.

Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]retValue returned if x evaluates to xms::XR_FAILURE (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 82 of file XmError.h.

◆ XM_ENSURE_SUCCESS_NO_ASSERT

#define XM_ENSURE_SUCCESS_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns ret if x evaluates to xms::XR_FAILURE and logs.

Definition at line 119 of file XmError.h.

◆ XM_ENSURE_SUCCESS_T

#define XM_ENSURE_SUCCESS_T (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_T_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.

Definition at line 164 of file XmError.h.

◆ XM_ENSURE_SUCCESS_T_3

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

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]retValue returned if x evaluates to xms::XR_FAILURE (any type).
[in]astAsserts if true (bool).

Definition at line 158 of file XmError.h.

◆ XM_ENSURE_SUCCESS_T_5

#define XM_ENSURE_SUCCESS_T_5 (   x,
  ret,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
xms::xmresult __rv = x; /* Don't evaluate |x| more than once */ \
if (XM_FAILED(__rv)) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_SUCCESS(" #x ", " #ret ") failed"); */ \
throw(ret); \
} \
} while (xms::XM0)
#define XM_FAILED(_xmresult)
macro
Definition: XmError.h:55

Returns ret if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.

Like Mozilla's NS_ENSURE_SUCCESS in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]retValue returned if x evaluates to xms::XR_FAILURE (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 134 of file XmError.h.

◆ XM_ENSURE_SUCCESS_T_NO_ASSERT

#define XM_ENSURE_SUCCESS_T_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_T_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to xms::XR_FAILURE and logs.

Definition at line 171 of file XmError.h.

◆ XM_ENSURE_SUCCESS_VOID

#define XM_ENSURE_SUCCESS_VOID (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_VOID_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to xms::XR_FAILURE, logs, and optionally asserts.

Parameters
...Variable input

Definition at line 215 of file XmError.h.

◆ XM_ENSURE_SUCCESS_VOID_2

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

Like Mozilla's NS_ENSURE_SUCCESS_VOID in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]astAsserts if true (bool).

Definition at line 208 of file XmError.h.

◆ XM_ENSURE_SUCCESS_VOID_4

#define XM_ENSURE_SUCCESS_VOID_4 (   x,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
xms::xmresult __rv = x; \
if (XM_FAILED(__rv)) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_SUCCESS(" #x ") failed"); */ \
return; \
} \
} while (xms::XM0)
#define XM_FAILED(_xmresult)
macro
Definition: XmError.h:55

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.

Parameters
[in]xExpression that evaluates to xms::xmresult.
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 185 of file XmError.h.

◆ XM_ENSURE_SUCCESS_VOID_NO_ASSERT

#define XM_ENSURE_SUCCESS_VOID_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_SUCCESS_VOID_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to xms::XR_FAILURE and logs.

Parameters
...Variable input

Definition at line 223 of file XmError.h.

◆ XM_ENSURE_TRUE

#define XM_ENSURE_TRUE (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to false, logs, and optionally asserts.

Definition at line 276 of file XmError.h.

◆ XM_ENSURE_TRUE_2

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

Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]astAsserts if true (bool).

Definition at line 271 of file XmError.h.

◆ XM_ENSURE_TRUE_3

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to false (any type).
[in]astAsserts if true (bool).

Definition at line 261 of file XmError.h.

◆ XM_ENSURE_TRUE_5

#define XM_ENSURE_TRUE_5 (   x,
  ret,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
if (XM_UNLIKELY(!(x))) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_TRUE(" #x ") failed"); */ \
return ret; \
} \
} while (xms::XM0)
#define XM_UNLIKELY(x)
Like Mozilla&#39;s NS_LIKELY in their Likely.h file.
Definition: XmError.h:44

Returns ret if x evaluates to false, logs, and optionally asserts.

Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to false (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 238 of file XmError.h.

◆ XM_ENSURE_TRUE_NO_ASSERT

#define XM_ENSURE_TRUE_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to false and logs.

Definition at line 282 of file XmError.h.

◆ XM_ENSURE_TRUE_T

#define XM_ENSURE_TRUE_T (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_T_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to false, logs, and optionally asserts.

Definition at line 325 of file XmError.h.

◆ XM_ENSURE_TRUE_T_3

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

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to false (any type).
[in]astAsserts if true (bool).

Definition at line 319 of file XmError.h.

◆ XM_ENSURE_TRUE_T_5

#define XM_ENSURE_TRUE_T_5 (   x,
  ret,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
if (XM_UNLIKELY(!(x))) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_TRUE(" #x ") failed"); */ \
throw(ret); \
} \
} while (xms::XM0)
#define XM_UNLIKELY(x)
Like Mozilla&#39;s NS_LIKELY in their Likely.h file.
Definition: XmError.h:44

Throws ret if x evaluates to false, logs, and optionally asserts.

Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]retValue returned if x evaluates to false (any type).
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 296 of file XmError.h.

◆ XM_ENSURE_TRUE_T_NO_ASSERT

#define XM_ENSURE_TRUE_T_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT(BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_T_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Throws ret if x evaluates to false and logs.

Definition at line 331 of file XmError.h.

◆ XM_ENSURE_TRUE_VOID

#define XM_ENSURE_TRUE_VOID (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_VOID_, __VA_ARGS__, xms::XM1)(__VA_ARGS__, xms::XM1), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to false, logs, and optionally asserts.

Definition at line 372 of file XmError.h.

◆ XM_ENSURE_TRUE_VOID_2

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

Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]astAsserts if true (bool).

Definition at line 366 of file XmError.h.

◆ XM_ENSURE_TRUE_VOID_4

#define XM_ENSURE_TRUE_VOID_4 (   x,
  lvl,
  msg,
  ast 
)
Value:
do \
{ \
if (XM_UNLIKELY(!(x))) \
{ \
XM_LOG(lvl, msg); \
if (ast) \
{ \
XM_ASSERT(!#x); \
} \
/*TS_WARN("XM_ENSURE_TRUE(" #x ") failed"); */ \
return; \
} \
} while (xms::XM0)
#define XM_UNLIKELY(x)
Like Mozilla&#39;s NS_LIKELY in their Likely.h file.
Definition: XmError.h:44

Returns (void) if x evaluates to false, logs, and optionally asserts.

Like Mozilla's NS_ENSURE_TRUE in their nsDebug.h file.

Parameters
[in]xExpression that evaluates to a bool true or false.
[in]lvlLog level xmlog::LogLevelEnum.
[in]msgLog message (std::string).
[in]astAsserts if true (bool).

Definition at line 344 of file XmError.h.

◆ XM_ENSURE_TRUE_VOID_NO_ASSERT

#define XM_ENSURE_TRUE_VOID_NO_ASSERT (   ...)
Value:
BOOST_PP_CAT( \
BOOST_PP_OVERLOAD(XM_ENSURE_TRUE_VOID_, __VA_ARGS__, xms::XM0)(__VA_ARGS__, xms::XM0), \
BOOST_PP_EMPTY())

Returns (void) if x evaluates to false and logs.

Definition at line 379 of file XmError.h.

◆ XM_RETURN_XMRESULT

#define XM_RETURN_XMRESULT (   x)
Value:
{ \
return (XM_LIKELY(x) ? XR_SUCCESS : XR_FAILURE); \
}
#define XM_LIKELY(x)
Like Mozilla&#39;s NS_LIKELY in their Likely.h file.
Definition: XmError.h:43

Returns XR_SUCCESS if cond == true, else XR_FAILURE. Useful to convert a true/false return value into an xmresult return value.

Parameters
[in]xExpression to be evaluated (expression of any type).

Definition at line 498 of file XmError.h.

Function Documentation

◆ XM_FAILED_impl()

unsigned int xms::XM_FAILED_impl ( xmresult  _xmresult)
inline

Like Mozilla's NS_FAILED in their nsError.h file.

Parameters
_xmresultresult to test
Returns
integer 0 or 1

Definition at line 50 of file XmError.h.

References xms::XM_FAILED_impl().

Referenced by xms::XM_FAILED_impl().

◆ xmAsserting()

bool & xms::xmAsserting ( )

Stores whether we want XM_ASSERT to do something or not.

Returns
Reference to a bool.

Definition at line 32 of file XmError.cpp.

References xms::xmAsserting().

Referenced by XmErrorUnitTests::test_XM_ASSERT(), and xms::xmAsserting().