File indexing completed on 2025-01-19 03:54:52
0001 /*****************************************************************************/ 0002 // Copyright 2006-2019 Adobe Systems Incorporated 0003 // All Rights Reserved. 0004 // 0005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 0006 // accordance with the terms of the Adobe license agreement accompanying it. 0007 /*****************************************************************************/ 0008 0009 /** \file 0010 * Conditionally compiled assertion check support. 0011 */ 0012 0013 /*****************************************************************************/ 0014 0015 #ifndef __dng_assertions__ 0016 #define __dng_assertions__ 0017 0018 /*****************************************************************************/ 0019 0020 #include "dng_exceptions.h" 0021 #include "dng_flags.h" 0022 0023 /*****************************************************************************/ 0024 0025 #if qDNGDebug 0026 0027 /// Platform-specific function to display an assert. 0028 0029 void dng_show_message (const char *s); 0030 0031 /// Show a formatted error message. 0032 0033 void dng_show_message_f (const char *fmt, ...); 0034 0035 #endif 0036 0037 /*****************************************************************************/ 0038 0039 #ifndef DNG_ASSERT 0040 0041 #if qDNGDebug 0042 0043 /// Conditionally compiled macro to check an assertion and display a message if 0044 /// it fails and assertions are compiled in via qDNGDebug 0045 /// \param x Predicate which must be true. 0046 /// \param y String to display if x is not true. 0047 0048 #define DNG_ASSERT(x,y) { if (!(x)) dng_show_message (y); } 0049 0050 #else 0051 0052 /// Conditionally compiled macro to check an assertion and display a message if 0053 /// it fails and assertions are compiled in via qDNGDebug 0054 /// \param x Predicate which must be true. 0055 /// \param y String to display if x is not true. 0056 0057 #define DNG_ASSERT(x,y) 0058 0059 #endif 0060 #endif 0061 0062 /*****************************************************************************/ 0063 0064 #ifndef DNG_REQUIRE 0065 0066 #if qDNGDebug 0067 0068 /// Conditionally compiled macro to check an assertion, display a message, and throw 0069 /// an exception if it fails and assertions are compiled in via qDNGDebug 0070 /// \param condition Predicate which must be true. 0071 /// \param msg String to display if condition is not true. 0072 0073 #define DNG_REQUIRE(condition,msg) \ 0074 do \ 0075 { \ 0076 \ 0077 if (!(condition)) \ 0078 { \ 0079 \ 0080 DNG_ASSERT(condition, msg); \ 0081 \ 0082 ThrowProgramError (msg); \ 0083 \ 0084 } \ 0085 \ 0086 } \ 0087 while (0) 0088 0089 #else 0090 0091 /// Conditionally compiled macro to check an assertion, display a message, and throw 0092 /// an exception if it fails and assertions are compiled in via qDNGDebug 0093 /// \param condition Predicate which must be true. 0094 /// \param msg String to display if condition is not true. 0095 0096 #define DNG_REQUIRE(condition,msg) \ 0097 do \ 0098 { \ 0099 \ 0100 if (!(condition)) \ 0101 { \ 0102 \ 0103 ThrowProgramError (msg); \ 0104 \ 0105 } \ 0106 \ 0107 } \ 0108 while (0) 0109 0110 #endif 0111 #endif 0112 0113 /*****************************************************************************/ 0114 0115 #ifndef DNG_REPORT 0116 0117 /// Macro to display an informational message 0118 /// \param x String to display. 0119 0120 #define DNG_REPORT(x) DNG_ASSERT (false, x) 0121 0122 #endif 0123 0124 /*****************************************************************************/ 0125 0126 #endif 0127 0128 /*****************************************************************************/