/src/exiv2/include/exiv2/error.hpp
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0-or-later |
2 | | |
3 | | /*! |
4 | | @file error.hpp |
5 | | @brief Error class for exceptions, log message class |
6 | | @author Andreas Huggel (ahu) |
7 | | <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> |
8 | | @date 15-Jan-04, ahu: created<BR> |
9 | | 11-Feb-04, ahu: isolated as a component |
10 | | */ |
11 | | #ifndef EXIV2_ERROR_HPP |
12 | | #define EXIV2_ERROR_HPP |
13 | | |
14 | | // ***************************************************************************** |
15 | | #include "exiv2lib_export.h" |
16 | | |
17 | | #include <exception> // for exception |
18 | | #include <sstream> // for operator<<, ostream, ostringstream, bas... |
19 | | #include <string> // for basic_string, string |
20 | | |
21 | | // ***************************************************************************** |
22 | | // namespace extensions |
23 | | namespace Exiv2 { |
24 | | // ***************************************************************************** |
25 | | // class definitions |
26 | | |
27 | | /*! |
28 | | @brief Class for a log message, used by the library. Applications can set |
29 | | the log level and provide a customer log message handler (callback |
30 | | function). |
31 | | |
32 | | This class is meant to be used as a temporary object with the |
33 | | related macro-magic like this: |
34 | | |
35 | | <code> |
36 | | EXV_WARNING << "Warning! Something looks fishy.\n"; |
37 | | </code> |
38 | | |
39 | | which translates to |
40 | | |
41 | | <code> |
42 | | if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) |
43 | | LogMsg(LogMsg::warn).os() << "Warning! Something looks fishy.\n"; |
44 | | </code> |
45 | | |
46 | | The macros EXV_DEBUG, EXV_INFO, EXV_WARNING and EXV_ERROR are |
47 | | shorthands and ensure efficient use of the logging facility: If a |
48 | | log message doesn't need to be generated because of the log level |
49 | | setting, the temp object is not even created. |
50 | | |
51 | | Caveat: The entire log message is not processed in this case. So don't |
52 | | make that call any logic that always needs to be executed. |
53 | | */ |
54 | | class EXIV2API LogMsg { |
55 | | public: |
56 | | //! Prevent copy-construction: not implemented. |
57 | | LogMsg(const LogMsg&) = delete; |
58 | | //! Prevent assignment: not implemented. |
59 | | LogMsg& operator=(const LogMsg&) = delete; |
60 | | /*! |
61 | | @brief Defined log levels. To suppress all log messages, either set the |
62 | | log level to \c mute or set the log message handler to 0. |
63 | | */ |
64 | | enum Level { |
65 | | debug = 0, |
66 | | info = 1, |
67 | | warn = 2, |
68 | | error = 3, |
69 | | mute = 4, |
70 | | }; |
71 | | /*! |
72 | | @brief Type for a log message handler function. The function receives |
73 | | the log level and message and can process it in an application |
74 | | specific way. The default handler sends the log message to |
75 | | standard error. |
76 | | */ |
77 | | using Handler = void (*)(int, const char*); |
78 | | |
79 | | //! @name Creators |
80 | | //@{ |
81 | | //! Constructor, takes the log message type as an argument |
82 | | explicit LogMsg(Level msgType); |
83 | | |
84 | | //! Destructor, passes the log message to the message handler depending on the log level |
85 | | ~LogMsg(); |
86 | | //@} |
87 | | |
88 | | //! @name Manipulators |
89 | | //@{ |
90 | | //! Return a reference to the ostringstream which holds the log message |
91 | | std::ostringstream& os(); |
92 | | //@} |
93 | | |
94 | | /*! |
95 | | @brief Set the log level. Only log messages with a level greater or |
96 | | equal \em level are sent to the log message handler. Default |
97 | | log level is \c warn. To suppress all log messages, set the log |
98 | | level to \c mute (or set the log message handler to 0). |
99 | | */ |
100 | | static void setLevel(Level level); |
101 | | /*! |
102 | | @brief Set the log message handler. The default handler writes log |
103 | | messages to standard error. To suppress all log messages, set |
104 | | the log message handler to 0 (or set the log level to \c mute). |
105 | | */ |
106 | | static void setHandler(Handler handler); |
107 | | //! Return the current log level |
108 | | static Level level(); |
109 | | //! Return the current log message handler |
110 | | static Handler handler(); |
111 | | //! The default log handler. Sends the log message to standard error. |
112 | | static void defaultHandler(int level, const char* s); |
113 | | |
114 | | private: |
115 | | // DATA |
116 | | // The output level. Only messages with type >= level_ will be written |
117 | | static Level level_; |
118 | | // The log handler in use |
119 | | static Handler handler_; |
120 | | // The type of this log message |
121 | | Level msgType_; |
122 | | // Holds the log message until it is passed to the message handler |
123 | | std::ostringstream os_; |
124 | | |
125 | | }; // class LogMsg |
126 | | |
127 | | // Macros for simple access |
128 | | //! Shorthand to create a temp debug log message object and return its ostringstream |
129 | | #define EXV_DEBUG \ |
130 | | if (LogMsg::debug >= LogMsg::level() && LogMsg::handler()) \ |
131 | | LogMsg(LogMsg::debug).os() |
132 | | //! Shorthand for a temp info log message object and return its ostringstream |
133 | | #define EXV_INFO \ |
134 | 3.42k | if (LogMsg::info >= LogMsg::level() && LogMsg::handler()) \ |
135 | 3.42k | LogMsg(LogMsg::info).os() |
136 | | //! Shorthand for a temp warning log message object and return its ostringstream |
137 | | #define EXV_WARNING \ |
138 | 63.9k | if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) \ |
139 | 63.9k | LogMsg(LogMsg::warn).os() |
140 | | //! Shorthand for a temp error log message object and return its ostringstream |
141 | | #define EXV_ERROR \ |
142 | 195k | if (LogMsg::error >= LogMsg::level() && LogMsg::handler()) \ |
143 | 195k | LogMsg(LogMsg::error).os() |
144 | | |
145 | | #ifdef _MSC_VER |
146 | | // Disable MSVC warnings "non - DLL-interface classkey 'identifier' used as base |
147 | | // for DLL-interface classkey 'identifier'" |
148 | | #pragma warning(disable : 4275) |
149 | | #endif |
150 | | |
151 | | //! Generalised toString function |
152 | | template <typename charT, typename T> |
153 | 7.40k | std::basic_string<charT> toBasicString(const T& arg) { |
154 | 7.40k | std::basic_ostringstream<charT> os; |
155 | 7.40k | os << arg; |
156 | 7.40k | return os.str(); |
157 | 7.40k | } std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 153 | 103 | std::basic_string<charT> toBasicString(const T& arg) { | 154 | 103 | std::basic_ostringstream<charT> os; | 155 | 103 | os << arg; | 156 | 103 | return os.str(); | 157 | 103 | } |
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, int>(int const&) Line | Count | Source | 153 | 3.46k | std::basic_string<charT> toBasicString(const T& arg) { | 154 | 3.46k | std::basic_ostringstream<charT> os; | 155 | 3.46k | os << arg; | 156 | 3.46k | return os.str(); | 157 | 3.46k | } |
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [4]>(char const (&) [4]) Line | Count | Source | 153 | 13 | std::basic_string<charT> toBasicString(const T& arg) { | 154 | 13 | std::basic_ostringstream<charT> os; | 155 | 13 | os << arg; | 156 | 13 | return os.str(); | 157 | 13 | } |
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [14]>(char const (&) [14]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [10]>(char const (&) [10]) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [5]>(char const (&) [5]) Line | Count | Source | 153 | 11 | std::basic_string<charT> toBasicString(const T& arg) { | 154 | 11 | std::basic_ostringstream<charT> os; | 155 | 11 | os << arg; | 156 | 11 | return os.str(); | 157 | 11 | } |
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [11]>(char const (&) [11]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [13]>(char const (&) [13]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, Exiv2::IfdId>(Exiv2::IfdId const&) std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char const*>(char const* const&) Line | Count | Source | 153 | 3.81k | std::basic_string<charT> toBasicString(const T& arg) { | 154 | 3.81k | std::basic_ostringstream<charT> os; | 155 | 3.81k | os << arg; | 156 | 3.81k | return os.str(); | 157 | 3.81k | } |
Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [6]>(char const (&) [6]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [33]>(char const (&) [33]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [30]>(char const (&) [30]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [38]>(char const (&) [38]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [15]>(char const (&) [15]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, unsigned int>(unsigned int const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [9]>(char const (&) [9]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [7]>(char const (&) [7]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [8]>(char const (&) [8]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [26]>(char const (&) [26]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [53]>(char const (&) [53]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [21]>(char const (&) [21]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [24]>(char const (&) [24]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [37]>(char const (&) [37]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [3]>(char const (&) [3]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [29]>(char const (&) [29]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [32]>(char const (&) [32]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [45]>(char const (&) [45]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, std::__1::basic_string_view<char, std::__1::char_traits<char> > >(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [17]>(char const (&) [17]) Unexecuted instantiation: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > Exiv2::toBasicString<char, char [61]>(char const (&) [61]) |
158 | | |
159 | | //! Complete list of all Exiv2 error codes |
160 | | enum class ErrorCode { |
161 | | kerSuccess = 0, |
162 | | kerGeneralError, |
163 | | kerErrorMessage, |
164 | | kerCallFailed, |
165 | | kerNotAnImage, |
166 | | kerInvalidDataset, |
167 | | kerInvalidRecord, |
168 | | kerInvalidKey, |
169 | | kerInvalidTag, |
170 | | kerValueNotSet, |
171 | | kerDataSourceOpenFailed, |
172 | | kerFileOpenFailed, |
173 | | kerFileContainsUnknownImageType, |
174 | | kerMemoryContainsUnknownImageType, |
175 | | kerUnsupportedImageType, |
176 | | kerFailedToReadImageData, |
177 | | kerNotAJpeg, |
178 | | kerFailedToMapFileForReadWrite, |
179 | | kerFileRenameFailed, |
180 | | kerTransferFailed, |
181 | | kerMemoryTransferFailed, |
182 | | kerInputDataReadFailed, |
183 | | kerImageWriteFailed, |
184 | | kerNoImageInInputData, |
185 | | kerInvalidIfdId, |
186 | | kerValueTooLarge, |
187 | | kerDataAreaValueTooLarge, |
188 | | kerOffsetOutOfRange, |
189 | | kerUnsupportedDataAreaOffsetType, |
190 | | kerInvalidCharset, |
191 | | kerUnsupportedDateFormat, |
192 | | kerUnsupportedTimeFormat, |
193 | | kerWritingImageFormatUnsupported, |
194 | | kerInvalidSettingForImage, |
195 | | kerNotACrwImage, |
196 | | kerFunctionNotSupported, |
197 | | kerNoNamespaceInfoForXmpPrefix, |
198 | | kerNoPrefixForNamespace, |
199 | | kerTooLargeJpegSegment, |
200 | | kerUnhandledXmpdatum, |
201 | | kerUnhandledXmpNode, |
202 | | kerXMPToolkitError, |
203 | | kerDecodeLangAltPropertyFailed, |
204 | | kerDecodeLangAltQualifierFailed, |
205 | | kerEncodeLangAltPropertyFailed, |
206 | | kerPropertyNameIdentificationFailed, |
207 | | kerSchemaNamespaceNotRegistered, |
208 | | kerNoNamespaceForPrefix, |
209 | | kerAliasesNotSupported, |
210 | | kerInvalidXmpText, |
211 | | kerTooManyTiffDirectoryEntries, |
212 | | kerMultipleTiffArrayElementTagsInDirectory, |
213 | | kerWrongTiffArrayElementTagType, |
214 | | kerInvalidKeyXmpValue, |
215 | | kerInvalidIccProfile, |
216 | | kerInvalidXMP, |
217 | | kerTiffDirectoryTooLarge, |
218 | | kerInvalidTypeValue, |
219 | | kerInvalidLangAltValue, |
220 | | kerInvalidMalloc, |
221 | | kerCorruptedMetadata, |
222 | | kerArithmeticOverflow, |
223 | | kerMallocFailed, |
224 | | kerInvalidIconvEncoding, |
225 | | kerFileAccessDisabled, |
226 | | |
227 | | kerErrorCount, |
228 | | }; |
229 | | |
230 | | /*! |
231 | | @brief Simple error class used for exceptions. An output operator is |
232 | | provided to print errors to a stream. |
233 | | */ |
234 | | class EXIV2API Error : public std::exception { |
235 | | public: |
236 | | //! @name Creators |
237 | | //@{ |
238 | | //! Constructor taking only an error code |
239 | | explicit Error(ErrorCode code); |
240 | | |
241 | | //! Constructor taking an error code and one argument |
242 | | template <typename A> |
243 | 480 | Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) { |
244 | 480 | setMsg(1); |
245 | 480 | } Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 243 | 103 | Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) { | 244 | 103 | setMsg(1); | 245 | 103 | } |
Unexecuted instantiation: Exiv2::Error::Error<int>(Exiv2::ErrorCode, int const&) Unexecuted instantiation: Exiv2::Error::Error<char [10]>(Exiv2::ErrorCode, char const (&) [10]) Exiv2::Error::Error<char [5]>(Exiv2::ErrorCode, char const (&) [5]) Line | Count | Source | 243 | 11 | Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) { | 244 | 11 | setMsg(1); | 245 | 11 | } |
Exiv2::Error::Error<char [4]>(Exiv2::ErrorCode, char const (&) [4]) Line | Count | Source | 243 | 13 | Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) { | 244 | 13 | setMsg(1); | 245 | 13 | } |
Unexecuted instantiation: Exiv2::Error::Error<char [11]>(Exiv2::ErrorCode, char const (&) [11]) Unexecuted instantiation: Exiv2::Error::Error<char [13]>(Exiv2::ErrorCode, char const (&) [13]) Unexecuted instantiation: Exiv2::Error::Error<Exiv2::IfdId>(Exiv2::ErrorCode, Exiv2::IfdId const&) Unexecuted instantiation: Exiv2::Error::Error<char [30]>(Exiv2::ErrorCode, char const (&) [30]) Unexecuted instantiation: Exiv2::Error::Error<char [38]>(Exiv2::ErrorCode, char const (&) [38]) Unexecuted instantiation: Exiv2::Error::Error<char [15]>(Exiv2::ErrorCode, char const (&) [15]) Unexecuted instantiation: Exiv2::Error::Error<char [9]>(Exiv2::ErrorCode, char const (&) [9]) Unexecuted instantiation: Exiv2::Error::Error<char [26]>(Exiv2::ErrorCode, char const (&) [26]) Unexecuted instantiation: Exiv2::Error::Error<char [53]>(Exiv2::ErrorCode, char const (&) [53]) Unexecuted instantiation: Exiv2::Error::Error<char [21]>(Exiv2::ErrorCode, char const (&) [21]) Unexecuted instantiation: Exiv2::Error::Error<char [24]>(Exiv2::ErrorCode, char const (&) [24]) Unexecuted instantiation: Exiv2::Error::Error<char [37]>(Exiv2::ErrorCode, char const (&) [37]) Exiv2::Error::Error<char const*>(Exiv2::ErrorCode, char const* const&) Line | Count | Source | 243 | 353 | Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1)) { | 244 | 353 | setMsg(1); | 245 | 353 | } |
Unexecuted instantiation: Exiv2::Error::Error<char [29]>(Exiv2::ErrorCode, char const (&) [29]) Unexecuted instantiation: Exiv2::Error::Error<char [17]>(Exiv2::ErrorCode, char const (&) [17]) Unexecuted instantiation: Exiv2::Error::Error<char [61]>(Exiv2::ErrorCode, char const (&) [61]) Unexecuted instantiation: Exiv2::Error::Error<char [45]>(Exiv2::ErrorCode, char const (&) [45]) |
246 | | |
247 | | //! Constructor taking an error code and two arguments |
248 | | template <typename A, typename B> |
249 | | Error(ErrorCode code, const A& arg1, const B& arg2) : |
250 | 3.46k | code_(code), arg1_(toBasicString<char>(arg1)), arg2_(toBasicString<char>(arg2)) { |
251 | 3.46k | setMsg(2); |
252 | 3.46k | } Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: Exiv2::Error::Error<char [14], char [4]>(Exiv2::ErrorCode, char const (&) [14], char const (&) [4]) Unexecuted instantiation: Exiv2::Error::Error<char [14], char [10]>(Exiv2::ErrorCode, char const (&) [14], char const (&) [10]) Unexecuted instantiation: Exiv2::Error::Error<char [14], char [5]>(Exiv2::ErrorCode, char const (&) [14], char const (&) [5]) Unexecuted instantiation: Exiv2::Error::Error<char const*, char [6]>(Exiv2::ErrorCode, char const* const&, char const (&) [6]) Unexecuted instantiation: Exiv2::Error::Error<int, char [33]>(Exiv2::ErrorCode, int const&, char const (&) [33]) Exiv2::Error::Error<int, char const*>(Exiv2::ErrorCode, int const&, char const* const&) Line | Count | Source | 250 | 3.46k | code_(code), arg1_(toBasicString<char>(arg1)), arg2_(toBasicString<char>(arg2)) { | 251 | 3.46k | setMsg(2); | 252 | 3.46k | } |
Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, unsigned int>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int const&) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const* const&) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Exiv2::IfdId>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Exiv2::IfdId const&) Unexecuted instantiation: Exiv2::Error::Error<char [13], char [5]>(Exiv2::ErrorCode, char const (&) [13], char const (&) [5]) Unexecuted instantiation: Exiv2::Error::Error<char [32], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, char const (&) [32], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: Exiv2::Error::Error<char [30], char const*>(Exiv2::ErrorCode, char const (&) [30], char const* const&) Unexecuted instantiation: Exiv2::Error::Error<char [45], std::__1::basic_string_view<char, std::__1::char_traits<char> > >(Exiv2::ErrorCode, char const (&) [45], std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) |
253 | | |
254 | | //! Constructor taking an error code and three arguments |
255 | | template <typename A, typename B, typename C> |
256 | | Error(ErrorCode code, const A& arg1, const B& arg2, const C& arg3) : |
257 | 0 | code_(code), |
258 | 0 | arg1_(toBasicString<char>(arg1)), |
259 | 0 | arg2_(toBasicString<char>(arg2)), |
260 | 0 | arg3_(toBasicString<char>(arg3)) { |
261 | 0 | setMsg(3); |
262 | 0 | } Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [4], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [4], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [7]>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [7]) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [5]>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [5]) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [11]>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [11]) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [8]>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [8]) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [3], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: Exiv2::Error::Error<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char [13]>(Exiv2::ErrorCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [13]) |
263 | | |
264 | | //! @name Accessors |
265 | | //@{ |
266 | | [[nodiscard]] ErrorCode code() const noexcept; |
267 | | /*! |
268 | | @brief Return the error message as a C-string. The pointer returned by what() |
269 | | is valid only as long as the BasicError object exists. |
270 | | */ |
271 | | [[nodiscard]] const char* what() const noexcept override; |
272 | | //@} |
273 | | |
274 | | private: |
275 | | //! @name Manipulators |
276 | | //@{ |
277 | | //! Assemble the error message from the arguments |
278 | | void setMsg(int count); |
279 | | //@} |
280 | | |
281 | | // DATA |
282 | | ErrorCode code_; //!< Error code |
283 | | std::string arg1_; //!< First argument |
284 | | std::string arg2_; //!< Second argument |
285 | | std::string arg3_; //!< Third argument |
286 | | std::string msg_; //!< Complete error message |
287 | | }; |
288 | | |
289 | | //! %Error output operator |
290 | 3.46k | inline std::ostream& operator<<(std::ostream& os, const Error& error) { |
291 | 3.46k | return os << error.what(); |
292 | 3.46k | } |
293 | | |
294 | | #ifdef _MSC_VER |
295 | | #pragma warning(default : 4275) |
296 | | #endif |
297 | | |
298 | | } // namespace Exiv2 |
299 | | #endif // EXIV2_ERROR_HPP |