/src/skia/third_party/externals/dng_sdk/source/dng_exceptions.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*****************************************************************************/ |
2 | | // Copyright 2006-2007 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 | | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_exceptions.h#1 $ */ |
10 | | /* $DateTime: 2012/05/30 13:28:51 $ */ |
11 | | /* $Change: 832332 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /** \file |
15 | | * C++ exception support for DNG SDK. |
16 | | */ |
17 | | |
18 | | /*****************************************************************************/ |
19 | | |
20 | | #ifndef __dng_exceptions__ |
21 | | #define __dng_exceptions__ |
22 | | |
23 | | /*****************************************************************************/ |
24 | | |
25 | | #include "dng_errors.h" |
26 | | #include "dng_flags.h" |
27 | | |
28 | | /*****************************************************************************/ |
29 | | |
30 | | /// Display a warning message. Note that this may just eat the message. |
31 | | |
32 | | void ReportWarning (const char *message, |
33 | | const char *sub_message = NULL); |
34 | | |
35 | | /*****************************************************************************/ |
36 | | |
37 | | /// Display an error message. Note that this may just eat the message. |
38 | | |
39 | | void ReportError (const char *message, |
40 | | const char *sub_message = NULL); |
41 | | |
42 | | /*****************************************************************************/ |
43 | | |
44 | | /// \brief All exceptions thrown by the DNG SDK use this exception class. |
45 | | |
46 | | class dng_exception |
47 | | { |
48 | | |
49 | | private: |
50 | | |
51 | | dng_error_code fErrorCode; |
52 | | |
53 | | public: |
54 | | |
55 | | /// Construct an exception representing the given error code. |
56 | | /// \param code Error code this exception is for. |
57 | | |
58 | | dng_exception (dng_error_code code) |
59 | | |
60 | | : fErrorCode (code) |
61 | | |
62 | 19.9k | { |
63 | 19.9k | } |
64 | | |
65 | | virtual ~dng_exception () |
66 | 19.9k | { |
67 | 19.9k | } |
68 | | |
69 | | /// Getter for error code of this exception |
70 | | /// \retval The error code of this exception. |
71 | | |
72 | | dng_error_code ErrorCode () const |
73 | 0 | { |
74 | 0 | return fErrorCode; |
75 | 0 | } |
76 | | |
77 | | }; |
78 | | |
79 | | /******************************************************************************/ |
80 | | |
81 | | /// \brief Throw an exception based on an arbitrary error code. |
82 | | |
83 | | void Throw_dng_error (dng_error_code err, |
84 | | const char * message = NULL, |
85 | | const char * sub_message = NULL, |
86 | | bool silent = false); |
87 | | |
88 | | /******************************************************************************/ |
89 | | |
90 | | /// \brief Convenience function to throw dng_exception with error code if |
91 | | /// error_code is not dng_error_none . |
92 | | |
93 | | inline void Fail_dng_error (dng_error_code err) |
94 | 0 | { |
95 | 0 | |
96 | 0 | if (err != dng_error_none) |
97 | 0 | { |
98 | 0 | |
99 | 0 | Throw_dng_error (err); |
100 | 0 | |
101 | 0 | } |
102 | 0 | |
103 | 0 | } |
104 | | |
105 | | /*****************************************************************************/ |
106 | | |
107 | | /// \brief Convenience function to throw dng_exception with error code |
108 | | /// dng_error_unknown . |
109 | | |
110 | | inline void ThrowProgramError (const char * sub_message = NULL) |
111 | 2.43k | { |
112 | | |
113 | 2.43k | Throw_dng_error (dng_error_unknown, NULL, sub_message); |
114 | | |
115 | 2.43k | } |
116 | | |
117 | | /*****************************************************************************/ |
118 | | |
119 | | /// \brief Convenience function to throw dng_exception with error code |
120 | | /// dng_error_not_yet_implemented . |
121 | | |
122 | | inline void ThrowNotYetImplemented (const char * sub_message = NULL) |
123 | 0 | { |
124 | | |
125 | 0 | Throw_dng_error (dng_error_not_yet_implemented, NULL, sub_message); |
126 | | |
127 | 0 | } |
128 | | |
129 | | /*****************************************************************************/ |
130 | | |
131 | | /// \brief Convenience function to throw dng_exception with error code |
132 | | /// dng_error_silent . |
133 | | |
134 | | inline void ThrowSilentError () |
135 | 0 | { |
136 | 0 | |
137 | 0 | Throw_dng_error (dng_error_silent); |
138 | 0 | |
139 | 0 | } |
140 | | |
141 | | /*****************************************************************************/ |
142 | | |
143 | | /// \brief Convenience function to throw dng_exception with error code |
144 | | /// dng_error_user_canceled . |
145 | | |
146 | | inline void ThrowUserCanceled () |
147 | 0 | { |
148 | 0 | |
149 | 0 | Throw_dng_error (dng_error_user_canceled); |
150 | 0 | |
151 | 0 | } |
152 | | |
153 | | /*****************************************************************************/ |
154 | | |
155 | | /// \brief Convenience function to throw dng_exception with error code |
156 | | /// dng_error_host_insufficient . |
157 | | |
158 | | inline void ThrowHostInsufficient (const char * sub_message = NULL) |
159 | 0 | { |
160 | 0 | |
161 | 0 | Throw_dng_error (dng_error_host_insufficient, NULL, sub_message); |
162 | 0 | |
163 | 0 | } |
164 | | |
165 | | /*****************************************************************************/ |
166 | | |
167 | | /// \brief Convenience function to throw dng_exception with error code |
168 | | /// dng_error_memory . |
169 | | |
170 | | inline void ThrowMemoryFull (const char * sub_message = NULL) |
171 | 10 | { |
172 | | |
173 | 10 | Throw_dng_error (dng_error_memory, NULL, sub_message); |
174 | | |
175 | 10 | } |
176 | | |
177 | | /*****************************************************************************/ |
178 | | |
179 | | /// \brief Convenience function to throw dng_exception with error code |
180 | | /// dng_error_bad_format . |
181 | | |
182 | | inline void ThrowBadFormat (const char * sub_message = NULL) |
183 | 38 | { |
184 | | |
185 | 38 | Throw_dng_error (dng_error_bad_format, NULL, sub_message); |
186 | | |
187 | 38 | } |
188 | | |
189 | | /*****************************************************************************/ |
190 | | |
191 | | /// \brief Convenience function to throw dng_exception with error code |
192 | | /// dng_error_matrix_math . |
193 | | |
194 | | inline void ThrowMatrixMath (const char * sub_message = NULL) |
195 | 10 | { |
196 | | |
197 | 10 | Throw_dng_error (dng_error_matrix_math, NULL, sub_message); |
198 | | |
199 | 10 | } |
200 | | |
201 | | /*****************************************************************************/ |
202 | | |
203 | | /// \brief Convenience function to throw dng_exception with error code |
204 | | /// dng_error_open_file . |
205 | | |
206 | | inline void ThrowOpenFile (const char * sub_message = NULL, bool silent = false) |
207 | 0 | { |
208 | 0 | |
209 | 0 | Throw_dng_error (dng_error_open_file, NULL, sub_message, silent); |
210 | 0 | |
211 | 0 | } |
212 | | |
213 | | /*****************************************************************************/ |
214 | | |
215 | | /// \brief Convenience function to throw dng_exception with error code |
216 | | /// dng_error_read_file . |
217 | | |
218 | | inline void ThrowReadFile (const char *sub_message = NULL) |
219 | 0 | { |
220 | 0 | |
221 | 0 | Throw_dng_error (dng_error_read_file, NULL, sub_message); |
222 | 0 | |
223 | 0 | } |
224 | | |
225 | | /*****************************************************************************/ |
226 | | |
227 | | /// \brief Convenience function to throw dng_exception with error code |
228 | | /// dng_error_write_file . |
229 | | |
230 | | inline void ThrowWriteFile (const char *sub_message = NULL) |
231 | 0 | { |
232 | 0 | |
233 | 0 | Throw_dng_error (dng_error_write_file, NULL, sub_message); |
234 | 0 | |
235 | 0 | } |
236 | | |
237 | | /*****************************************************************************/ |
238 | | |
239 | | /// \brief Convenience function to throw dng_exception with error code |
240 | | /// dng_error_end_of_file . |
241 | | |
242 | | inline void ThrowEndOfFile (const char *sub_message = NULL) |
243 | 17.1k | { |
244 | | |
245 | 17.1k | Throw_dng_error (dng_error_end_of_file, NULL, sub_message); |
246 | | |
247 | 17.1k | } |
248 | | |
249 | | /*****************************************************************************/ |
250 | | |
251 | | /// \brief Convenience function to throw dng_exception with error code |
252 | | /// dng_error_file_is_damaged . |
253 | | |
254 | | inline void ThrowFileIsDamaged () |
255 | 0 | { |
256 | 0 | |
257 | 0 | Throw_dng_error (dng_error_file_is_damaged); |
258 | 0 | |
259 | 0 | } |
260 | | |
261 | | /*****************************************************************************/ |
262 | | |
263 | | /// \brief Convenience function to throw dng_exception with error code |
264 | | /// dng_error_image_too_big_dng . |
265 | | |
266 | | inline void ThrowImageTooBigDNG () |
267 | 0 | { |
268 | | |
269 | 0 | Throw_dng_error (dng_error_image_too_big_dng); |
270 | | |
271 | 0 | } |
272 | | |
273 | | /*****************************************************************************/ |
274 | | |
275 | | /// \brief Convenience function to throw dng_exception with error code |
276 | | /// dng_error_image_too_big_tiff . |
277 | | |
278 | | inline void ThrowImageTooBigTIFF () |
279 | 0 | { |
280 | | |
281 | 0 | Throw_dng_error (dng_error_image_too_big_tiff); |
282 | | |
283 | 0 | } |
284 | | |
285 | | /*****************************************************************************/ |
286 | | |
287 | | /// \brief Convenience function to throw dng_exception with error code |
288 | | /// dng_error_unsupported_dng . |
289 | | |
290 | | inline void ThrowUnsupportedDNG () |
291 | 249 | { |
292 | | |
293 | 249 | Throw_dng_error (dng_error_unsupported_dng); |
294 | | |
295 | 249 | } |
296 | | |
297 | | /*****************************************************************************/ |
298 | | |
299 | | #endif |
300 | | |
301 | | /*****************************************************************************/ |