From d0da3a7489670a202901ac32ca6e4bffb16d485b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 4 May 2016 15:38:52 +0300 Subject: Add macroses returnFalseV, returnTrueV, returnFalse, returnTrue. --- src/utils/checkutils.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/utils/checkutils.h') diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h index fea0a0f67..713ac305f 100644 --- a/src/utils/checkutils.h +++ b/src/utils/checkutils.h @@ -35,6 +35,38 @@ #define failTrue(val) \ failTrueReal(val, #val, __FILE__, __LINE__, __func__) +#define returnFalseV(val) \ + if (!val) \ + { \ + reportStack(__FILE__, __LINE__, __func__, \ + "Detected false value", #val); \ + return; \ + } + +#define returnTrueV(val) \ + if (val) \ + { \ + reportStack(__FILE__, __LINE__, __func__, \ + "Detected true value", #val); \ + return; \ + } + +#define returnFalse(ret, val) \ + if (!val) \ + { \ + reportStack(__FILE__, __LINE__, __func__, \ + "Detected false value", #val); \ + return ret; \ + } + +#define returnTrue(ret, val) \ + if (val) \ + { \ + reportStack(__FILE__, __LINE__, __func__, \ + "Detected true value", #val); \ + return ret; \ + } + bool reportFalseReal(const bool val, const char *const text, const char *const file, @@ -71,6 +103,10 @@ void reportStack(const char *const file, #define reportTrue(val) (val) #define failFalse(val) (val) #define failTrue(val) (val) +#define returnTrueV(val) +#define returnFalseV(val) +#define returnTrue(val) +#define returnFalse(val) #endif // ENABLE_ASSERTS #endif // UTILS_CHECKUTILS_H -- cgit v1.2.3-70-g09d2