VR-Vantage
Loading...
Searching...
No Matches
DtAssert.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2017 MAK Technologies, Inc.
3** All rights reserved.
4******************************************************************************/
5
9#pragma once
10
11// If this is is 1, the asserts are enabled. Else they are compiled out
12// The developer can turn them on for development (locally)
13#ifndef DT_ASSERT_ENABLED
14#define DT_ASSERT_ENABLED 0
15#endif
16
17#if DT_ASSERT_ENABLED
18#ifdef NDEBUG
19 #undef NDEBUG
20#endif
21 // do the assert
22 #include <cassert>
23 #define Assert assert
24#else
25 #define Assert(exp) static_cast<void>(0)
26#endif
27
28#define ASSERT_PREDICATE(p) Assert(p);
29
30#define ASSERT_RETURN(p) Assert(p); \
31 if (p==0)\
32 return;
33#define ASSERT_RETURN_ZERO(p) Assert(p); \
34 if (p==0)\
35 return 0;
36
37#define ASSERT_PREDICATE_RETURN(p) Assert((p)); \
38 if (!(p))\
39 return;
40
41#define ASSERT_PREDICATE_RETURN_ZERO(p) Assert((p)); \
42 if (!(p))\
43 return 0;
44
45#define ASSERT_PREDICATE_RETURN_DEFAULT_CONSTRUCTOR(V, p) Assert((p)); \
46 if (!(p))\
47 return V();
48
49#define ASSERT_PREDICATE_RETURN_FALSE(p) Assert((p)); \
50 if (!(p))\
51 return false;
52
53#define ASSERT_PREDICATE_RETURN_TRUE(p) Assert((p)); \
54 if (!(p))\
55 return true;
56
57#define ASSERT_RETURN_EMPTY_STRING(p) Assert(p); \
58 if (p==0)\
59 return "";
60
61#define ASSERT_RETURN_FALSE(p) Assert(p); \
62 if (p==0)\
63 return false;
64#define ASSERT_RETURN_TRUE(p) Assert(p); \
65 if (p==0)\
66 return true;
67
68#define ASSERT_EQUAL_RETURN_ZERO(x,y) Assert(x==y);\
69 if (x!=y) \
70 return 0;
71
72#define ASSERT_RETURN_VALUE(condition, return_value) Assert(condition);\
73if (!(condition)) return (return_value);
74
75