summaryrefslogtreecommitdiff
path: root/source/dng_assertions.h
blob: 3c45957fdd4cf89970d5d8487cebf619d4803327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*****************************************************************************/
// Copyright 2006-2007 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/

/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_assertions.h#3 $ */ 
/* $DateTime: 2012/09/05 12:31:51 $ */
/* $Change: 847652 $ */
/* $Author: tknoll $ */

/** \file
 * Conditionally compiled assertion check support.
 */

/*****************************************************************************/

#ifndef __dng_assertions__
#define __dng_assertions__

/*****************************************************************************/

#include "dng_exceptions.h"
#include "dng_flags.h"

/*****************************************************************************/

#if qDNGDebug

/// Platform-specific function to display an assert.

void dng_show_message (const char *s);

/// Show a formatted error message.

void dng_show_message_f (const char *fmt, ...);

#endif

/*****************************************************************************/

#ifndef DNG_ASSERT

#if qDNGDebug

/// Conditionally compiled macro to check an assertion and display a message if
/// it fails and assertions are compiled in via qDNGDebug
/// \param x Predicate which must be true.
/// \param y String to display if x is not true.

#define DNG_ASSERT(x,y) { if (!(x)) dng_show_message (y); }

#else

/// Conditionally compiled macro to check an assertion and display a message if
/// it fails and assertions are compiled in via qDNGDebug
/// \param x Predicate which must be true.
/// \param y String to display if x is not true.

#define DNG_ASSERT(x,y)

#endif
#endif

/*****************************************************************************/

#ifndef DNG_REQUIRE

#if qDNGDebug

/// Conditionally compiled macro to check an assertion, display a message, and throw
/// an exception if it fails and assertions are compiled in via qDNGDebug
/// \param condition Predicate which must be true.
/// \param msg String to display if condition is not true.

#define DNG_REQUIRE(condition,msg)				\
	do											\
		{										\
												\
		if (!(condition))						\
			{									\
												\
			DNG_ASSERT(condition, msg);			\
												\
			ThrowProgramError (msg);			\
												\
			}									\
												\
		}										\
	while (0)

#else

/// Conditionally compiled macro to check an assertion, display a message, and throw
/// an exception if it fails and assertions are compiled in via qDNGDebug
/// \param condition Predicate which must be true.
/// \param msg String to display if condition is not true.

#define DNG_REQUIRE(condition,msg)				\
	do											\
		{										\
												\
		if (!(condition))						\
			{									\
												\
			ThrowProgramError (msg);			\
												\
			}									\
												\
		}										\
	while (0)

#endif
#endif

/*****************************************************************************/

#ifndef DNG_REPORT

/// Macro to display an informational message
/// \param x String to display.

#define DNG_REPORT(x) DNG_ASSERT (false, x)

#endif

/*****************************************************************************/

#endif

/*****************************************************************************/