Debian Codegraph @

core/libs/dngwriter/extra/dng_sdk/dng_assertions.h

raw
1 /*****************************************************************************/
2 // Copyright 2006-2019 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE: Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8
9 /** \file
10 * Conditionally compiled assertion check support.
11 */
12
13 /*****************************************************************************/
14
15 #ifndef __dng_assertions__
16 #define __dng_assertions__
17
18 /*****************************************************************************/
19
20 #include "dng_exceptions.h"
21 #include "dng_flags.h"
22
23
24 /*****************************************************************************/
25
26 #if qWinOS
27
28 /// Windows-only function to emit a message to the Debugger Output pane
29 /// if a debug session is in progress.
30 /// \param s C string to emit.
31 /// \param nl Optional newline (or suffix) C string to be emitted after s.
32
33 void dng_outputdebugstring (const char *s,
34 const char *nl = NULL);
35
36 #endif
37
38 /*****************************************************************************/
39
40 #if defined(__EMSCRIPTEN__)
41
42 /// Emscripten-only function to emit a message to the debugger console
43 /// if a debug session is in progress.
44
45 void dng_emscripten_log (int emLogType,
46 const char *s);
47
48 #endif
49
50 /*****************************************************************************/
51
52 /// Platform-specific function to display an assert.
53
54 void dng_show_message (const char *s);
55
56 /// Show a formatted error message.
57
58 void dng_show_message_f (const char *fmt, ...);
59
60 /*****************************************************************************/
61
62 #ifndef DNG_ASSERT
63
64 #if qDNGDebug
65
66 /// Conditionally compiled macro to check an assertion and display a message if
67 /// it fails and assertions are compiled in via qDNGDebug
68 /// \param x Predicate which must be true.
69 /// \param y String to display if x is not true.
70
71 #define DNG_ASSERT(x,y) { if (!(x)) dng_show_message (y); }
72
73 #else
74
75 /// Conditionally compiled macro to check an assertion and display a message if
76 /// it fails and assertions are compiled in via qDNGDebug
77 /// \param x Predicate which must be true.
78 /// \param y String to display if x is not true.
79
80 #define DNG_ASSERT(x,y)
81
82 #endif
83 #endif
84
85 /*****************************************************************************/
86
87 #ifndef DNG_REQUIRE
88
89 #if qDNGDebug
90
91 /// Conditionally compiled macro to check an assertion, display a message, and throw
92 /// an exception if it fails and assertions are compiled in via qDNGDebug
93 /// \param condition Predicate which must be true.
94 /// \param msg String to display if condition is not true.
95
96 #define DNG_REQUIRE(condition,msg) \
97 do \
98 { \
99 \
100 if (!(condition)) \
101 { \
102 \
103 DNG_ASSERT(condition, msg); \
104 \
105 ThrowProgramError (msg); \
106 \
107 } \
108 \
109 } \
110 while (0)
111
112 #else
113
114 /// Conditionally compiled macro to check an assertion, display a message, and throw
115 /// an exception if it fails and assertions are compiled in via qDNGDebug
116 /// \param condition Predicate which must be true.
117 /// \param msg String to display if condition is not true.
118
119 #define DNG_REQUIRE(condition,msg) \
120 do \
121 { \
122 \
123 if (!(condition)) \
124 { \
125 \
126 ThrowProgramError (msg); \
127 \
128 } \
129 \
130 } \
131 while (0)
132
133 #endif
134 #endif
135
136 /*****************************************************************************/
137
138 #ifndef DNG_REPORT
139
140 /// Macro to display an informational message
141 /// \param x String to display.
142
143 #define DNG_REPORT(x) DNG_ASSERT (false, x)
144
145 #endif
146
147 /*****************************************************************************/
148
149 #endif
150
151 /*****************************************************************************/