comparison Framework/StoneException.h @ 860:238693c3bc51 am-dev

merge default -> am-dev
author Alain Mazy <alain@mazy.be>
date Mon, 24 Jun 2019 14:35:00 +0200
parents 101073b3e855
children 1091b2adeb5a
comparison
equal deleted inserted replaced
856:a6e17a5a39e7 860:238693c3bc51
113 113
114 } 114 }
115 115
116 // See https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-multi-stmts 116 // See https://isocpp.org/wiki/faq/misc-technical-issues#macros-with-multi-stmts
117 // (or google "Multiple lines macro C++ faq lite" if link is dead) 117 // (or google "Multiple lines macro C++ faq lite" if link is dead)
118 #define ORTHANC_ASSERT(cond,streamChainMessage) \ 118 #define ORTHANC_ASSERT2(cond,streamChainMessage) \
119 if (!(cond)) { \ 119 if (!(cond)) { \
120 std::stringstream sst; \ 120 std::stringstream sst; \
121 sst << "Assertion failed. Condition = \"" #cond "\" Message = \"" << streamChainMessage << "\""; \ 121 sst << "Assertion failed. Condition = \"" #cond "\" Message = \"" << streamChainMessage << "\""; \
122 std::string sstr = sst.str(); \ 122 std::string sstr = sst.str(); \
123 throw OrthancException(ErrorCode_InternalError,sstr.c_str()); \ 123 throw ::Orthanc::OrthancException(::Orthanc::ErrorCode_InternalError,sstr.c_str()); \
124 } else (void)0 124 } else (void)0
125 125
126 #define ORTHANC_ASSERT1(cond) \
127 if (!(cond)) { \
128 std::stringstream sst; \
129 sst << "Assertion failed. Condition = \"" #cond "\""; \
130 std::string sstr = sst.str(); \
131 throw ::Orthanc::OrthancException(::Orthanc::ErrorCode_InternalError,sstr.c_str()); \
132 } else (void)0
133
134 # define ORTHANC_EXPAND( x ) x
135 # define GET_ORTHANC_ASSERT(_1,_2,NAME,...) NAME
136 # define ORTHANC_ASSERT(...) ORTHANC_EXPAND(GET_ORTHANC_ASSERT(__VA_ARGS__, ORTHANC_ASSERT2, ORTHANC_ASSERT1, UNUSED)(__VA_ARGS__))
137
138 /*
139 Explanation:
140
141 ORTHANC_ASSERT(a)
142 ORTHANC_EXPAND(GET_ORTHANC_ASSERT(a, ORTHANC_ASSERT2, ORTHANC_ASSERT1, UNUSED)(a))
143 ORTHANC_EXPAND(ORTHANC_ASSERT1(a))
144 ORTHANC_ASSERT1(a)
145
146 ORTHANC_ASSERT(a,b)
147 ORTHANC_EXPAND(GET_ORTHANC_ASSERT(a, b, ORTHANC_ASSERT2, ORTHANC_ASSERT1, UNUSED)(a,b))
148 ORTHANC_EXPAND(ORTHANC_ASSERT2(a,b))
149 ORTHANC_ASSERT2(a,b)
150
151 Note: ORTHANC_EXPAND is required for some older compilers (MS v100 cl.exe )
152 */
153
154
155
156
157
158