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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*****************************************************************************/
// 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_exceptions.h#1 $ */
/* $DateTime: 2012/05/30 13:28:51 $ */
/* $Change: 832332 $ */
/* $Author: tknoll $ */
/** \file
* C++ exception support for DNG SDK.
*/
/*****************************************************************************/
#ifndef __dng_exceptions__
#define __dng_exceptions__
/*****************************************************************************/
#include "dng_errors.h"
#include "dng_flags.h"
/*****************************************************************************/
/// Display a warning message. Note that this may just eat the message.
void ReportWarning (const char *message,
const char *sub_message = NULL);
/*****************************************************************************/
/// Display an error message. Note that this may just eat the message.
void ReportError (const char *message,
const char *sub_message = NULL);
/*****************************************************************************/
/// \brief All exceptions thrown by the DNG SDK use this exception class.
class dng_exception
{
private:
dng_error_code fErrorCode;
public:
/// Construct an exception representing the given error code.
/// \param code Error code this exception is for.
dng_exception (dng_error_code code)
: fErrorCode (code)
{
}
virtual ~dng_exception ()
{
}
/// Getter for error code of this exception
/// \retval The error code of this exception.
dng_error_code ErrorCode () const
{
return fErrorCode;
}
};
/******************************************************************************/
/// \brief Throw an exception based on an arbitrary error code.
void Throw_dng_error (dng_error_code err,
const char * message = NULL,
const char * sub_message = NULL,
bool silent = false);
/******************************************************************************/
/// \brief Convenience function to throw dng_exception with error code if
/// error_code is not dng_error_none .
inline void Fail_dng_error (dng_error_code err)
{
if (err != dng_error_none)
{
Throw_dng_error (err);
}
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_unknown .
inline void ThrowProgramError (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_unknown, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_not_yet_implemented .
inline void ThrowNotYetImplemented (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_not_yet_implemented, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_silent .
inline void ThrowSilentError ()
{
Throw_dng_error (dng_error_silent);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_user_canceled .
inline void ThrowUserCanceled ()
{
Throw_dng_error (dng_error_user_canceled);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_host_insufficient .
inline void ThrowHostInsufficient (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_host_insufficient, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_memory .
inline void ThrowMemoryFull (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_memory, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_bad_format .
inline void ThrowBadFormat (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_bad_format, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_matrix_math .
inline void ThrowMatrixMath (const char * sub_message = NULL)
{
Throw_dng_error (dng_error_matrix_math, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_open_file .
inline void ThrowOpenFile (const char * sub_message = NULL, bool silent = false)
{
Throw_dng_error (dng_error_open_file, NULL, sub_message, silent);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_read_file .
inline void ThrowReadFile (const char *sub_message = NULL)
{
Throw_dng_error (dng_error_read_file, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_write_file .
inline void ThrowWriteFile (const char *sub_message = NULL)
{
Throw_dng_error (dng_error_write_file, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_end_of_file .
inline void ThrowEndOfFile (const char *sub_message = NULL)
{
Throw_dng_error (dng_error_end_of_file, NULL, sub_message);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_file_is_damaged .
inline void ThrowFileIsDamaged ()
{
Throw_dng_error (dng_error_file_is_damaged);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_image_too_big_dng .
inline void ThrowImageTooBigDNG ()
{
Throw_dng_error (dng_error_image_too_big_dng);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_image_too_big_tiff .
inline void ThrowImageTooBigTIFF ()
{
Throw_dng_error (dng_error_image_too_big_tiff);
}
/*****************************************************************************/
/// \brief Convenience function to throw dng_exception with error code
/// dng_error_unsupported_dng .
inline void ThrowUnsupportedDNG ()
{
Throw_dng_error (dng_error_unsupported_dng);
}
/*****************************************************************************/
#endif
/*****************************************************************************/
|