-
-#### werror-test
-
-```
-Usage: werror-test
-```
-
-Simple tests for the wide-string error class WError
-
-[Sample](#TOC1) Programs [Test](#TOC2) Programs
-
#### write-test
@@ -664,4 +651,4 @@ Read an XMP packet from a file, parse and re-serialize it.
Robin Mills
robin@clanmills.com
-Revised: 2021-09-21
\ No newline at end of file
+Revised: 2021-09-21
diff --git a/app/actions.cpp b/app/actions.cpp
index 83b505d79d..7221bcbc81 100644
--- a/app/actions.cpp
+++ b/app/actions.cpp
@@ -220,7 +220,7 @@ namespace Action {
}
return rc;
}
- catch(const Exiv2::AnyError& e) {
+ catch(const Exiv2::Error& e) {
std::cerr << "Exiv2 exception in print action for file "
<< path << ":\n" << e << "\n";
return 1;
@@ -684,7 +684,7 @@ namespace Action {
}
return rc;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in rename action for file " << path
<< ":\n" << e << "\n";
@@ -744,7 +744,7 @@ namespace Action {
return rc;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in erase action for file " << path
<< ":\n" << e << "\n";
@@ -854,7 +854,7 @@ namespace Action {
rc = metacopy(path_, exvPath, Exiv2::ImageType::exv, false);
}
return rc;
- } catch (const Exiv2::AnyError& e) {
+ } catch (const Exiv2::Error& e) {
std::cerr << "Exiv2 exception in extract action for file " << path << ":\n" << e << "\n";
return 1;
}
@@ -1050,7 +1050,7 @@ namespace Action {
if (Params::instance().preserve_) ts.touch(path);
return rc;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in insert action for file " << path
<< ":\n" << e << "\n";
@@ -1201,7 +1201,7 @@ namespace Action {
return rc;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in modify action for file " << path
<< ":\n" << e << "\n";
@@ -1440,7 +1440,7 @@ namespace Action {
}
return rc?1:0;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in adjust action for file " << path
<< ":\n" << e << "\n";
@@ -1576,7 +1576,7 @@ namespace Action {
return 0;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in fixiso action for file " << path
<< ":\n" << e << "\n";
@@ -1642,7 +1642,7 @@ namespace Action {
return 0;
}
- catch(const Exiv2::AnyError& e)
+ catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in fixcom action for file " << path
<< ":\n" << e << "\n";
@@ -1886,7 +1886,7 @@ namespace {
targetImage->writeMetadata();
rc=0;
}
- catch (const Exiv2::AnyError& e) {
+ catch (const Exiv2::Error& e) {
std::cerr << tgt <<
": " << _("Could not write metadata to file") << ": " << e << "\n";
rc=1;
diff --git a/app/exiv2.cpp b/app/exiv2.cpp
index ee32960c28..45797784de 100644
--- a/app/exiv2.cpp
+++ b/app/exiv2.cpp
@@ -1316,7 +1316,7 @@ namespace {
}
}
}
- catch (const Exiv2::AnyError& error) {
+ catch (const Exiv2::Error& error) {
std::cerr << filename << ", " << _("line") << " " << error << "\n";
return false;
}
@@ -1337,7 +1337,7 @@ namespace {
}
return true;
}
- catch (const Exiv2::AnyError& error) {
+ catch (const Exiv2::Error& error) {
std::cerr << _("-M option") << " " << error << "\n";
return false;
}
@@ -1385,14 +1385,14 @@ namespace {
cmdLine += std::string(" ") + formatArg(__argv[i]) ;
}
#endif
- throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line:") + cmdLine);
}
std::string cmd(line.substr(cmdStart, cmdEnd-cmdStart));
CmdId cmdId = commandId(cmd);
if (cmdId == invalidCmdId) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command") + " `" + cmd + "'");
}
@@ -1406,14 +1406,14 @@ namespace {
defaultType = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(),
iptcKey.record());
}
- catch (const Exiv2::AnyError&) {}
+ catch (const Exiv2::Error&) {}
if (metadataId == invalidMetadataId) {
try {
Exiv2::ExifKey exifKey(key);
metadataId = exif;
defaultType = exifKey.defaultTypeId();
}
- catch (const Exiv2::AnyError&) {}
+ catch (const Exiv2::Error&) {}
}
if (metadataId == invalidMetadataId) {
try {
@@ -1421,10 +1421,10 @@ namespace {
metadataId = xmp;
defaultType = Exiv2::XmpProperties::propertyType(xmpKey);
}
- catch (const Exiv2::AnyError&) {}
+ catch (const Exiv2::Error&) {}
}
if (metadataId == invalidMetadataId) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid key") + " `" + key + "'");
}
}
@@ -1444,7 +1444,7 @@ namespace {
if ( cmdId == reg
&& ( keyEnd == std::string::npos
|| valStart == std::string::npos)) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line") + " " );
}
@@ -1456,7 +1456,7 @@ namespace {
if (tmpType != Exiv2::invalidTypeId) {
valStart = line.find_first_not_of(delim, typeEnd+1);
if (valStart == std::string::npos) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line") + " " );
}
type = tmpType;
@@ -1483,7 +1483,7 @@ namespace {
if (cmdId == reg) {
if (value.empty()) {
- throw Exiv2::Error(Exiv2::kerErrorMessage,
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage,
Exiv2::toString(num) + ": " + _("Empty value for key") + + " `" + key + "'");
}
diff --git a/include/exiv2/bmpimage.hpp b/include/exiv2/bmpimage.hpp
index 36b9d9b354..fc2887d063 100644
--- a/include/exiv2/bmpimage.hpp
+++ b/include/exiv2/bmpimage.hpp
@@ -56,16 +56,16 @@ namespace Exiv2 {
//@{
void readMetadata() override;
- /// @throws Error(kerWritingImageFormatUnsupported).
+ /// @throws Error(ErrorCode::kerWritingImageFormatUnsupported).
void writeMetadata() override;
- /// @throws Error(kerInvalidSettingForImage)
+ /// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setExifData(const ExifData& exifData) override;
- /// @throws Error(kerInvalidSettingForImage)
+ /// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setIptcData(const IptcData& iptcData) override;
- /// @throws Error(kerInvalidSettingForImage)
+ /// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/cr2image.hpp b/include/exiv2/cr2image.hpp
index 16399d0a96..6bcdb7a102 100644
--- a/include/exiv2/cr2image.hpp
+++ b/include/exiv2/cr2image.hpp
@@ -60,7 +60,7 @@ namespace Exiv2 {
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
/*!
@brief Not supported. CR2 format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/crwimage.hpp b/include/exiv2/crwimage.hpp
index aa15c10280..21a917fad9 100644
--- a/include/exiv2/crwimage.hpp
+++ b/include/exiv2/crwimage.hpp
@@ -61,7 +61,7 @@ namespace Exiv2 {
void writeMetadata() override;
/*!
@brief Not supported. CRW format does not contain IPTC metadata.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
//@}
diff --git a/include/exiv2/epsimage.hpp b/include/exiv2/epsimage.hpp
index 36b3d5c1b2..71177ca1e8 100644
--- a/include/exiv2/epsimage.hpp
+++ b/include/exiv2/epsimage.hpp
@@ -61,7 +61,7 @@ namespace Exiv2
void writeMetadata() override;
/*!
@brief Not supported.
- Calling this function will throw an instance of Error(kerInvalidSettingForImage).
+ Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp
index 863e73bcd7..affc3423bb 100644
--- a/include/exiv2/error.hpp
+++ b/include/exiv2/error.hpp
@@ -22,10 +22,10 @@
// *****************************************************************************
// namespace extensions
-namespace Exiv2 {
-
-// *****************************************************************************
-// class definitions
+namespace Exiv2
+{
+ // *****************************************************************************
+ // class definitions
/*!
@brief Class for a log message, used by the library. Applications can set
@@ -54,7 +54,8 @@ namespace Exiv2 {
Caveat: The entire log message is not processed in this case. So don't
make that call any logic that always needs to be executed.
*/
- class EXIV2API LogMsg {
+ class EXIV2API LogMsg
+ {
public:
//! Prevent copy-construction: not implemented.
LogMsg(const LogMsg&) = delete;
@@ -64,7 +65,14 @@ namespace Exiv2 {
@brief Defined log levels. To suppress all log messages, either set the
log level to \c mute or set the log message handler to 0.
*/
- enum Level { debug = 0, info = 1, warn = 2, error = 3, mute = 4 };
+ enum Level
+ {
+ debug = 0,
+ info = 1,
+ warn = 2,
+ error = 3,
+ mute = 4
+ };
/*!
@brief Type for a log message handler function. The function receives
the log level and message and can process it in an application
@@ -119,26 +127,34 @@ namespace Exiv2 {
// Holds the log message until it is passed to the message handler
std::ostringstream os_;
- }; // class LogMsg
+ }; // class LogMsg
// Macros for simple access
//! Shorthand to create a temp debug log message object and return its ostringstream
-#define EXV_DEBUG if (LogMsg::debug >= LogMsg::level() && LogMsg::handler()) LogMsg(LogMsg::debug).os()
+#define EXV_DEBUG \
+ if (LogMsg::debug >= LogMsg::level() && LogMsg::handler()) \
+ LogMsg(LogMsg::debug).os()
//! Shorthand for a temp info log message object and return its ostringstream
-#define EXV_INFO if (LogMsg::info >= LogMsg::level() && LogMsg::handler()) LogMsg(LogMsg::info).os()
+#define EXV_INFO \
+ if (LogMsg::info >= LogMsg::level() && LogMsg::handler()) \
+ LogMsg(LogMsg::info).os()
//! Shorthand for a temp warning log message object and return its ostringstream
-#define EXV_WARNING if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) LogMsg(LogMsg::warn).os()
+#define EXV_WARNING \
+ if (LogMsg::warn >= LogMsg::level() && LogMsg::handler()) \
+ LogMsg(LogMsg::warn).os()
//! Shorthand for a temp error log message object and return its ostringstream
-#define EXV_ERROR if (LogMsg::error >= LogMsg::level() && LogMsg::handler()) LogMsg(LogMsg::error).os()
+#define EXV_ERROR \
+ if (LogMsg::error >= LogMsg::level() && LogMsg::handler()) \
+ LogMsg(LogMsg::error).os()
#ifdef _MSC_VER
// Disable MSVC warnings "non - DLL-interface classkey 'identifier' used as base
// for DLL-interface classkey 'identifier'"
-# pragma warning( disable : 4275 )
+#pragma warning(disable : 4275)
#endif
//! Generalised toString function
- template
+ template
std::basic_string toBasicString(const T& arg)
{
std::basic_ostringstream os;
@@ -146,33 +162,11 @@ namespace Exiv2 {
return os.str();
}
- /*!
- @brief Error class interface. Allows the definition and use of a hierarchy
- of error classes which can all be handled in one catch block.
- Inherits from the standard exception base-class, to make life
- easier for library users (they have the option of catching most
- things via std::exception).
- */
- class EXIV2API AnyError : public std::exception {
- public:
- AnyError() = default;
- AnyError(const AnyError& o) = default;
-
- ~AnyError() noexcept override = default;
- ///@brief Return the error code.
- virtual int code() const noexcept = 0;
- };
-
- //! %AnyError output operator
- inline std::ostream& operator<<(std::ostream& os, const AnyError& error)
- {
- return os << error.what();
- }
-
//! Complete list of all Exiv2 error codes
- enum ErrorCode {
- kerGeneralError = -1,
+ enum class ErrorCode
+ {
kerSuccess = 0,
+ kerGeneralError,
kerErrorMessage,
kerCallFailed,
kerNotAnImage,
@@ -196,9 +190,7 @@ namespace Exiv2 {
kerImageWriteFailed,
kerNoImageInInputData,
kerInvalidIfdId,
- //! Entry::setValue: Value too large
kerValueTooLarge,
- //! Entry::setDataArea: Value too large
kerDataAreaValueTooLarge,
kerOffsetOutOfRange,
kerUnsupportedDataAreaOffsetType,
@@ -236,122 +228,86 @@ namespace Exiv2 {
kerCorruptedMetadata,
kerArithmeticOverflow,
kerMallocFailed,
+
+ kerErrorCount,
};
/*!
@brief Simple error class used for exceptions. An output operator is
provided to print errors to a stream.
*/
- template
- class EXIV2API BasicError : public AnyError {
+ class EXIV2API Error : public std::exception
+ {
public:
//! @name Creators
//@{
//! Constructor taking only an error code
- explicit inline BasicError(ErrorCode code);
+ explicit Error(ErrorCode code);
//! Constructor taking an error code and one argument
- template
- inline BasicError(ErrorCode code, const A& arg1);
+ template
+ Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString(arg1))
+ {
+ setMsg(1);
+ }
//! Constructor taking an error code and two arguments
- template
- inline BasicError(ErrorCode code, const A& arg1, const B& arg2);
+ template
+ Error(ErrorCode code, const A& arg1, const B& arg2)
+ : code_(code), arg1_(toBasicString(arg1)), arg2_(toBasicString(arg2))
+ {
+ setMsg(2);
+ }
//! Constructor taking an error code and three arguments
- template
- inline BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3);
+ template
+ Error(ErrorCode code, const A& arg1, const B& arg2, const C& arg3)
+ : code_(code),
+ arg1_(toBasicString(arg1)),
+ arg2_(toBasicString(arg2)),
+ arg3_(toBasicString(arg3))
+ {
+ setMsg(3);
+ }
//! Virtual destructor. (Needed because of throw())
- inline ~BasicError() noexcept override;
+ virtual ~Error() noexcept;
//@}
//! @name Accessors
//@{
- inline int code() const noexcept override;
+ ErrorCode code() const noexcept;
/*!
@brief Return the error message as a C-string. The pointer returned by what()
is valid only as long as the BasicError object exists.
*/
- inline const char* what() const noexcept override;
+ const char* what() const noexcept override;
//@}
private:
//! @name Manipulators
//@{
//! Assemble the error message from the arguments
- void setMsg();
+ void setMsg(int count);
//@}
// DATA
- ErrorCode code_; //!< Error code
- int count_; //!< Number of arguments
- std::basic_string arg1_; //!< First argument
- std::basic_string arg2_; //!< Second argument
- std::basic_string arg3_; //!< Third argument
- std::string msg_; //!< Complete error message
- }; // class BasicError
-
- //! Error class used for exceptions (std::string based)
- using Error = BasicError;
-
- // *****************************************************************************
- // free functions, template and inline definitions
-
- //! Return the error message for the error with code \em code.
- const char* errMsg(int code);
-
- template
- BasicError::BasicError(ErrorCode code)
- : code_(code), count_(0)
- {
- setMsg();
- }
-
- template template
- BasicError::BasicError(ErrorCode code, const A& arg1)
- : code_(code), count_(1), arg1_(toBasicString(arg1))
+ const ErrorCode code_; //!< Error code
+ const std::string arg1_; //!< First argument
+ const std::string arg2_; //!< Second argument
+ const std::string arg3_; //!< Third argument
+ std::string msg_; //!< Complete error message
+ }; // class BasicError
+
+ //! %Error output operator
+ inline std::ostream& operator<<(std::ostream& os, const Error& error)
{
- setMsg();
- }
-
- template template
- BasicError::BasicError(ErrorCode code, const A& arg1, const B& arg2)
- : code_(code), count_(2),
- arg1_(toBasicString(arg1)),
- arg2_(toBasicString(arg2))
- {
- setMsg();
- }
-
- template template
- BasicError::BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3)
- : code_(code), count_(3),
- arg1_(toBasicString(arg1)),
- arg2_(toBasicString(arg2)),
- arg3_(toBasicString(arg3))
- {
- setMsg();
- }
-
- template
- BasicError::~BasicError() noexcept = default;
-
- template
- int BasicError::code() const noexcept
- {
- return code_;
- }
-
- template
- const char* BasicError::what() const noexcept
- {
- return msg_.c_str();
+ return os << error.what();
}
#ifdef _MSC_VER
-# pragma warning( default : 4275 )
+#pragma warning(default : 4275)
#endif
-} // namespace Exiv2
-#endif // #ifndef ERROR_HPP_
+} // namespace Exiv2
+#endif // #ifndef ERROR_HPP_
diff --git a/include/exiv2/gifimage.hpp b/include/exiv2/gifimage.hpp
index 5beb6f122e..caf9f318a0 100644
--- a/include/exiv2/gifimage.hpp
+++ b/include/exiv2/gifimage.hpp
@@ -52,22 +52,22 @@ namespace Exiv2 {
void readMetadata() override;
/*!
@brief Todo: Write metadata back to the image. This method is not
- yet(?) implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
+ yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
- an instance of Error(kerInvalidSettingForImage).
+ an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
- an instance of Error(kerInvalidSettingForImage).
+ an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. Calling this function will throw an instance
- of Error(kerInvalidSettingForImage).
+ of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/jp2image.hpp b/include/exiv2/jp2image.hpp
index d484e94967..ab14d08475 100644
--- a/include/exiv2/jp2image.hpp
+++ b/include/exiv2/jp2image.hpp
@@ -56,7 +56,7 @@ namespace Exiv2
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
- an instance of Error(kerInvalidSettingForImage).
+ an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/mrwimage.hpp b/include/exiv2/mrwimage.hpp
index faefd38efd..47f103f77c 100644
--- a/include/exiv2/mrwimage.hpp
+++ b/include/exiv2/mrwimage.hpp
@@ -55,22 +55,22 @@ namespace Exiv2 {
void readMetadata() override;
/*!
@brief Todo: Write metadata back to the image. This method is not
- yet implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
+ yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. MRW format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/orfimage.hpp b/include/exiv2/orfimage.hpp
index 906ce38999..ac4f50dde8 100644
--- a/include/exiv2/orfimage.hpp
+++ b/include/exiv2/orfimage.hpp
@@ -57,7 +57,7 @@ namespace Exiv2 {
void writeMetadata() override;
/*!
@brief Not supported. ORF format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/psdimage.hpp b/include/exiv2/psdimage.hpp
index e3ec827a9b..cb56911a55 100644
--- a/include/exiv2/psdimage.hpp
+++ b/include/exiv2/psdimage.hpp
@@ -51,7 +51,7 @@ namespace Exiv2 {
void readMetadata() override;
void writeMetadata() override;
/*!
- @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage).
+ @brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/rafimage.hpp b/include/exiv2/rafimage.hpp
index febd36fa03..1db1c0054b 100644
--- a/include/exiv2/rafimage.hpp
+++ b/include/exiv2/rafimage.hpp
@@ -48,22 +48,22 @@ namespace Exiv2 {
void readMetadata() override;
/*!
@brief Todo: Write metadata back to the image. This method is not
- yet implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
+ yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. RAF format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/rw2image.hpp b/include/exiv2/rw2image.hpp
index d6e25c51e8..f0ec07e993 100644
--- a/include/exiv2/rw2image.hpp
+++ b/include/exiv2/rw2image.hpp
@@ -46,22 +46,22 @@ namespace Exiv2 {
void readMetadata() override;
/*!
@brief Todo: Write metadata back to the image. This method is not
- yet implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
+ yet implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet, requires writeMetadata(). Calling
- this function will throw an Error(kerInvalidSettingForImage).
+ this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. RW2 format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/tgaimage.hpp b/include/exiv2/tgaimage.hpp
index fd3b7f13cb..6c9cbda71b 100644
--- a/include/exiv2/tgaimage.hpp
+++ b/include/exiv2/tgaimage.hpp
@@ -51,22 +51,22 @@ namespace Exiv2 {
void readMetadata() override;
/*!
@brief Todo: Write metadata back to the image. This method is not
- yet(?) implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
+ yet(?) implemented. Calling it will throw an Error(ErrorCode::kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
- an instance of Error(kerInvalidSettingForImage).
+ an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
- an instance of Error(kerInvalidSettingForImage).
+ an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. Calling this function will throw an instance
- of Error(kerInvalidSettingForImage).
+ of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/tiffimage.hpp b/include/exiv2/tiffimage.hpp
index ef240ac098..356d400137 100644
--- a/include/exiv2/tiffimage.hpp
+++ b/include/exiv2/tiffimage.hpp
@@ -57,7 +57,7 @@ namespace Exiv2 {
/*!
@brief Not supported. TIFF format does not contain a comment.
- Calling this function will throw an Error(kerInvalidSettingForImage).
+ Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp
index dc12c0152f..9f10e33b06 100644
--- a/include/exiv2/webpimage.hpp
+++ b/include/exiv2/webpimage.hpp
@@ -46,7 +46,7 @@ namespace Exiv2 {
//@}
/*!
- @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage).
+ @brief Not supported. Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
void setIptcData(const IptcData& /*iptcData*/) override;
diff --git a/include/exiv2/xmpsidecar.hpp b/include/exiv2/xmpsidecar.hpp
index 642c158d86..2c215924ea 100644
--- a/include/exiv2/xmpsidecar.hpp
+++ b/include/exiv2/xmpsidecar.hpp
@@ -45,7 +45,7 @@ namespace Exiv2 {
void writeMetadata() override;
/*!
@brief Not supported. XMP sidecar files do not contain a comment.
- Calling this function will throw an instance of Error(kerInvalidSettingForImage).
+ Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index 566f0ab2c6..331ebba37d 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -22,7 +22,6 @@ set( SAMPLES
stringto-test.cpp
taglist.cpp
tiff-test.cpp
- werror-test.cpp
write-test.cpp
write2-test.cpp
xmpparse.cpp
diff --git a/samples/addmoddel.cpp b/samples/addmoddel.cpp
index 6abc1225eb..a2fa8859c7 100644
--- a/samples/addmoddel.cpp
+++ b/samples/addmoddel.cpp
@@ -74,14 +74,14 @@ try {
key = Exiv2::ExifKey("Exif.Image.PrimaryChromaticities");
auto pos = exifData.findKey(key);
if (pos == exifData.end())
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Key not found");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Key not found");
// Get a pointer to a copy of the value
v = pos->getValue();
// Downcast the Value pointer to its actual type
auto prv = dynamic_cast(v.get());
if (!prv)
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Downcast failed");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Downcast failed");
rv = Exiv2::URationalValue(*prv);
// Modify the value directly through the interface of URationalValue
@@ -97,7 +97,7 @@ try {
// Delete the metadatum at iterator position pos
key = Exiv2::ExifKey("Exif.Image.PrimaryChromaticities");
pos = exifData.findKey(key);
- if (pos == exifData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Key not found");
+ if (pos == exifData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Key not found");
exifData.erase(pos);
std::cout << "Deleted key \"" << key << "\"\n";
@@ -109,7 +109,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/conntest.cpp b/samples/conntest.cpp
index 9df8e969b7..664cedd7d3 100644
--- a/samples/conntest.cpp
+++ b/samples/conntest.cpp
@@ -23,7 +23,7 @@ void httpcon(const std::string& url, bool useHttp1_0 = false) {
int serverCode = Exiv2::http(request,response,errors);
if (serverCode < 0 || serverCode >= 400 || !errors.empty()) {
- throw Exiv2::Error(Exiv2::kerTiffDirectoryTooLarge, "Server", serverCode);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerTiffDirectoryTooLarge, "Server", serverCode);
}
}
@@ -31,14 +31,14 @@ void httpcon(const std::string& url, bool useHttp1_0 = false) {
void curlcon(const std::string& url, bool useHttp1_0 = false) {
CURL* curl = curl_easy_init();
if(!curl) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Unable to init libcurl.");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Unable to init libcurl.");
}
// get the timeout value
std::string timeoutStr = Exiv2::getEnv(Exiv2::envTIMEOUT);
long timeout = atol(timeoutStr.c_str());
if (timeout == 0) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Timeout Environmental Variable must be a positive integer.");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Timeout Environmental Variable must be a positive integer.");
}
std::string response;
@@ -55,7 +55,7 @@ void curlcon(const std::string& url, bool useHttp1_0 = false) {
/* Perform the request, res will get the return code */
CURLcode res = curl_easy_perform(curl);
if(res != CURLE_OK) { // error happened
- throw Exiv2::Error(Exiv2::kerErrorMessage, curl_easy_strerror(res));
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, curl_easy_strerror(res));
}
// get return code
@@ -64,7 +64,7 @@ void curlcon(const std::string& url, bool useHttp1_0 = false) {
curl_easy_cleanup(curl);
if (returnCode >= 400 || returnCode < 0) {
- throw Exiv2::Error(Exiv2::kerTiffDirectoryTooLarge, "Server", returnCode);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerTiffDirectoryTooLarge, "Server", returnCode);
}
}
#endif
@@ -102,7 +102,7 @@ int main(int argc,const char** argv)
httpcon(url, useHttp1_0);
isOk = true;
}
- } catch (const Exiv2::AnyError& e) {
+ } catch (const Exiv2::Error& e) {
std::cout << "Error: '" << e << "'" << std::endl;
return -1;
}
diff --git a/samples/convert-test.cpp b/samples/convert-test.cpp
index 2d05f74049..0add559cc6 100644
--- a/samples/convert-test.cpp
+++ b/samples/convert-test.cpp
@@ -34,7 +34,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/easyaccess-test.cpp b/samples/easyaccess-test.cpp
index ea8b7345d9..130e6cbb8d 100644
--- a/samples/easyaccess-test.cpp
+++ b/samples/easyaccess-test.cpp
@@ -81,7 +81,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/exifcomment.cpp b/samples/exifcomment.cpp
index 880c38ffb0..20ed7c80c3 100644
--- a/samples/exifcomment.cpp
+++ b/samples/exifcomment.cpp
@@ -49,7 +49,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/exifdata-test.cpp b/samples/exifdata-test.cpp
index 3ae5f6eccb..9b9341e46b 100644
--- a/samples/exifdata-test.cpp
+++ b/samples/exifdata-test.cpp
@@ -30,7 +30,7 @@ try {
Exiv2::ExifData &ed = image->exifData();
if (ed.empty()) {
std::string error = file + ": No Exif data found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
std::cout << "Copy construction, non-intrusive changes\n";
@@ -88,7 +88,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/exifdata.cpp b/samples/exifdata.cpp
index 18d87940b7..aef871496f 100644
--- a/samples/exifdata.cpp
+++ b/samples/exifdata.cpp
@@ -198,7 +198,7 @@ int main(int argc,const char* argv[])
result = 3;
break;
}
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cerr << "*** error exiv2 exception '" << e << "' ***" << std::endl;
result = 4;
} catch ( ... ) {
diff --git a/samples/exifprint.cpp b/samples/exifprint.cpp
index 7748ee2481..fab48ba5ca 100644
--- a/samples/exifprint.cpp
+++ b/samples/exifprint.cpp
@@ -70,7 +70,7 @@ try {
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) {
std::string error("No Exif data found in file");
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
std::set shortLong;
@@ -118,7 +118,7 @@ try {
return rc;
}
//catch (std::exception& e) {
-//catch (Exiv2::AnyError& e) {
+//catch (Exiv2::Error& e) {
catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
return -1;
diff --git a/samples/exifvalue.cpp b/samples/exifvalue.cpp
index 55ceb02e00..d50cdb01cb 100644
--- a/samples/exifvalue.cpp
+++ b/samples/exifvalue.cpp
@@ -32,7 +32,7 @@ int main(int argc, char* const argv[])
try {
std::cout << exifData[key] << std::endl;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'" << std::endl;
exit(3);
} catch ( ... ) {
diff --git a/samples/iotest.cpp b/samples/iotest.cpp
index 8a538b95c8..39b0413912 100644
--- a/samples/iotest.cpp
+++ b/samples/iotest.cpp
@@ -51,11 +51,11 @@ int main(int argc, char* const argv[])
// copy fileIn from a remote location.
auto io = Exiv2::ImageFactory::createIo(fr);
if ( io->open() != 0 ) {
- Error(Exiv2::kerFileOpenFailed, io->path(), "rb", strError());
+ Error(Exiv2::ErrorCode::kerFileOpenFailed, io->path(), "rb", strError());
}
FileIo output(f0);
if ( !output.open("wb") ) {
- Error(Exiv2::kerFileOpenFailed, output.path() , "w+b", strError());
+ Error(Exiv2::ErrorCode::kerFileOpenFailed, output.path() , "w+b", strError());
}
size_t l = 0;
if ( !bytes.empty() ) {
@@ -75,12 +75,12 @@ int main(int argc, char* const argv[])
FileIo fileIn(f0);
if (fileIn.open() != 0) {
- throw Error(Exiv2::kerDataSourceOpenFailed, fileIn.path(), strError());
+ throw Error(Exiv2::ErrorCode::kerDataSourceOpenFailed, fileIn.path(), strError());
}
FileIo fileOut1(f1);
if (fileOut1.open("w+b") != 0) {
- throw Error(Exiv2::kerFileOpenFailed, f1, "w+b", strError());
+ throw Error(Exiv2::ErrorCode::kerFileOpenFailed, f1, "w+b", strError());
}
MemIo memIo1;
@@ -106,7 +106,7 @@ int main(int argc, char* const argv[])
// Create or overwrite the file, then close it
FileIo fileTest("iotest.txt");
if (fileTest.open("w+b") != 0) {
- throw Error(Exiv2::kerFileOpenFailed, "iotest.txt", "w+b", strError());
+ throw Error(Exiv2::ErrorCode::kerFileOpenFailed, "iotest.txt", "w+b", strError());
}
fileTest.close();
@@ -118,7 +118,7 @@ int main(int argc, char* const argv[])
memIo2.seek(0, BasicIo::beg);
FileIo fileOut2(f2);
if (fileOut2.open("w+b") != 0) {
- throw Error(Exiv2::kerFileOpenFailed, f2, "w+b", strError());
+ throw Error(Exiv2::ErrorCode::kerFileOpenFailed, f2, "w+b", strError());
}
size_t readCount = 0;
@@ -137,7 +137,7 @@ int main(int argc, char* const argv[])
}
return 0;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 20;
}
@@ -155,7 +155,7 @@ int WriteReadSeek(BasicIo &io)
const size_t size2 = std::strlen(tester2) + 1;
if (io.open() != 0) {
- throw Error(Exiv2::kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(Exiv2::ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
if (io.write(reinterpret_cast(tester1), size1) != size1) {
@@ -218,7 +218,7 @@ int WriteReadSeek(BasicIo &io)
// open should seek to beginning
if (io.open() != 0) {
- throw Error(Exiv2::kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(Exiv2::ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
std::memset(buf, -1, sizeof(buf));
if (io.read(buf, sizeof(buf)) != insert + size2) {
diff --git a/samples/iptceasy.cpp b/samples/iptceasy.cpp
index 99afcae050..c98f1f3271 100644
--- a/samples/iptceasy.cpp
+++ b/samples/iptceasy.cpp
@@ -44,7 +44,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/iptcprint.cpp b/samples/iptcprint.cpp
index f7eea57ae6..b46b66698e 100644
--- a/samples/iptcprint.cpp
+++ b/samples/iptcprint.cpp
@@ -25,7 +25,7 @@ try {
if (iptcData.empty()) {
std::string error(argv[1]);
error += ": No IPTC data found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
auto end = iptcData.end();
@@ -45,7 +45,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return 1;
}
diff --git a/samples/iptctest.cpp b/samples/iptctest.cpp
index 36703700f6..531ef2289f 100644
--- a/samples/iptctest.cpp
+++ b/samples/iptctest.cpp
@@ -45,7 +45,7 @@ int main(int argc, char* const argv[])
return 0;
}
- catch (AnyError& e) {
+ catch (Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
@@ -72,7 +72,7 @@ bool processLine(const std::string& line, int num, IptcData &iptcData)
default:
std::ostringstream os;
os << "Unknown command (" << line.at(0) << ") at line " << num;
- throw Error(kerErrorMessage, os.str());
+ throw Error(ErrorCode::kerErrorMessage, os.str());
}
return true;
}
@@ -88,7 +88,7 @@ void processAdd(const std::string& line, int num, IptcData &iptcData)
dataStart == std::string::npos) {
std::ostringstream os;
os << "Invalid \'a\' command at line " << num;
- throw Error(kerErrorMessage, os.str());
+ throw Error(ErrorCode::kerErrorMessage, os.str());
}
std::string key(line.substr(keyStart, keyEnd-keyStart));
@@ -105,7 +105,7 @@ void processAdd(const std::string& line, int num, IptcData &iptcData)
int rc = iptcData.add(iptcKey, value.get());
if (rc) {
- throw Error(kerErrorMessage, "Iptc dataset already exists and is not repeatable");
+ throw Error(ErrorCode::kerErrorMessage, "Iptc dataset already exists and is not repeatable");
}
}
@@ -116,7 +116,7 @@ void processRemove(const std::string& line, int num, IptcData &iptcData)
if (keyStart == std::string::npos) {
std::ostringstream os;
os << "Invalid \'r\' command at line " << num;
- throw Error(kerErrorMessage, os.str());
+ throw Error(ErrorCode::kerErrorMessage, os.str());
}
const std::string key( line.substr(keyStart) );
@@ -139,7 +139,7 @@ void processModify(const std::string& line, int num, IptcData &iptcData)
dataStart == std::string::npos) {
std::ostringstream os;
os << "Invalid \'m\' command at line " << num;
- throw Error(kerErrorMessage, os.str());
+ throw Error(ErrorCode::kerErrorMessage, os.str());
}
std::string key(line.substr(keyStart, keyEnd-keyStart));
@@ -161,7 +161,7 @@ void processModify(const std::string& line, int num, IptcData &iptcData)
else {
int rc = iptcData.add(iptcKey, value.get());
if (rc) {
- throw Error(kerErrorMessage, "Iptc dataset already exists and is not repeatable");
+ throw Error(ErrorCode::kerErrorMessage, "Iptc dataset already exists and is not repeatable");
}
}
}
diff --git a/samples/largeiptc-test.cpp b/samples/largeiptc-test.cpp
index d4d5b4dc92..8a3d214ebd 100644
--- a/samples/largeiptc-test.cpp
+++ b/samples/largeiptc-test.cpp
@@ -26,14 +26,14 @@ int main(int argc, char* const argv[])
// Read data file into data buffer
Exiv2::FileIo io(data);
if (io.open() != 0) {
- throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError());
+ throw Exiv2::Error(Exiv2::ErrorCode::kerDataSourceOpenFailed, io.path(), Exiv2::strError());
}
Exiv2::DataBuf buf(io.size());
std::cout << "Reading " << buf.size() << " bytes from " << data << "\n";
const size_t readBytes = io.read(buf.data(), buf.size());
if (readBytes != buf.size() || io.error() || io.eof()) {
- throw Exiv2::Error(Exiv2::kerFailedToReadImageData);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerFailedToReadImageData);
}
// Read metadata from file
@@ -72,7 +72,7 @@ int main(int argc, char* const argv[])
image->writeMetadata();
return 0;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/metacopy.cpp b/samples/metacopy.cpp
index 5062b01404..2c985bc59d 100644
--- a/samples/metacopy.cpp
+++ b/samples/metacopy.cpp
@@ -57,7 +57,7 @@ try {
try {
writeImg->writeMetadata();
}
- catch (const Exiv2::AnyError&) {
+ catch (const Exiv2::Error&) {
std::cerr << params.progname() <<
": Could not write metadata to (" << params.write_ << ")\n";
return 8;
@@ -65,7 +65,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 10;
}
diff --git a/samples/mmap-test.cpp b/samples/mmap-test.cpp
index a12ba7a5f8..b5a8c0a9f1 100644
--- a/samples/mmap-test.cpp
+++ b/samples/mmap-test.cpp
@@ -24,7 +24,7 @@ try {
FileIo file(path);
// Open the file in read mode
if (file.open("rb") != 0) {
- throw Error(kerFileOpenFailed, path, "rb", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path, "rb", strError());
}
// Map it to memory
const Exiv2::byte* pData = file.mmap();
@@ -39,6 +39,6 @@ try {
return 0;
}
-catch (const AnyError& e) {
+catch (const Error& e) {
std::cout << e << "\n";
}
diff --git a/samples/mrwthumb.cpp b/samples/mrwthumb.cpp
index 323b03462c..7b67d89a36 100644
--- a/samples/mrwthumb.cpp
+++ b/samples/mrwthumb.cpp
@@ -26,7 +26,7 @@ int main(int argc, char* const argv[])
if (exifData.empty()) {
std::string error(argv[1]);
error += ": No Exif data found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
Exiv2::ExifKey key("Exif.Minolta.ThumbnailOffset");
@@ -46,7 +46,7 @@ int main(int argc, char* const argv[])
}
return 0;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/prevtest.cpp b/samples/prevtest.cpp
index f4065a3dcb..624c0a3c85 100644
--- a/samples/prevtest.cpp
+++ b/samples/prevtest.cpp
@@ -38,7 +38,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/remotetest.cpp b/samples/remotetest.cpp
index a08a494ecb..321c8a43ab 100644
--- a/samples/remotetest.cpp
+++ b/samples/remotetest.cpp
@@ -56,7 +56,7 @@ try {
if (exifReadData.empty()) {
std::string error(argv[1]);
error += ": No Exif data found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
auto end = exifReadData.end();
for (auto i = exifReadData.begin(); i != end; ++i) {
@@ -82,26 +82,26 @@ try {
exifReadData["Exif.Image.Copyright"] = "Exiv2.org"; // AsciiValue
key = Exiv2::ExifKey("Exif.Image.Make");
auto pos = exifReadData.findKey(key);
- if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.Image.Make not found");
+ if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.Make not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Image.DateTime");
pos = exifReadData.findKey(key);
- if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.Image.DateTime not found");
+ if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Image.DateTime not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.Canon.OwnerName");
pos = exifReadData.findKey(key);
- if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.Canon.OwnerName not found");
+ if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.Canon.OwnerName not found");
exifReadData.erase(pos);
key = Exiv2::ExifKey("Exif.CanonCs.LensType");
pos = exifReadData.findKey(key);
- if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.CanonCs.LensType not found");
+ if (pos == exifReadData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Exif.CanonCs.LensType not found");
exifReadData.erase(pos);
readTest->setExifData(exifReadData);
readTest->writeMetadata();
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/stringto-test.cpp b/samples/stringto-test.cpp
index 0d5c3291f0..23451e9653 100644
--- a/samples/stringto-test.cpp
+++ b/samples/stringto-test.cpp
@@ -80,7 +80,7 @@ int main()
std::cout << "nok";
std::cout << std::endl;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/taglist.cpp b/samples/taglist.cpp
index cc01839e5d..2ee212e583 100644
--- a/samples/taglist.cpp
+++ b/samples/taglist.cpp
@@ -76,7 +76,7 @@ int main(int argc, char* argv[])
try {
XmpProperties::printProperties(std::cout, item);
break;
- } catch (const AnyError&) {
+ } catch (const Error&) {
rc = 2;
}
std::cerr << "Unexpected argument " << argv[1] << std::endl;
@@ -135,7 +135,7 @@ int main(int argc, char* argv[])
<< "Print Exif tags, MakerNote tags, or Iptc datasets" << std::endl
;
}
- } catch (AnyError& e) {
+ } catch (Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
rc = EXIT_FAILURE ;
}
diff --git a/samples/tiff-test.cpp b/samples/tiff-test.cpp
index 17239357aa..3b22c0b4f5 100644
--- a/samples/tiff-test.cpp
+++ b/samples/tiff-test.cpp
@@ -35,7 +35,7 @@ try {
return 0;
}
-catch (const AnyError& e) {
+catch (const Error& e) {
std::cout << e << "\n";
}
@@ -47,25 +47,25 @@ void mini1(const char* path)
// Write nothing to a new structure, without a previous binary image
wm = ExifParser::encode(blob, nullptr, 0, bigEndian, exifData);
- enforce(wm == wmIntrusive, Exiv2::kerErrorMessage, "encode returned an unexpected value");
+ enforce(wm == wmIntrusive, Exiv2::ErrorCode::kerErrorMessage, "encode returned an unexpected value");
assert(blob.empty());
std::cout << "Test 1: Writing empty Exif data without original binary data: ok.\n";
// Write nothing, this time with a previous binary image
DataBuf buf = readFile(path);
wm = ExifParser::encode(blob, buf.c_data(), buf.size(), bigEndian, exifData);
- enforce(wm == wmIntrusive, Exiv2::kerErrorMessage, "encode returned an unexpected value");
+ enforce(wm == wmIntrusive, Exiv2::ErrorCode::kerErrorMessage, "encode returned an unexpected value");
assert(blob.empty());
std::cout << "Test 2: Writing empty Exif data with original binary data: ok.\n";
// Write something to a new structure, without a previous binary image
exifData["Exif.Photo.DateTimeOriginal"] = "Yesterday at noon";
wm = ExifParser::encode(blob, nullptr, 0, bigEndian, exifData);
- enforce(wm == wmIntrusive, Exiv2::kerErrorMessage, "encode returned an unexpected value");
+ enforce(wm == wmIntrusive, Exiv2::ErrorCode::kerErrorMessage, "encode returned an unexpected value");
std::cout << "Test 3: Wrote non-empty Exif data without original binary data:\n";
exifData.clear();
ByteOrder bo = ExifParser::decode(exifData, &blob[0], blob.size());
- enforce(bo == bigEndian, Exiv2::kerErrorMessage, "decode returned an unexpected value");
+ enforce(bo == bigEndian, Exiv2::ErrorCode::kerErrorMessage, "decode returned an unexpected value");
print(exifData);
}
@@ -93,7 +93,7 @@ void print(const ExifData& exifData)
{
if (exifData.empty()) {
std::string error("No Exif data found in the file");
- throw Exiv2::Error(kerErrorMessage, error);
+ throw Exiv2::Error(ErrorCode::kerErrorMessage, error);
}
auto end = exifData.end();
for (auto i = exifData.begin(); i != end; ++i) {
diff --git a/samples/werror-test.cpp b/samples/werror-test.cpp
deleted file mode 100644
index fad6fb06c9..0000000000
--- a/samples/werror-test.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// Simple tests for the wide-string error class WError
-
-#include
-#include
-
-int main()
-{
- Exiv2::XmpParser::initialize();
- ::atexit(Exiv2::XmpParser::terminate);
-#ifdef EXV_ENABLE_BMFF
- Exiv2::enableBMFF();
-#endif
-
- try {
- throw Exiv2::Error(Exiv2::kerGeneralError, "ARG1", "ARG2", "ARG3");
- }
- catch (const Exiv2::Error& e) {
- std::cout << "Caught Error '" << e.what() << "'\n";
- }
-
- return 0;
-}
diff --git a/samples/write-test.cpp b/samples/write-test.cpp
index 2bb1e32014..4a2f8280b3 100644
--- a/samples/write-test.cpp
+++ b/samples/write-test.cpp
@@ -132,7 +132,7 @@ int main(int argc, char* const argv[])
return rc;
}
-catch (AnyError& e) {
+catch (Error& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 1;
}
@@ -158,7 +158,7 @@ void testCase(const std::string& file1,
std::cerr << "---> Modifying Exif data\n";
auto pos = ed1.findKey(ek);
if (pos == ed1.end()) {
- throw Error(kerErrorMessage, "Metadatum with key = " + ek.key() + " not found");
+ throw Error(ErrorCode::kerErrorMessage, "Metadatum with key = " + ek.key() + " not found");
}
pos->setValue(value);
diff --git a/samples/write2-test.cpp b/samples/write2-test.cpp
index a1a1169009..fed1037b86 100644
--- a/samples/write2-test.cpp
+++ b/samples/write2-test.cpp
@@ -189,7 +189,7 @@ int main(int argc, char* const argv[])
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/xmpdump.cpp b/samples/xmpdump.cpp
index 27046816af..bc7f6a0218 100644
--- a/samples/xmpdump.cpp
+++ b/samples/xmpdump.cpp
@@ -25,12 +25,12 @@ int main(int argc, char* const argv[])
if (xmpPacket.empty()) {
std::string error(argv[1]);
error += ": No XMP packet found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
std::cout << xmpPacket << "\n";
return 0;
- } catch (Exiv2::AnyError& e) {
+ } catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/xmpparse.cpp b/samples/xmpparse.cpp
index 7a3c4b7067..8dad16ace9 100644
--- a/samples/xmpparse.cpp
+++ b/samples/xmpparse.cpp
@@ -24,12 +24,12 @@ try {
if (0 != Exiv2::XmpParser::decode(xmpData, xmpPacket)) {
std::string error(argv[1]);
error += ": Failed to parse file contents (XMP packet)";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
if (xmpData.empty()) {
std::string error(argv[1]);
error += ": No XMP properties found in the XMP packet";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
for (auto&& md : xmpData) {
std::cout << std::setfill(' ') << std::left << std::setw(44) << md.key() << " " << std::setw(9)
@@ -39,7 +39,7 @@ try {
Exiv2::XmpParser::terminate();
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/xmpparser-test.cpp b/samples/xmpparser-test.cpp
index f141bf35d8..39565bfec8 100644
--- a/samples/xmpparser-test.cpp
+++ b/samples/xmpparser-test.cpp
@@ -25,12 +25,12 @@ try {
if (0 != Exiv2::XmpParser::decode(xmpData, xmpPacket)) {
std::string error(argv[1]);
error += ": Failed to parse file contents (XMP packet)";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
if (xmpData.empty()) {
std::string error(argv[1]);
error += ": No XMP properties found in the XMP packet";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
for (auto&& md : xmpData) {
std::cout << std::setfill(' ') << std::left << std::setw(44) << md.key() << " " << std::setw(9)
@@ -42,19 +42,19 @@ try {
if (0 != Exiv2::XmpParser::encode(xmpPacket, xmpData)) {
std::string error(argv[1]);
error += ": Failed to encode the XMP data";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
Exiv2::FileIo file(filename);
if (file.open("wb") != 0) {
- throw Exiv2::Error(Exiv2::kerFileOpenFailed, filename, "wb", Exiv2::strError());
+ throw Exiv2::Error(Exiv2::ErrorCode::kerFileOpenFailed, filename, "wb", Exiv2::strError());
}
if (file.write(reinterpret_cast(xmpPacket.data()), xmpPacket.size()) == 0) {
- throw Exiv2::Error(Exiv2::kerCallFailed, filename, Exiv2::strError(), "FileIo::write");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerCallFailed, filename, Exiv2::strError(), "FileIo::write");
}
Exiv2::XmpParser::terminate();
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/samples/xmpprint.cpp b/samples/xmpprint.cpp
index d31be89856..69e2ec960f 100644
--- a/samples/xmpprint.cpp
+++ b/samples/xmpprint.cpp
@@ -30,13 +30,13 @@ int main(int argc, char** argv)
if (xmpData.empty()) {
std::string error(argv[1]);
error += ": No XMP data found in the file";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
if (xmpData.empty())
{
std::string error(argv[1]);
error += ": No XMP properties found in the XMP packet";
- throw Exiv2::Error(Exiv2::kerErrorMessage, error);
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
}
for (auto&& md : xmpData) {
@@ -49,7 +49,7 @@ int main(int argc, char** argv)
return 0;
}
-catch (Exiv2::AnyError& e)
+catch (Exiv2::Error& e)
{
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
diff --git a/samples/xmpsample.cpp b/samples/xmpsample.cpp
index 81042953e7..5f8ac76038 100644
--- a/samples/xmpsample.cpp
+++ b/samples/xmpsample.cpp
@@ -100,7 +100,7 @@ try {
// Deleting an XMP property
auto pos = xmpData.findKey(Exiv2::XmpKey("Xmp.dc.eight"));
- if (pos == xmpData.end()) throw Exiv2::Error(Exiv2::kerErrorMessage, "Key not found");
+ if (pos == xmpData.end()) throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Key not found");
xmpData.erase(pos);
// -------------------------------------------------------------------------
@@ -196,7 +196,7 @@ try {
// Serialize the XMP data and output the XMP packet
std::string xmpPacket;
if (0 != Exiv2::XmpParser::encode(xmpPacket, xmpData)) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Failed to serialize XMP data");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Failed to serialize XMP data");
}
std::cout << xmpPacket << "\n";
@@ -205,7 +205,7 @@ try {
return 0;
}
-catch (Exiv2::AnyError& e) {
+catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
diff --git a/src/basicio.cpp b/src/basicio.cpp
index 1e2f28ad11..68a53e6d0c 100644
--- a/src/basicio.cpp
+++ b/src/basicio.cpp
@@ -230,12 +230,12 @@ namespace Exiv2 {
{
assert(p_->fp_);
if (munmap() != 0) {
- throw Error(kerCallFailed, path(), strError(), "munmap");
+ throw Error(ErrorCode::kerCallFailed, path(), strError(), "munmap");
}
p_->mappedLength_ = size();
p_->isWriteable_ = isWriteable;
if (p_->isWriteable_ && p_->switchMode(Impl::opWrite) != 0) {
- throw Error(kerFailedToMapFileForReadWrite, path(), strError());
+ throw Error(ErrorCode::kerFailedToMapFileForReadWrite, path(), strError());
}
#if defined EXV_HAVE_MMAP && defined EXV_HAVE_MUNMAP
int prot = PROT_READ;
@@ -244,7 +244,7 @@ namespace Exiv2 {
}
void* rc = ::mmap(nullptr, p_->mappedLength_, prot, MAP_SHARED, fileno(p_->fp_), 0);
if (MAP_FAILED == rc) {
- throw Error(kerCallFailed, path(), strError(), "mmap");
+ throw Error(ErrorCode::kerCallFailed, path(), strError(), "mmap");
}
p_->pMappedArea_ = static_cast(rc);
@@ -265,28 +265,28 @@ namespace Exiv2 {
HANDLE hPh = GetCurrentProcess();
HANDLE hFd = (HANDLE)_get_osfhandle(fileno(p_->fp_));
if (hFd == INVALID_HANDLE_VALUE) {
- throw Error(kerCallFailed, path(), "MSG1", "_get_osfhandle");
+ throw Error(ErrorCode::kerCallFailed, path(), "MSG1", "_get_osfhandle");
}
if (!DuplicateHandle(hPh, hFd, hPh, &p_->hFile_, 0, false, DUPLICATE_SAME_ACCESS)) {
- throw Error(kerCallFailed, path(), "MSG2", "DuplicateHandle");
+ throw Error(ErrorCode::kerCallFailed, path(), "MSG2", "DuplicateHandle");
}
p_->hMap_ = CreateFileMapping(p_->hFile_, 0, flProtect, 0, (DWORD) p_->mappedLength_, 0);
if (p_->hMap_ == 0 ) {
- throw Error(kerCallFailed, path(), "MSG3", "CreateFileMapping");
+ throw Error(ErrorCode::kerCallFailed, path(), "MSG3", "CreateFileMapping");
}
void* rc = MapViewOfFile(p_->hMap_, dwAccess, 0, 0, 0);
if (rc == 0) {
- throw Error(kerCallFailed, path(), "MSG4", "CreateFileMapping");
+ throw Error(ErrorCode::kerCallFailed, path(), "MSG4", "CreateFileMapping");
}
p_->pMappedArea_ = static_cast(rc);
#else
// Workaround for platforms without mmap: Read the file into memory
DataBuf buf(static_cast(p_->mappedLength_));
if (read(buf.data(), buf.size()) != buf.size()) {
- throw Error(kerCallFailed, path(), strError(), "FileIo::read");
+ throw Error(ErrorCode::kerCallFailed, path(), strError(), "FileIo::read");
}
if (error()) {
- throw Error(kerCallFailed, path(), strError(), "FileIo::mmap");
+ throw Error(ErrorCode::kerCallFailed, path(), strError(), "FileIo::mmap");
}
p_->pMappedArea_ = buf.release().first;
p_->isMalloced_ = true;
@@ -346,7 +346,7 @@ namespace Exiv2 {
if (open("a+b") != 0) {
// Remove the (temporary) file
fs::remove(fileIo->path().c_str());
- throw Error(kerFileOpenFailed, path(), "a+b", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path(), "a+b", strError());
}
close();
@@ -380,13 +380,13 @@ namespace Exiv2 {
fs::remove(fileIo->path().c_str());
}
else {
- throw Error(kerFileRenameFailed, fileIo->path(), pf, strError());
+ throw Error(ErrorCode::kerFileRenameFailed, fileIo->path(), pf, strError());
}
}
}
else {
if (fileExists(pf) && ::remove(pf) != 0) {
- throw Error(kerCallFailed, pf, strError(), "fs::remove");
+ throw Error(ErrorCode::kerCallFailed, pf, strError(), "fs::remove");
}
fs::rename(fileIo->path().c_str(), pf);
fs::remove(fileIo->path().c_str());
@@ -394,7 +394,7 @@ namespace Exiv2 {
}
#else
if (fileExists(pf) && fs::remove(pf) != 0) {
- throw Error(kerCallFailed, pf, strError(), "fs::remove");
+ throw Error(ErrorCode::kerCallFailed, pf, strError(), "fs::remove");
}
fs::rename(fileIo->path().c_str(), pf);
fs::remove(fileIo->path().c_str());
@@ -404,14 +404,14 @@ namespace Exiv2 {
if (statOk && ::stat(pf, &buf2) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- EXV_WARNING << Error(kerCallFailed, pf, strError(), "::stat") << "\n";
+ EXV_WARNING << Error(ErrorCode::kerCallFailed, pf, strError(), "::stat") << "\n";
#endif
}
if (statOk && origStMode != buf2.st_mode) {
// Set original file permissions
if (::chmod(pf, origStMode) == -1) {
#ifndef SUPPRESS_WARNINGS
- EXV_WARNING << Error(kerCallFailed, pf, strError(), "::chmod") << "\n";
+ EXV_WARNING << Error(ErrorCode::kerCallFailed, pf, strError(), "::chmod") << "\n";
#endif
}
}
@@ -420,10 +420,10 @@ namespace Exiv2 {
else {
// Generic handling, reopen both to reset to start
if (open("w+b") != 0) {
- throw Error(kerFileOpenFailed, path(), "w+b", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path(), "w+b", strError());
}
if (src.open() != 0) {
- throw Error(kerDataSourceOpenFailed, src.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, src.path(), strError());
}
write(src);
src.close();
@@ -431,13 +431,13 @@ namespace Exiv2 {
if (wasOpen) {
if (open(lastMode) != 0) {
- throw Error(kerFileOpenFailed, path(), lastMode, strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path(), lastMode, strError());
}
}
else close();
if (error() || src.error()) {
- throw Error(kerTransferFailed, path(), strError());
+ throw Error(ErrorCode::kerTransferFailed, path(), strError());
}
} // FileIo::transfer
@@ -530,11 +530,11 @@ namespace Exiv2 {
{
assert(p_->fp_);
if (static_cast(rcount) > size())
- throw Error(kerInvalidMalloc);
+ throw Error(ErrorCode::kerInvalidMalloc);
DataBuf buf(rcount);
size_t readCount = read(buf.data(), buf.size());
if (readCount == 0) {
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
}
buf.resize(readCount);
return buf;
@@ -682,7 +682,7 @@ namespace Exiv2 {
size_t size = std::max(blockSize * (1 + need / blockSize), size_);
auto data = static_cast(std::malloc(size));
if (!data) {
- throw Error(kerMallocFailed);
+ throw Error(ErrorCode::kerMallocFailed);
}
if (data_) {
std::memcpy(data, data_, size_);
@@ -700,7 +700,7 @@ namespace Exiv2 {
size_t want = blockSize * (1 + need / blockSize );
data_ = static_cast(std::realloc(data_, want));
if (!data_) {
- throw Error(kerMallocFailed);
+ throw Error(ErrorCode::kerMallocFailed);
}
sizeAlloced_ = want;
}
@@ -756,13 +756,13 @@ namespace Exiv2 {
else {
// Generic reopen to reset position to start
if (src.open() != 0) {
- throw Error(kerDataSourceOpenFailed, src.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, src.path(), strError());
}
p_->idx_ = 0;
write(src);
src.close();
}
- if (error() || src.error()) throw Error(kerMemoryTransferFailed, strError());
+ if (error() || src.error()) throw Error(ErrorCode::kerMemoryTransferFailed, strError());
}
size_t MemIo::write(BasicIo& src)
@@ -910,12 +910,12 @@ namespace Exiv2 {
void XPathIo::ReadStdin() {
if (isatty(fileno(stdin)))
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
#ifdef _O_BINARY
// convert stdin to binary
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
#endif
char readBuf[100*1024];
@@ -932,7 +932,7 @@ namespace Exiv2 {
void XPathIo::ReadDataUri(const std::string& path) {
size_t base64Pos = path.find("base64,");
if (base64Pos == std::string::npos)
- throw Error(kerErrorMessage, "No base64 data");
+ throw Error(ErrorCode::kerErrorMessage, "No base64 data");
std::string data = path.substr(base64Pos+7);
char* decodeData = new char[data.length()];
@@ -940,7 +940,7 @@ namespace Exiv2 {
if (size > 0)
write((byte*)decodeData, size);
else
- throw Error(kerErrorMessage, "Unable to decode base 64.");
+ throw Error(ErrorCode::kerErrorMessage, "Unable to decode base 64.");
delete[] decodeData;
}
@@ -983,11 +983,11 @@ namespace Exiv2 {
if (prot == pStdin) {
if (isatty(fileno(stdin)))
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
#if defined(_MSC_VER) || defined(__MINGW__)
// convert stdin to binary
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
#endif
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
// read stdin and write to the temp file.
@@ -1007,7 +1007,7 @@ namespace Exiv2 {
size_t base64Pos = orgPath.find("base64,");
if (base64Pos == std::string::npos) {
fs.close();
- throw Error(kerErrorMessage, "No base64 data");
+ throw Error(ErrorCode::kerErrorMessage, "No base64 data");
}
std::string data = orgPath.substr(base64Pos+7);
@@ -1018,7 +1018,7 @@ namespace Exiv2 {
fs.close();
} else {
fs.close();
- throw Error(kerErrorMessage, "Unable to decode base 64.");
+ throw Error(ErrorCode::kerErrorMessage, "Unable to decode base 64.");
}
}
@@ -1117,7 +1117,7 @@ namespace Exiv2 {
getDataByRange(static_cast(lowBlock), static_cast(highBlock), data);
rcount = data.length();
if (rcount == 0) {
- throw Error(kerErrorMessage, "Data By Range is empty. Please check the permission.");
+ throw Error(ErrorCode::kerErrorMessage, "Data By Range is empty. Please check the permission.");
}
auto source = reinterpret_cast(const_cast(data.c_str()));
size_t remain = rcount, totalRead = 0;
@@ -1171,7 +1171,7 @@ namespace Exiv2 {
iBlock++;
}
} else if (length == 0) { // file is empty
- throw Error(kerErrorMessage, "the file length is 0");
+ throw Error(ErrorCode::kerErrorMessage, "the file length is 0");
} else {
p_->size_ = static_cast(length);
size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_;
@@ -1284,7 +1284,7 @@ namespace Exiv2 {
DataBuf buf(rcount);
size_t readCount = read(buf.data(), buf.size());
if (readCount == 0) {
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
}
buf.resize(readCount);
return buf;
@@ -1305,7 +1305,7 @@ namespace Exiv2 {
p_->populateBlocks(lowBlock, highBlock);
auto fakeData = static_cast(std::calloc(p_->blockSize_, sizeof(byte)));
if (!fakeData) {
- throw Error(kerErrorMessage, "Unable to allocate data");
+ throw Error(ErrorCode::kerErrorMessage, "Unable to allocate data");
}
size_t iBlock = lowBlock;
@@ -1349,7 +1349,7 @@ namespace Exiv2 {
void RemoteIo::transfer(BasicIo& src)
{
if (src.open() != 0) {
- throw Error(kerErrorMessage, "unable to open src when transferring");
+ throw Error(ErrorCode::kerErrorMessage, "unable to open src when transferring");
}
write(src);
src.close();
@@ -1507,7 +1507,7 @@ namespace Exiv2 {
request["verb"] = "HEAD";
int serverCode = http(request, response, errors);
if (serverCode < 0 || serverCode >= 400 || !errors.empty()) {
- throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
+ throw Error(ErrorCode::kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
auto lengthIter = response.find("Content-Length");
@@ -1532,7 +1532,7 @@ namespace Exiv2 {
int serverCode = http(request, responseDic, errors);
if (serverCode < 0 || serverCode >= 400 || !errors.empty()) {
- throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
+ throw Error(ErrorCode::kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
response = responseDic["body"];
}
@@ -1541,7 +1541,7 @@ namespace Exiv2 {
{
std::string scriptPath(getEnv(envHTTPPOST));
if (scriptPath.empty()) {
- throw Error(kerErrorMessage, "Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable.");
+ throw Error(ErrorCode::kerErrorMessage, "Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable.");
}
// standardize the path without "/" at the beginning.
@@ -1584,7 +1584,7 @@ namespace Exiv2 {
int serverCode = http(request, response, errors);
if (serverCode < 0 || serverCode >= 400 || !errors.empty()) {
- throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
+ throw Error(ErrorCode::kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
}
@@ -1646,7 +1646,7 @@ namespace Exiv2 {
CurlIo::CurlImpl::CurlImpl(const std::string& url, size_t blockSize) : Impl(url, blockSize), curl_(curl_easy_init())
{
if(!curl_) {
- throw Error(kerErrorMessage, "Unable to init libcurl.");
+ throw Error(ErrorCode::kerErrorMessage, "Unable to init libcurl.");
}
// The default block size for FTP is much larger than other protocols
@@ -1659,7 +1659,7 @@ namespace Exiv2 {
std::string timeout = getEnv(envTIMEOUT);
timeout_ = atol(timeout.c_str());
if (timeout_ == 0) {
- throw Error(kerErrorMessage, "Timeout Environmental Variable must be a positive integer.");
+ throw Error(ErrorCode::kerErrorMessage, "Timeout Environmental Variable must be a positive integer.");
}
}
@@ -1679,13 +1679,13 @@ namespace Exiv2 {
/* Perform the request, res will get the return code */
CURLcode res = curl_easy_perform(curl_);
if(res != CURLE_OK) { // error happened
- throw Error(kerErrorMessage, curl_easy_strerror(res));
+ throw Error(ErrorCode::kerErrorMessage, curl_easy_strerror(res));
}
// get status
int serverCode;
curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &serverCode); // get code
if (serverCode >= 400 || serverCode < 0) {
- throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode),path_);
+ throw Error(ErrorCode::kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode),path_);
}
// get length
double temp;
@@ -1717,12 +1717,12 @@ namespace Exiv2 {
CURLcode res = curl_easy_perform(curl_);
if(res != CURLE_OK) {
- throw Error(kerErrorMessage, curl_easy_strerror(res));
+ throw Error(ErrorCode::kerErrorMessage, curl_easy_strerror(res));
}
int serverCode;
curl_easy_getinfo(curl_, CURLINFO_RESPONSE_CODE, &serverCode); // get code
if (serverCode >= 400 || serverCode < 0) {
- throw Error(kerFileOpenFailed, "http", Exiv2::Internal::stringFormat("%d", serverCode), path_);
+ throw Error(ErrorCode::kerFileOpenFailed, "http", Exiv2::Internal::stringFormat("%d", serverCode), path_);
}
}
@@ -1730,7 +1730,7 @@ namespace Exiv2 {
{
std::string scriptPath(getEnv(envHTTPPOST));
if (scriptPath.empty()) {
- throw Error(kerErrorMessage, "Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable.");
+ throw Error(ErrorCode::kerErrorMessage, "Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable.");
}
Exiv2::Uri hostInfo = Exiv2::Uri::Parse(path_);
@@ -1767,12 +1767,12 @@ namespace Exiv2 {
CURLcode res = curl_easy_perform(curl_);
if(res != CURLE_OK) {
- throw Error(kerErrorMessage, curl_easy_strerror(res));
+ throw Error(ErrorCode::kerErrorMessage, curl_easy_strerror(res));
}
int serverCode;
curl_easy_getinfo(curl_, CURLINFO_RESPONSE_CODE, &serverCode);
if (serverCode >= 400 || serverCode < 0) {
- throw Error(kerFileOpenFailed, "http", Exiv2::Internal::stringFormat("%d", serverCode), path_);
+ throw Error(ErrorCode::kerFileOpenFailed, "http", Exiv2::Internal::stringFormat("%d", serverCode), path_);
}
}
@@ -1785,7 +1785,7 @@ namespace Exiv2 {
if (p_->protocol_ == pHttp || p_->protocol_ == pHttps) {
return RemoteIo::write(data, wcount);
}
- throw Error(kerErrorMessage, "doesnt support write for this protocol.");
+ throw Error(ErrorCode::kerErrorMessage, "doesnt support write for this protocol.");
}
size_t CurlIo::write(BasicIo& src)
@@ -1793,7 +1793,7 @@ namespace Exiv2 {
if (p_->protocol_ == pHttp || p_->protocol_ == pHttps) {
return RemoteIo::write(src);
}
- throw Error(kerErrorMessage, "doesnt support write for this protocol.");
+ throw Error(ErrorCode::kerErrorMessage, "doesnt support write for this protocol.");
}
CurlIo::CurlIo(const std::string& url, size_t blockSize)
@@ -1810,16 +1810,16 @@ namespace Exiv2 {
{
FileIo file(path);
if (file.open("rb") != 0) {
- throw Error(kerFileOpenFailed, path, "rb", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path, "rb", strError());
}
struct stat st;
if (0 != ::stat(path.c_str(), &st)) {
- throw Error(kerCallFailed, path, strError(), "::stat");
+ throw Error(ErrorCode::kerCallFailed, path, strError(), "::stat");
}
DataBuf buf(st.st_size);
const size_t len = file.read(buf.data(), buf.size());
if (len != buf.size()) {
- throw Error(kerCallFailed, path, strError(), "FileIo::read");
+ throw Error(ErrorCode::kerCallFailed, path, strError(), "FileIo::read");
}
return buf;
}
@@ -1828,7 +1828,7 @@ namespace Exiv2 {
{
FileIo file(path);
if (file.open("wb") != 0) {
- throw Error(kerFileOpenFailed, path, "wb", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path, "wb", strError());
}
return file.write(buf.c_data(), buf.size());
}
diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp
index 5d20eb4e34..f655d7e5f1 100644
--- a/src/bmffimage.cpp
+++ b/src/bmffimage.cpp
@@ -173,7 +173,7 @@ namespace Exiv2
// never visit a box twice!
if ( depth == 0 ) visits_.clear();
if (visits_.find(address) != visits_.end() || visits_.size() > visits_max_) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
visits_.insert(address);
@@ -186,7 +186,7 @@ namespace Exiv2
byte hdrbuf[2 * sizeof(uint32_t)];
size_t hdrsize = sizeof(hdrbuf);
- enforce(hdrsize <= static_cast(pbox_end - address), Exiv2::kerCorruptedMetadata);
+ enforce(hdrsize <= static_cast(pbox_end - address), Exiv2::ErrorCode::kerCorruptedMetadata);
if (io_->read(reinterpret_cast(&hdrbuf), sizeof(hdrbuf)) != sizeof(hdrbuf))
return pbox_end;
@@ -205,7 +205,7 @@ namespace Exiv2
if (box_length == 1) {
// The box size is encoded as a uint64_t, so we need to read another 8 bytes.
hdrsize += 8;
- enforce(hdrsize <= static_cast(pbox_end - address), Exiv2::kerCorruptedMetadata);
+ enforce(hdrsize <= static_cast(pbox_end - address), Exiv2::ErrorCode::kerCorruptedMetadata);
DataBuf data(8);
io_->read(data.data(), data.size());
box_length = data.read_uint64(0, endian_);
@@ -213,8 +213,8 @@ namespace Exiv2
// read data in box and restore file position
long restore = io_->tell();
- enforce(box_length >= hdrsize, Exiv2::kerCorruptedMetadata);
- enforce(box_length - hdrsize <= static_cast(pbox_end - restore), Exiv2::kerCorruptedMetadata);
+ enforce(box_length >= hdrsize, Exiv2::ErrorCode::kerCorruptedMetadata);
+ enforce(box_length - hdrsize <= static_cast(pbox_end - restore), Exiv2::ErrorCode::kerCorruptedMetadata);
const auto buffer_size = static_cast(box_length - hdrsize);
if (skipBox(box_type)) {
@@ -236,7 +236,7 @@ namespace Exiv2
uint32_t flags = 0;
if (fullBox(box_type)) {
- enforce(data.size() - skip >= 4, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= 4, Exiv2::ErrorCode::kerCorruptedMetadata);
flags = data.read_uint32(skip, endian_); // version/flags
version = static_cast(flags >> 24);
flags &= 0x00ffffff;
@@ -246,7 +246,7 @@ namespace Exiv2
switch (box_type) {
// See notes in skipBox()
case TAG_ftyp: {
- enforce(data.size() >= 4, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() >= 4, Exiv2::ErrorCode::kerCorruptedMetadata);
fileType_ = data.read_uint32(0, endian_);
if ( bTrace ) {
out << "brand: " << toAscii(fileType_);
@@ -260,7 +260,7 @@ namespace Exiv2
bLF = false;
}
- enforce(data.size() - skip >= 2, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= 2, Exiv2::ErrorCode::kerCorruptedMetadata);
uint16_t n = data.read_uint16(skip, endian_);
skip += 2;
@@ -272,7 +272,7 @@ namespace Exiv2
// 8.11.6.2
case TAG_infe: { // .__._.__hvc1_ 2 0 0 1 0 1 0 0 104 118 99 49 0
- enforce(data.size() - skip >= 8, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= 8, Exiv2::ErrorCode::kerCorruptedMetadata);
/* getLong (data.pData_+skip,endian_) ; */ skip += 4;
uint16_t ID = data.read_uint16(skip, endian_);
skip += 2;
@@ -281,7 +281,7 @@ namespace Exiv2
// Check that the string has a '\0' terminator.
const char* str = data.c_str(skip);
const size_t maxlen = data.size() - skip;
- enforce(maxlen > 0 && strnlen(str, maxlen) < maxlen, Exiv2::kerCorruptedMetadata);
+ enforce(maxlen > 0 && strnlen(str, maxlen) < maxlen, Exiv2::ErrorCode::kerCorruptedMetadata);
std::string name(str);
if (name.find("Exif") != std::string::npos) { // "Exif" or "ExifExif"
exifID_ = ID;
@@ -330,7 +330,7 @@ namespace Exiv2
// 8.11.3.1
case TAG_iloc: {
- enforce(data.size() - skip >= 2, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= 2, Exiv2::ErrorCode::kerCorruptedMetadata);
uint8_t u = data.read_uint8(skip++);
uint16_t offsetSize = u >> 4;
uint16_t lengthSize = u & 0xF;
@@ -343,7 +343,7 @@ namespace Exiv2
#else
skip++;
#endif
- enforce(data.size() - skip >= (version < 2u ? 2u : 4u), Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= (version < 2u ? 2u : 4u), Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t itemCount = version < 2 ? data.read_uint16(skip, endian_)
: data.read_uint32(skip, endian_);
skip += version < 2 ? 2 : 4;
@@ -357,8 +357,8 @@ namespace Exiv2
size_t base = skip;
for (uint32_t i = 0; i < itemCount; i++) {
skip = base + i * step; // move in 14, 16 or 18 byte steps
- enforce(data.size() - skip >= (version > 2u ? 4u : 2u), Exiv2::kerCorruptedMetadata);
- enforce(data.size() - skip >= step, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= (version > 2u ? 4u : 2u), Exiv2::ErrorCode::kerCorruptedMetadata);
+ enforce(data.size() - skip >= step, Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t ID = version > 2 ? data.read_uint32(skip, endian_)
: data.read_uint16(skip, endian_);
uint32_t offset = step==14 || step==16 ? data.read_uint32(skip + step - 8, endian_)
@@ -381,7 +381,7 @@ namespace Exiv2
} break;
case TAG_ispe: {
- enforce(data.size() - skip >= 12, Exiv2::kerCorruptedMetadata);
+ enforce(data.size() - skip >= 12, Exiv2::ErrorCode::kerCorruptedMetadata);
skip += 4;
uint32_t width = data.read_uint32(skip, endian_);
skip += 4;
@@ -492,10 +492,10 @@ namespace Exiv2
void BmffImage::parseTiff(uint32_t root_tag, uint64_t length,uint64_t start)
{
- enforce(start <= io_->size(), kerCorruptedMetadata);
- enforce(length <= io_->size() - start, kerCorruptedMetadata);
- enforce(start <= std::numeric_limits::max(), kerCorruptedMetadata);
- enforce(length <= std::numeric_limits::max(), kerCorruptedMetadata);
+ enforce(start <= io_->size(), ErrorCode::kerCorruptedMetadata);
+ enforce(length <= io_->size() - start, ErrorCode::kerCorruptedMetadata);
+ enforce(start <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata);
+ enforce(length <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata);
// read and parse exif data
long restore = io_->tell();
@@ -522,15 +522,15 @@ namespace Exiv2
void BmffImage::parseTiff(uint32_t root_tag, uint64_t length)
{
if (length > 8) {
- enforce(length - 8 <= io_->size() - io_->tell(), kerCorruptedMetadata);
- enforce(length - 8 <= std::numeric_limits::max(), kerCorruptedMetadata);
+ enforce(length - 8 <= io_->size() - io_->tell(), ErrorCode::kerCorruptedMetadata);
+ enforce(length - 8 <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata);
DataBuf data(static_cast(length) - 8);
const size_t bufRead = io_->read(data.data(), data.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != data.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
Internal::TiffParserWorker::decode(exifData(), iptcData(), xmpData(),
data.c_data(), static_cast(data.size()), root_tag,
@@ -541,24 +541,24 @@ namespace Exiv2
void BmffImage::parseXmp(uint64_t length,uint64_t start)
{
if (length > 8) {
- enforce(start <= io_->size(), kerCorruptedMetadata);
- enforce(length <= io_->size() - start, kerCorruptedMetadata);
+ enforce(start <= io_->size(), ErrorCode::kerCorruptedMetadata);
+ enforce(length <= io_->size() - start, ErrorCode::kerCorruptedMetadata);
long restore = io_->tell() ;
- enforce(start <= std::numeric_limits::max(), kerCorruptedMetadata);
+ enforce(start <= std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata);
io_->seek(static_cast(start),BasicIo::beg);
- enforce(length < std::numeric_limits::max(), kerCorruptedMetadata);
+ enforce(length < std::numeric_limits::max(), ErrorCode::kerCorruptedMetadata);
DataBuf xmp(static_cast(length+1));
xmp.write_uint8(static_cast(length), 0); // ensure xmp is null terminated!
if ( io_->read(xmp.data(), static_cast(length)) != length )
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if ( io_->error() )
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
try {
Exiv2::XmpParser::decode(xmpData(), std::string(xmp.c_str()));
} catch (...) {
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
io_->seek(restore,BasicIo::beg);
@@ -579,7 +579,7 @@ namespace Exiv2
long here = io_->tell();
enforce(here >= 0 &&
here <= std::numeric_limits::max() - static_cast(relative_position),
- kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
NativePreview nativePreview;
nativePreview.position_ = here + static_cast(relative_position);
nativePreview.width_ = data.read_uint16(width_offset, endian_);
@@ -607,19 +607,19 @@ namespace Exiv2
void BmffImage::setComment(std::string_view /*comment*/)
{
// bmff files are read-only
- throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "BMFF"));
}
void BmffImage::openOrThrow()
{
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
// Ensure that this is the correct image type
if (!isBmffType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "BMFF");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "BMFF");
}
} // Bmff::openOrThrow();
@@ -659,7 +659,7 @@ namespace Exiv2
case kpsXMP : {
std::string xmp;
if ( Exiv2::XmpParser::encode(xmp, xmpData()) ) {
- throw Exiv2::Error(Exiv2::kerErrorMessage, "Failed to serialize XMP data");
+ throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, "Failed to serialize XMP data");
}
out << xmp;
} break;
@@ -682,7 +682,7 @@ namespace Exiv2
void BmffImage::writeMetadata()
{
// bmff files are read-only
- throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "BMFF"));
} // BmffImage::writeMetadata
// *************************************************************************
diff --git a/src/bmpimage.cpp b/src/bmpimage.cpp
index f60c0e250e..ec4d8fbdc8 100644
--- a/src/bmpimage.cpp
+++ b/src/bmpimage.cpp
@@ -32,17 +32,17 @@ namespace Exiv2
void BmpImage::setExifData(const ExifData& /*exifData*/)
{
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "BMP"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "BMP"));
}
void BmpImage::setIptcData(const IptcData& /*iptcData*/)
{
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "BMP"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "BMP"));
}
void BmpImage::setComment(std::string_view /*comment*/)
{
- throw(Error(kerInvalidSettingForImage, "Image comment", "BMP"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "BMP"));
}
void BmpImage::readMetadata()
@@ -51,15 +51,15 @@ namespace Exiv2
std::cerr << "Exiv2::BmpImage::readMetadata: Reading Windows bitmap file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isBmpType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "BMP");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "BMP");
}
clearMetadata();
@@ -94,7 +94,7 @@ namespace Exiv2
void BmpImage::writeMetadata()
{
/// \todo implement me!
- throw(Error(kerWritingImageFormatUnsupported, "BMP"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "BMP"));
}
// *************************************************************************
diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp
index 3cb04e09c6..2e3cae8345 100644
--- a/src/canonmn_int.cpp
+++ b/src/canonmn_int.cpp
@@ -2767,7 +2767,7 @@ namespace Exiv2::Internal {
if (!std::regex_search(lens.label_, base_match, lens_regex)) {
// this should never happen, as it would indicate the lens is specified incorrectly
// in the CanonCsLensType array
- throw Error(kerErrorMessage, std::string("Lens regex didn't match for: ") + std::string(lens.label_));
+ throw Error(ErrorCode::kerErrorMessage, std::string("Lens regex didn't match for: ") + std::string(lens.label_));
}
auto tc = base_match[5].length() > 0 ? std::stof(base_match[5].str()) : 1.f;
diff --git a/src/cr2image.cpp b/src/cr2image.cpp
index 264e5b04b0..0c3fd97bab 100644
--- a/src/cr2image.cpp
+++ b/src/cr2image.cpp
@@ -49,7 +49,8 @@ namespace Exiv2 {
void Cr2Image::printStructure(std::ostream& out, Exiv2::PrintStructureOption option,int depth)
{
- if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ if (io_->open() != 0)
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
io_->seek(0,BasicIo::beg);
printTiffStructure(io(),out,option,depth-1);
}
@@ -57,7 +58,7 @@ namespace Exiv2 {
void Cr2Image::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "CR2"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "CR2"));
}
void Cr2Image::readMetadata()
@@ -66,13 +67,14 @@ namespace Exiv2 {
std::cerr << "Reading CR2 file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isCr2Type(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "CR2");
+ if (io_->error() || io_->eof())
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "CR2");
}
clearMetadata();
ByteOrder bo =
diff --git a/src/crwimage.cpp b/src/crwimage.cpp
index 88676cf9b6..c7fcd42281 100644
--- a/src/crwimage.cpp
+++ b/src/crwimage.cpp
@@ -52,7 +52,7 @@ namespace Exiv2 {
void CrwImage::setIptcData(const IptcData& /*iptcData*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "CRW"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "CRW"));
}
void CrwImage::readMetadata()
@@ -61,13 +61,14 @@ namespace Exiv2 {
std::cerr << "Reading CRW file " << io_->path() << "\n";
#endif
if (io_->open()) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isCrwType(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotACrwImage);
+ if (io_->error() || io_->eof())
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotACrwImage);
}
clearMetadata();
DataBuf file(io().size());
@@ -102,7 +103,7 @@ namespace Exiv2 {
// Write new buffer to file
auto tempIo = std::make_unique();
- tempIo->write((!blob.empty() ? &blob[0] : nullptr), static_cast(blob.size()));
+ tempIo->write((!blob.empty() ? &blob[0] : nullptr), blob.size());
io_->close();
io_->transfer(*tempIo); // may throw
diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp
index 0cbeae2d0e..e9b90c406d 100644
--- a/src/crwimage_int.cpp
+++ b/src/crwimage_int.cpp
@@ -161,7 +161,7 @@ namespace Exiv2::Internal {
void CiffEntry::doAdd(UniquePtr /*component*/)
{
- throw Error(kerFunctionNotSupported, "CiffEntry::add");
+ throw Error(ErrorCode::kerFunctionNotSupported, "CiffEntry::add");
} // CiffEntry::doAdd
void CiffDirectory::doAdd(UniquePtr component)
@@ -171,7 +171,8 @@ namespace Exiv2::Internal {
void CiffHeader::read(const byte* pData, uint32_t size)
{
- if (size < 14) throw Error(kerNotACrwImage);
+ if (size < 14) throw
+ Error(ErrorCode::kerNotACrwImage);
if (pData[0] == 'I' && pData[0] == pData[1]) {
byteOrder_ = littleEndian;
@@ -180,12 +181,13 @@ namespace Exiv2::Internal {
byteOrder_ = bigEndian;
}
else {
- throw Error(kerNotACrwImage);
+ throw Error(ErrorCode::kerNotACrwImage);
}
offset_ = getULong(pData + 2, byteOrder_);
- if (offset_ < 14 || offset_ > size) throw Error(kerNotACrwImage);
+ if (offset_ < 14 || offset_ > size)
+ throw Error(ErrorCode::kerNotACrwImage);
if (std::memcmp(pData + 6, signature(), 8) != 0) {
- throw Error(kerNotACrwImage);
+ throw Error(ErrorCode::kerNotACrwImage);
}
pPadding_.clear();
@@ -211,7 +213,7 @@ namespace Exiv2::Internal {
ByteOrder byteOrder)
{
// We're going read 10 bytes. Make sure they won't be out-of-bounds.
- enforce(size >= 10 && start <= size - 10, kerNotACrwImage);
+ enforce(size >= 10 && start <= size - 10, ErrorCode::kerNotACrwImage);
tag_ = getUShort(pData + start, byteOrder);
DataLocId dl = dataLocation();
@@ -228,12 +230,12 @@ namespace Exiv2::Internal {
// bytes in memory.
if (offset_ < start) {
// Sub-region is before in memory.
- enforce(size_ <= start - offset_, kerOffsetOutOfRange);
+ enforce(size_ <= start - offset_, ErrorCode::kerOffsetOutOfRange);
} else {
// Sub-region is after in memory.
- enforce(offset_ >= start + 10, kerOffsetOutOfRange);
- enforce(offset_ <= size, kerOffsetOutOfRange);
- enforce(size_ <= size - offset_, kerOffsetOutOfRange);
+ enforce(offset_ >= start + 10, ErrorCode::kerOffsetOutOfRange);
+ enforce(offset_ <= size, ErrorCode::kerOffsetOutOfRange);
+ enforce(size_ <= size - offset_, ErrorCode::kerOffsetOutOfRange);
}
}
if (dl == directoryData) {
@@ -260,7 +262,7 @@ namespace Exiv2::Internal {
std::cout << "Reading directory 0x" << std::hex << tag() << "\n";
#endif
if (this->offset() + this->size() > size)
- throw Error(kerOffsetOutOfRange);
+ throw Error(ErrorCode::kerOffsetOutOfRange);
readDirectory(pData + offset(), this->size(), byteOrder);
#ifdef EXIV2_DEBUG_MESSAGES
@@ -273,10 +275,10 @@ namespace Exiv2::Internal {
ByteOrder byteOrder)
{
if (size < 4)
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
uint32_t o = getULong(pData + size - 4, byteOrder);
if ( o > size-2 )
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
uint16_t count = getUShort(pData + o, byteOrder);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Directory at offset " << std::dec << o
@@ -284,7 +286,7 @@ namespace Exiv2::Internal {
#endif
o += 2;
if ( static_cast(count) * 10 > size-o )
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
for (uint16_t i = 0; i < count; ++i) {
uint16_t tag = getUShort(pData + o, byteOrder);
@@ -544,7 +546,7 @@ namespace Exiv2::Internal {
switch (tag & 0xc000) {
case 0x0000: return valueData;
case 0x4000: return directoryData;
- default: throw Error(kerCorruptedMetadata);
+ default: throw Error(ErrorCode::kerCorruptedMetadata);
}
} // CiffComponent::dataLocation
@@ -810,8 +812,8 @@ namespace Exiv2::Internal {
std::string groupName(Internal::groupName(ifdId));
const uint32_t component_size = ciffComponent.size();
- enforce(component_size % 2 == 0, kerCorruptedMetadata);
- enforce(component_size/2 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata);
+ enforce(component_size % 2 == 0, ErrorCode::kerCorruptedMetadata);
+ enforce(component_size/2 <= static_cast(std::numeric_limits::max()), ErrorCode::kerCorruptedMetadata);
const auto num_components = static_cast(component_size / 2);
uint16_t c = 1;
while (c < num_components) {
@@ -1117,7 +1119,7 @@ namespace Exiv2::Internal {
uint32_t size = 28;
if (cc) {
if (cc->size() < size)
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
size = cc->size();
}
DataBuf buf(size);
diff --git a/src/datasets.cpp b/src/datasets.cpp
index 4f03322f1e..34a1015cca 100644
--- a/src/datasets.cpp
+++ b/src/datasets.cpp
@@ -378,7 +378,6 @@ namespace Exiv2 {
false, false, 0, 0, Exiv2::unsignedShort, IptcDataSets::application2, ""},
};
-
constexpr DataSet unknownDataSet{
0xffff, "Unknown dataset", N_("Unknown dataset"), N_("Unknown dataset"), false, true, 0,
0xffffffff, Exiv2::string, IptcDataSets::invalidRecord, N_("Unknown dataset"),
@@ -489,7 +488,7 @@ namespace Exiv2 {
dataSet = records_[recordId][idx].number_;
} else {
if (!isHex(dataSetName, 4, "0x"))
- throw Error(kerInvalidDataset, dataSetName);
+ throw Error(ErrorCode::kerInvalidDataset, dataSetName);
std::istringstream is(dataSetName);
is >> std::hex >> dataSet;
}
@@ -524,7 +523,7 @@ namespace Exiv2 {
}
if (i == 0) {
if (!isHex(recordName, 4, "0x"))
- throw Error(kerInvalidRecord, recordName);
+ throw Error(ErrorCode::kerInvalidRecord, recordName);
std::istringstream is(recordName);
is >> std::hex >> i;
}
@@ -610,7 +609,7 @@ namespace Exiv2 {
static const std::regex re(R"((\w+)(\.\w+){2})");
std::smatch sm;
if (!std::regex_match(key_, sm, re)) {
- throw Error(kerInvalidKey, key_);
+ throw Error(ErrorCode::kerInvalidKey, key_);
}
// Get the family name, record name and dataSet name parts of the key
@@ -619,7 +618,7 @@ namespace Exiv2 {
const std::string familyName = key_.substr(0, posDot1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
- throw Error(kerInvalidKey, key_);
+ throw Error(ErrorCode::kerInvalidKey, key_);
}
std::string recordName = key_.substr(posDot1+1, posDot2 - posDot1 - 1);
diff --git a/src/epsimage.cpp b/src/epsimage.cpp
index 2e7bcde549..d07e29626d 100644
--- a/src/epsimage.cpp
+++ b/src/epsimage.cpp
@@ -95,7 +95,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to write to temporary file.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -113,7 +113,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Internal error while determining current write position in temporary file.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
return static_cast(pos);
}
@@ -201,7 +201,7 @@ namespace {
EXV_WARNING << "Unable to handle read-only XMP metadata yet. Please provide your "
"sample EPS file to the Exiv2 project: http://dev.exiv2.org/projects/exiv2\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
// search for end of XMP trailer
@@ -214,13 +214,13 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Found XMP header but incomplete XMP trailer.\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
}
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Found XMP header but no XMP trailer.\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
}
}
@@ -230,7 +230,7 @@ namespace {
{
// open input file
if (io.open() != 0) {
- throw Error(kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
@@ -256,7 +256,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Premature end of file after DOS EPS signature.\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
posEps = getULong(data + 4, littleEndian);
posEndEps = getULong(data + 8, littleEndian) + posEps;
@@ -279,31 +279,31 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "DOS EPS file has both WMF and TIFF section. Only one of those is allowed.\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
}
if (sizeWmf == 0 && sizeTiff == 0) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "DOS EPS file has neither WMF nor TIFF section. Exactly one of those is required.\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
}
if (posEps < 30 || posEndEps > size) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "DOS EPS file has invalid position (" << posEps << ") or size (" << (posEndEps - posEps) << ") for EPS section.\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
if (sizeWmf != 0 && (posWmf < 30 || posWmf + sizeWmf > size)) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "DOS EPS file has invalid position (" << posWmf << ") or size (" << sizeWmf << ") for WMF section.\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
}
if (sizeTiff != 0 && (posTiff < 30 || posTiff + sizeTiff > size)) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "DOS EPS file has invalid position (" << posTiff << ") or size (" << sizeTiff << ") for TIFF section.\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -315,7 +315,7 @@ namespace {
#endif
bool matched = std::find(epsFirstLine.begin(), epsFirstLine.end(), firstLine) != epsFirstLine.end();
if (!matched) {
- throw Error(kerNotAnImage, "EPS");
+ throw Error(ErrorCode::kerNotAnImage, "EPS");
}
// determine line ending style of the first line
@@ -323,7 +323,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Premature end of file after first line.\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
const std::string lineEnding(reinterpret_cast(data + posEps + firstLine.size()), posSecondLine - (posEps + firstLine.size()));
#ifdef DEBUG
@@ -378,14 +378,14 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Nested document at invalid position: " << startPos << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
if (startsWith(line, "%%BeginDocument:")) {
if (depth == maxDepth) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Document too deeply nested at position: " << startPos << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
depth++;
} else if (startsWith(line, "%%EndDocument")) {
@@ -393,7 +393,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unmatched EndDocument at position: " << startPos << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
depth--;
} else {
@@ -424,12 +424,12 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Page at position " << startPos << " conflicts with implicit page at position: " << posPage << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unable to handle multiple PostScript pages. Found second page at position: " << startPos << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
} else if (line == "%%BeginPageSetup") {
posBeginPageSetup = startPos;
} else if (!inRemovableEmbedding && line == "%Exiv2BeginXMP: Before %%EndPageSetup") {
@@ -581,7 +581,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unmatched BeginDocument (" << depth << "x)\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
// look for the unmarked trailers of some removable XMP embeddings
@@ -601,7 +601,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unable to find XMP embedding trailer ending at position: " << posXmpTrailerEnd << "\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
break;
}
removableEmbeddings.emplace_back(posXmpTrailer, posXmpTrailerEnd);
@@ -625,7 +625,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Invalid line \"" << line << "\" at position: " << posContainsXmp << "\n";
#endif
- throw Error(write ? kerImageWriteFailed : kerFailedToReadImageData);
+ throw Error(write ? ErrorCode::kerImageWriteFailed : ErrorCode::kerFailedToReadImageData);
}
const bool deleteXmp = (write && xmpPacket.empty());
@@ -672,7 +672,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Missing %begin_xml_packet in Photoshop EPS at position: " << xmpPos << "\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
}
}
if (!useFlexibleEmbedding) {
@@ -693,7 +693,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "XMP metadata block is not removable at position: " << posOtherXmp << "\n";
#endif
- if (write) throw Error(kerImageWriteFailed);
+ if (write) throw Error(ErrorCode::kerImageWriteFailed);
break;
}
}
@@ -780,7 +780,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unable to write to EPS files created by Adobe Illustrator 8.0 or older.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
// create temporary output file
@@ -789,7 +789,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Unable to create temporary file for writing.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef DEBUG
EXV_DEBUG << "readWriteEpsMetadata: Created temporary file " << tempIo->path() << "\n";
@@ -836,7 +836,7 @@ namespace {
EXV_WARNING << "Internal error while assembling the result EPS document: "
"Unable to continue at position " << pos << " after skipping to position " << prevSkipPos << "\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
writeTemp(tempIo, data + prevSkipPos, pos - prevSkipPos);
const size_t posLineEnd = readLine(line, data, pos, posEndEps);
@@ -1025,7 +1025,7 @@ namespace {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Internal error while seeking in temporary file.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
byte dosEpsHeader[30];
dosEpsSignature.copy(reinterpret_cast(dosEpsHeader), dosEpsSignature.size());
@@ -1066,7 +1066,7 @@ namespace Exiv2
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to write blank EPS image.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
}
@@ -1079,7 +1079,7 @@ namespace Exiv2
void EpsImage::setComment(std::string_view /*comment*/)
{
- throw Error(kerInvalidSettingForImage, "Image comment", "EPS");
+ throw Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "EPS");
}
void EpsImage::readMetadata()
@@ -1096,7 +1096,7 @@ namespace Exiv2
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to decode XMP metadata.\n";
#endif
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
#ifdef DEBUG
@@ -1115,7 +1115,7 @@ namespace Exiv2
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to encode XMP metadata.\n";
#endif
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
// write metadata
diff --git a/src/error.cpp b/src/error.cpp
index df44737928..5873e42a81 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -2,164 +2,111 @@
// included header files
#include "error.hpp"
-#include "types.hpp"
#include "i18n.h" // NLS support.
+#include "types.hpp"
// + standard includes
-#include
+#include
#include
+#include
-// *****************************************************************************
-namespace {
-
- //! Helper structure defining an error message.
- struct ErrMsg {
- //! Comparison operator
- bool operator==(int code) const { return code_ == code; }
-
- int code_; //!< Error code
- const char* message_; //!< Error message
- };
-
+namespace
+{
//! Complete list of Exiv2 exception error messages
- const ErrMsg errList[] = {
- { Exiv2::kerGeneralError,
- N_("Error %0: arg2=%2, arg3=%3, arg1=%1.") },
- { Exiv2::kerSuccess,
- N_("Success") },
- { Exiv2::kerErrorMessage,
- "%1" }, // %1=error message
- { Exiv2::kerCallFailed,
- "%1: Call to `%3' failed: %2" }, // %1=path, %2=strerror, %3=function that failed
- { Exiv2::kerNotAnImage,
- N_("This does not look like a %1 image") }, // %1=Image type
- { Exiv2::kerInvalidDataset,
- N_("Invalid dataset name '%1'") }, // %1=dataset name
- { Exiv2::kerInvalidRecord,
- N_("Invalid record name '%1'") }, // %1=record name
- { Exiv2::kerInvalidKey,
- N_("Invalid key '%1'") }, // %1=key
- { Exiv2::kerInvalidTag,
- N_("Invalid tag name or ifdId `%1', ifdId %2") }, // %1=tag name, %2=ifdId
- { Exiv2::kerValueNotSet,
- N_("Value not set") },
- { Exiv2::kerDataSourceOpenFailed,
- N_("%1: Failed to open the data source: %2") }, // %1=path, %2=strerror
- { Exiv2::kerFileOpenFailed,
- N_("%1: Failed to open file (%2): %3") }, // %1=path, %2=mode, %3=strerror
- { Exiv2::kerFileContainsUnknownImageType,
- N_("%1: The file contains data of an unknown image type") }, // %1=path
- { Exiv2::kerMemoryContainsUnknownImageType,
- N_("The memory contains data of an unknown image type") },
- { Exiv2::kerUnsupportedImageType,
- N_("Image type %1 is not supported") }, // %1=image type
- { Exiv2::kerFailedToReadImageData,
- N_("Failed to read image data") },
- { Exiv2::kerNotAJpeg,
- N_("This does not look like a JPEG image") },
- { Exiv2::kerFailedToMapFileForReadWrite,
- N_("%1: Failed to map file for reading and writing: %2") }, // %1=path, %2=strerror
- { Exiv2::kerFileRenameFailed,
- N_("%1: Failed to rename file to %2: %3") }, // %1=old path, %2=new path, %3=strerror
- { Exiv2::kerTransferFailed,
- N_("%1: Transfer failed: %2") }, // %1=path, %2=strerror
- { Exiv2::kerMemoryTransferFailed,
- N_("Memory transfer failed: %1") }, // %1=strerror
- { Exiv2::kerInputDataReadFailed,
- N_("Failed to read input data") },
- { Exiv2::kerImageWriteFailed,
- N_("Failed to write image") },
- { Exiv2::kerNoImageInInputData,
- N_("Input data does not contain a valid image") },
- { Exiv2::kerInvalidIfdId,
- N_("Invalid ifdId %1") }, // %1=ifdId
- { Exiv2::kerValueTooLarge,
- N_("Entry::setValue: Value too large (tag=%1, size=%2, requested=%3)") }, // %1=tag, %2=dataSize, %3=required size
- { Exiv2::kerDataAreaValueTooLarge,
- N_("Entry::setDataArea: Value too large (tag=%1, size=%2, requested=%3)") }, // %1=tag, %2=dataAreaSize, %3=required size
- { Exiv2::kerOffsetOutOfRange,
- N_("Offset out of range") },
- { Exiv2::kerUnsupportedDataAreaOffsetType,
- N_("Unsupported data area offset type") },
- { Exiv2::kerInvalidCharset,
- N_("Invalid charset: `%1'") }, // %1=charset name
- { Exiv2::kerUnsupportedDateFormat,
- N_("Unsupported date format") },
- { Exiv2::kerUnsupportedTimeFormat,
- N_("Unsupported time format") },
- { Exiv2::kerWritingImageFormatUnsupported,
- N_("Writing to %1 images is not supported") }, // %1=image format
- { Exiv2::kerInvalidSettingForImage,
- N_("Setting %1 in %2 images is not supported") }, // %1=metadata type, %2=image format
- { Exiv2::kerNotACrwImage,
- N_("This does not look like a CRW image") },
- { Exiv2::kerFunctionNotSupported,
- N_("%1: Not supported") }, // %1=function
- { Exiv2::kerNoNamespaceInfoForXmpPrefix,
- N_("No namespace info available for XMP prefix `%1'") }, // %1=prefix
- { Exiv2::kerNoPrefixForNamespace,
- N_("No prefix registered for namespace `%2', needed for property path `%1'") }, // %1=namespace
- { Exiv2::kerTooLargeJpegSegment,
- N_("Size of %1 JPEG segment is larger than 65535 bytes") }, // %1=type of metadata (Exif, IPTC, JPEG comment)
- { Exiv2::kerUnhandledXmpdatum,
- N_("Unhandled Xmpdatum %1 of type %2") }, // %1=key, %2=value type
- { Exiv2::kerUnhandledXmpNode,
- N_("Unhandled XMP node %1 with opt=%2") }, // %1=key, %2=XMP Toolkit option flags
- { Exiv2::kerXMPToolkitError,
- N_("XMP Toolkit error %1: %2") }, // %1=XMP_Error::GetID(), %2=XMP_Error::GetErrMsg()
- { Exiv2::kerDecodeLangAltPropertyFailed,
- N_("Failed to decode Lang Alt property %1 with opt=%2") }, // %1=property path, %3=XMP Toolkit option flags
- { Exiv2::kerDecodeLangAltQualifierFailed,
- N_("Failed to decode Lang Alt qualifier %1 with opt=%2") }, // %1=qualifier path, %3=XMP Toolkit option flags
- { Exiv2::kerEncodeLangAltPropertyFailed,
- N_("Failed to encode Lang Alt property %1") }, // %1=key
- { Exiv2::kerPropertyNameIdentificationFailed,
- N_("Failed to determine property name from path %1, namespace %2") }, // %1=property path, %2=namespace
- { Exiv2::kerSchemaNamespaceNotRegistered,
- N_("Schema namespace %1 is not registered with the XMP Toolkit") }, // %1=namespace
- { Exiv2::kerNoNamespaceForPrefix,
- N_("No namespace registered for prefix `%1'") }, // %1=prefix
- { Exiv2::kerAliasesNotSupported,
- N_("Aliases are not supported. Please send this XMP packet to ahuggel@gmx.net `%1', `%2', `%3'") }, // %1=namespace, %2=property path, %3=value
- { Exiv2::kerInvalidXmpText,
- N_("Invalid XmpText type `%1'") }, // %1=type
- { Exiv2::kerTooManyTiffDirectoryEntries,
- N_("TIFF directory %1 has too many entries") }, // %1=TIFF directory name
- { Exiv2::kerMultipleTiffArrayElementTagsInDirectory,
- N_("Multiple TIFF array element tags %1 in one directory") }, // %1=tag number
- { Exiv2::kerWrongTiffArrayElementTagType,
- N_("TIFF array element tag %1 has wrong type") }, // %1=tag number
- { Exiv2::kerInvalidKeyXmpValue,
- N_("%1 has invalid XMP value type `%2'") }, // %1=key, %2=value type
- { Exiv2::kerInvalidIccProfile,
- N_("Not a valid ICC Profile") },
- { Exiv2::kerTiffDirectoryTooLarge,
- N_("tiff directory length is too large") },
- { Exiv2::kerInvalidTypeValue,
- N_("invalid type in tiff structure") },
- { Exiv2::kerInvalidLangAltValue,
- N_("Invalid LangAlt value `%1'") }, // %1=value
- { Exiv2::kerInvalidMalloc,
- N_("invalid memory allocation request") },
- { Exiv2::kerCorruptedMetadata,
- N_("corrupted image metadata") },
- { Exiv2::kerArithmeticOverflow,
- N_("Arithmetic operation overflow") },
- { Exiv2::kerMallocFailed,
- N_("Memory allocation failed")}
+ constexpr std::array errList{
+ N_("Success"), // kerSuccess
+ N_("Error %0: arg2=%2, arg3=%3, arg1=%1."), // KerGeneralError
+ "%1", // kerErrorMessage,
+ "%1: Call to `%3' failed: %2", // KerCallFailed, %1=path, %2=strerror, %3=function that failed
+ N_("This does not look like a %1 image"), // kerNotAnImage, %1=Image type
+ N_("Invalid dataset name '%1'"), // kerInvalidDataset %1=dataset name
+ N_("Invalid record name '%1'"), // kerInvalidRecord %1=record name
+ N_("Invalid key '%1'"), // kerInvalidKey %1=key
+ N_("Invalid tag name or ifdId `%1', ifdId %2"), // kerInvalidTag %1=tag name, %2=ifdId
+ N_("Value not set"), // kerValueNotSet
+ N_("%1: Failed to open the data source: %2"), // kerDataSourceOpenFailed %1=path, %2=strerror
+ N_("%1: Failed to open file (%2): %3"), // kerFileOpenFailed %1=path, %2=mode, %3=strerror
+ N_("%1: The file contains data of an unknown image type"), // kerFileContainsUnknownImageType %1=path
+ N_("The memory contains data of an unknown image type"), // kerMemoryContainsUnknownImageType
+ N_("Image type %1 is not supported"), // kerUnsupportedImageType %1=image type
+ N_("Failed to read image data"), // kerFailedToReadImageData
+ N_("This does not look like a JPEG image"), // kerNotAJpeg
+ N_("%1: Failed to map file for reading and writing: %2"), // kerFailedToMapFileForReadWrite %1=path,
+ // %2=strerror
+ N_("%1: Failed to rename file to %2: %3"), // kerFileRenameFailed %1=old path, %2=new path, %3=strerror
+ N_("%1: Transfer failed: %2"), // kerTransferFailed %1=path, %2=strerror
+ N_("Memory transfer failed: %1"), // kerMemoryTransferFailed %1=strerror
+ N_("Failed to read input data"), // kerInputDataReadFailed
+ N_("Failed to write image"), // kerImageWriteFailed
+ N_("Input data does not contain a valid image"), // kerNoImageInInputData
+ N_("Invalid ifdId %1"), // kerInvalidIfdId %1=ifdId
+ N_("Entry::setValue: Value too large (tag=%1, size=%2, requested=%3)"), // kerValueTooLarge %1=tag,
+ // %2=dataSize, %3=required size
+ N_("Entry::setDataArea: Value too large (tag=%1, size=%2, requested=%3)"), // kerDataAreaValueTooLarge %1=tag,
+ // %2=dataAreaSize, %3=required size
+ N_("Offset out of range"), // kerOffsetOutOfRange
+ N_("Unsupported data area offset type"), // kerUnsupportedDataAreaOffsetType
+ N_("Invalid charset: `%1'"), // kerInvalidCharset %1=charset name
+ N_("Unsupported date format"), // kerUnsupportedDateFormat
+ N_("Unsupported time format"), // kerUnsupportedTimeFormat
+ N_("Writing to %1 images is not supported"), // kerWritingImageFormatUnsupported %1=image format
+ N_("Setting %1 in %2 images is not supported"), // kerInvalidSettingForImage %1=metadata type, %2=image format
+ N_("This does not look like a CRW image"), // kerNotACrwImage
+ N_("%1: Not supported"), // kerFunctionNotSupported %1=function
+ N_("No namespace info available for XMP prefix `%1'"), // kerNoNamespaceInfoForXmpPrefix %1=prefix
+ N_("No prefix registered for namespace `%2', needed for property path `%1'"), // kerNoPrefixForNamespace
+ // %1=namespace
+ N_("Size of %1 JPEG segment is larger than 65535 bytes"), // kerTooLargeJpegSegment %1=type of metadata (Exif,
+ // IPTC, JPEG comment)
+ N_("Unhandled Xmpdatum %1 of type %2"), // kerUnhandledXmpdatum %1=key, %2=value type
+ N_("Unhandled XMP node %1 with opt=%2"), // kerUnhandledXmpNode %1=key, %2=XMP Toolkit option flags
+ N_("XMP Toolkit error %1: %2"), // kerXMPToolkitError %1=XMP_Error::GetID(), %2=XMP_Error::GetErrMsg()
+ N_("Failed to decode Lang Alt property %1 with opt=%2"), // kerDecodeLangAltPropertyFailed %1=property path,
+ // %3=XMP Toolkit option flags
+ N_("Failed to decode Lang Alt qualifier %1 with opt=%2"), // kerDecodeLangAltQualifierFailed %1=qualifier path,
+ // %3=XMP Toolkit option flags
+ N_("Failed to encode Lang Alt property %1"), // kerEncodeLangAltPropertyFailed %1=key
+ N_("Failed to determine property name from path %1, namespace %2"), // kerPropertyNameIdentificationFailed
+ // %1=property path, %2=namespace
+ N_("Schema namespace %1 is not registered with the XMP Toolkit"), // kerSchemaNamespaceNotRegistered
+ // %1=namespace
+ N_("No namespace registered for prefix `%1'"), // kerNoNamespaceForPrefix %1=prefix
+ N_("Aliases are not supported. Please send this XMP packet to ahuggel@gmx.net `%1', `%2', `%3'"), // kerAliasesNotSupported
+ // %1=namespace,
+ // %2=property
+ // path,
+ // %3=value
+ N_("Invalid XmpText type `%1'"), // kerInvalidXmpText %1=type
+ N_("TIFF directory %1 has too many entries"), // kerTooManyTiffDirectoryEntries %1=TIFF directory name
+ N_("Multiple TIFF array element tags %1 in one directory"), // kerMultipleTiffArrayElementTagsInDirectory
+ // %1=tag number
+ N_("TIFF array element tag %1 has wrong type"), // kerWrongTiffArrayElementTagType %1=tag number
+ N_("%1 has invalid XMP value type `%2'"), // kerInvalidKeyXmpValue %1=key, %2=value type
+ N_("Not a valid ICC Profile"), // kerInvalidIccProfile
+ N_("Not valid XMP"), // kerInvalidXMP
+ N_("tiff directory length is too large"), // kerTiffDirectoryTooLarge
+ N_("invalid type in tiff structure"), // kerInvalidTypeValue
+ N_("Invalid LangAlt value `%1'"), // kerInvalidLangAltValue %1=value
+ N_("invalid memory allocation request"), // kerInvalidMalloc
+ N_("corrupted image metadata"), // kerCorruptedMetadata
+ N_("Arithmetic operation overflow"), // kerArithmeticOverflow
+ N_("Memory allocation failed"), // kerMallocFailed
};
+ static_assert(errList.size() == static_cast(Exiv2::ErrorCode::kerErrorCount),
+ "errList needs to contain a error msg for every ErrorCode defined in error.hpp");
} // namespace
// *****************************************************************************
// class member definitions
-namespace Exiv2 {
-
- LogMsg::Level LogMsg::level_ = LogMsg::warn; // Default output level
+namespace Exiv2
+{
+ LogMsg::Level LogMsg::level_ = LogMsg::warn; // Default output level
LogMsg::Handler LogMsg::handler_ = LogMsg::defaultHandler;
LogMsg::LogMsg(LogMsg::Level msgType) : msgType_(msgType)
- {}
+ {
+ }
LogMsg::~LogMsg()
{
@@ -167,50 +114,91 @@ namespace Exiv2 {
handler_(msgType_, os_.str().c_str());
}
- std::ostringstream &LogMsg::os() { return os_; }
+ std::ostringstream& LogMsg::os()
+ {
+ return os_;
+ }
- void LogMsg::setLevel(LogMsg::Level level) { level_ = level; }
+ void LogMsg::setLevel(LogMsg::Level level)
+ {
+ level_ = level;
+ }
- void LogMsg::setHandler(LogMsg::Handler handler) { handler_ = handler; }
+ void LogMsg::setHandler(LogMsg::Handler handler)
+ {
+ handler_ = handler;
+ }
- LogMsg::Level LogMsg::level() { return level_; }
+ LogMsg::Level LogMsg::level()
+ {
+ return level_;
+ }
- LogMsg::Handler LogMsg::handler() { return handler_; }
+ LogMsg::Handler LogMsg::handler()
+ {
+ return handler_;
+ }
void LogMsg::defaultHandler(int level, const char* s)
{
switch (static_cast(level)) {
- case LogMsg::debug: std::cerr << "Debug: "; break;
- case LogMsg::info: std::cerr << "Info: "; break;
- case LogMsg::warn: std::cerr << "Warning: "; break;
- case LogMsg::error: std::cerr << "Error: "; break;
- case LogMsg::mute: assert(false);
+ case LogMsg::debug:
+ std::cerr << "Debug: ";
+ break;
+ case LogMsg::info:
+ std::cerr << "Info: ";
+ break;
+ case LogMsg::warn:
+ std::cerr << "Warning: ";
+ break;
+ case LogMsg::error:
+ std::cerr << "Error: ";
+ break;
+ case LogMsg::mute:
+ assert(false);
}
std::cerr << s;
}
- template<>
- void EXIV2API BasicError::setMsg()
+ Error::Error(ErrorCode code) : code_(code)
+ {
+ setMsg(0);
+ }
+
+ Error::~Error() noexcept
+ {
+ }
+
+ ErrorCode Error::code() const noexcept
{
- std::string msg = _(errMsg(code_));
- std::string::size_type pos;
- pos = msg.find("%0");
+ return code_;
+ }
+
+ const char* Error::what() const noexcept
+ {
+ return msg_.c_str();
+ }
+
+ void Error::setMsg(int count)
+ {
+ std::string msg {errList.at(static_cast(code_))};
+ auto pos = msg.find("%0");
if (pos != std::string::npos) {
- msg.replace(pos, 2, toString(code_));
+ msg.replace(pos, 2, toString(static_cast(code_)));
}
- if (count_ > 0) {
+ if (count > 0) {
pos = msg.find("%1");
if (pos != std::string::npos) {
msg.replace(pos, 2, arg1_);
}
}
- if (count_ > 1) {
+ if (count > 1) {
pos = msg.find("%2");
if (pos != std::string::npos) {
msg.replace(pos, 2, arg2_);
}
}
- if (count_ > 2) {
+ if (count > 2) {
pos = msg.find("%3");
if (pos != std::string::npos) {
msg.replace(pos, 2, arg3_);
@@ -218,14 +206,5 @@ namespace Exiv2 {
}
msg_ = msg;
}
-#ifdef __APPLE__
- template class EXIV2API BasicError;
-#endif
-
- const char* errMsg(int code)
- {
- const ErrMsg* em = find(errList, code);
- return em ? em->message_ : "";
- }
-} // namespace Exiv2
+} // namespace Exiv2
diff --git a/src/exif.cpp b/src/exif.cpp
index ab464d4dc5..a5691e5a0d 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -205,7 +205,7 @@ namespace Exiv2 {
const Value& Exifdatum::value() const
{
if (!value_)
- throw Error(kerValueNotSet);
+ throw Error(ErrorCode::kerValueNotSet);
return *value_;
}
diff --git a/src/futils.cpp b/src/futils.cpp
index 529d717a53..9cf0631521 100644
--- a/src/futils.cpp
+++ b/src/futils.cpp
@@ -243,7 +243,7 @@ namespace Exiv2 {
char buf[n];
std::memset(buf, 0x0, n);
const int ret = strerror_r(error, buf, n);
- enforce(ret != ERANGE, Exiv2::kerCallFailed);
+ enforce(ret != ERANGE, Exiv2::ErrorCode::kerCallFailed);
#endif
os << buf;
// Issue# 908.
diff --git a/src/gifimage.cpp b/src/gifimage.cpp
index 4ae6976c6e..e281cd9698 100644
--- a/src/gifimage.cpp
+++ b/src/gifimage.cpp
@@ -26,19 +26,19 @@ namespace Exiv2 {
void GifImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "GIF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "GIF"));
}
void GifImage::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "GIF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "GIF"));
}
void GifImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "GIF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "GIF"));
}
void GifImage::readMetadata()
@@ -48,14 +48,14 @@ namespace Exiv2 {
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isGifType(*io_, true))
{
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "GIF");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "GIF");
}
clearMetadata();
@@ -70,7 +70,7 @@ namespace Exiv2 {
void GifImage::writeMetadata()
{
// Todo: implement me!
- throw(Error(kerWritingImageFormatUnsupported, "GIF"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "GIF"));
} // GifImage::writeMetadata
// *************************************************************************
diff --git a/src/image.cpp b/src/image.cpp
index d9c6eaa8d2..7cfb46969d 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -132,7 +132,7 @@ namespace Exiv2 {
void Image::printStructure(std::ostream&, PrintStructureOption,int /*depth*/)
{
- throw Error(kerUnsupportedImageType, io_->path());
+ throw Error(ErrorCode::kerUnsupportedImageType, io_->path());
}
bool Image::isStringType(uint16_t type)
@@ -306,14 +306,14 @@ namespace Exiv2 {
do {
// Read top of directory
- io.seekOrThrow(start, BasicIo::beg, kerCorruptedMetadata);
- io.readOrThrow(dir.data(), 2, kerCorruptedMetadata);
+ io.seekOrThrow(start, BasicIo::beg, ErrorCode::kerCorruptedMetadata);
+ io.readOrThrow(dir.data(), 2, ErrorCode::kerCorruptedMetadata);
uint16_t dirLength = byteSwap2(dir,0,bSwap);
// Prevent infinite loops. (GHSA-m479-7frc-gqqg)
- enforce(dirLength > 0, kerCorruptedMetadata);
+ enforce(dirLength > 0, ErrorCode::kerCorruptedMetadata);
if ( dirLength > 500 ) // tooBig
- throw Error(kerTiffDirectoryTooLarge);
+ throw Error(ErrorCode::kerTiffDirectoryTooLarge);
if ( bFirst && bPrint ) {
out << Internal::indent(depth) << Internal::stringFormat("STRUCTURE OF TIFF FILE (%c%c): ",c,c) << io.path() << std::endl;
@@ -322,7 +322,7 @@ namespace Exiv2 {
// Read the dictionary
for ( int i = 0 ; i < dirLength ; i ++ ) {
if ( visits.find(io.tell()) != visits.end() ) { // #547
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
visits.insert(io.tell());
@@ -333,7 +333,7 @@ namespace Exiv2 {
}
bFirst = false;
- io.readOrThrow(dir.data(), 12, kerCorruptedMetadata);
+ io.readOrThrow(dir.data(), 12, ErrorCode::kerCorruptedMetadata);
uint16_t tag = byteSwap2(dir,0,bSwap);
uint16_t type = byteSwap2(dir,2,bSwap);
uint32_t count = byteSwap4(dir,4,bSwap);
@@ -342,7 +342,7 @@ namespace Exiv2 {
// Break for unknown tag types else we may segfault.
if ( !typeValid(type) ) {
EXV_ERROR << "invalid type in tiff structure" << type << std::endl;
- throw Error(kerInvalidTypeValue);
+ throw Error(ErrorCode::kerInvalidTypeValue);
}
std::string sp; // output spacer
@@ -367,11 +367,11 @@ namespace Exiv2 {
// #55 and #56 memory allocation crash test/data/POC8
const uint64_t allocate64 = static_cast(size) * count + pad + 20;
if ( allocate64 > io.size() ) {
- throw Error(kerInvalidMalloc);
+ throw Error(ErrorCode::kerInvalidMalloc);
}
// Overflow check
- enforce(allocate64 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata);
- enforce(allocate64 <= static_cast(std::numeric_limits::max()), kerCorruptedMetadata);
+ enforce(allocate64 <= static_cast(std::numeric_limits::max()), ErrorCode::kerCorruptedMetadata);
+ enforce(allocate64 <= static_cast(std::numeric_limits::max()), ErrorCode::kerCorruptedMetadata);
const auto allocate = static_cast(allocate64);
DataBuf buf(allocate); // allocate a buffer
buf.copyBytes(0, dir.c_data(8), 4); // copy dir[8:11] into buffer (short strings)
@@ -382,9 +382,9 @@ namespace Exiv2 {
if ( bOffsetIsPointer ) { // read into buffer
const long restore = io.tell(); // save
- io.seekOrThrow(offset, BasicIo::beg, kerCorruptedMetadata); // position
- io.readOrThrow(buf.data(), count_x_size, kerCorruptedMetadata); // read
- io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata); // restore
+ io.seekOrThrow(offset, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position
+ io.readOrThrow(buf.data(), count_x_size, ErrorCode::kerCorruptedMetadata); // read
+ io.seekOrThrow(restore, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // restore
}
if ( bPrint ) {
@@ -426,20 +426,20 @@ namespace Exiv2 {
const long restore = io.tell();
offset = byteSwap4(buf,k*size,bSwap);
printIFDStructure(io,out,option,offset,bSwap,c,depth);
- io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata);
+ io.seekOrThrow(restore, BasicIo::beg, ErrorCode::kerCorruptedMetadata);
}
} else if ( option == kpsRecursive && tag == 0x83bb /* IPTCNAA */ ) {
if (count > 0) {
if (static_cast(Safe::add(count, offset)) > io.size()) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
const long restore = io.tell();
- io.seekOrThrow(offset, BasicIo::beg, kerCorruptedMetadata); // position
+ io.seekOrThrow(offset, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position
std::vector bytes(count) ; // allocate memory
// TODO: once we have C++11 use bytes.data()
- io.readOrThrow(&bytes[0], count, kerCorruptedMetadata);
- io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata);
+ io.readOrThrow(&bytes[0], count, ErrorCode::kerCorruptedMetadata);
+ io.seekOrThrow(restore, BasicIo::beg, ErrorCode::kerCorruptedMetadata);
// TODO: once we have C++11 use bytes.data()
IptcData::printStructure(out, makeSliceUntil(&bytes[0], count), depth);
}
@@ -449,8 +449,8 @@ namespace Exiv2 {
uint32_t jump= 10 ;
byte bytes[20] ;
const auto chars = reinterpret_cast(&bytes[0]);
- io.seekOrThrow(offset, BasicIo::beg, kerCorruptedMetadata); // position
- io.readOrThrow(bytes, jump, kerCorruptedMetadata) ; // read
+ io.seekOrThrow(offset, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position
+ io.readOrThrow(bytes, jump, ErrorCode::kerCorruptedMetadata) ; // read
bytes[jump]=0 ;
bool bNikon = ::strcmp("Nikon" ,chars) == 0;
@@ -460,17 +460,17 @@ namespace Exiv2 {
// tag is an embedded tiff
const long byteslen = count-jump;
DataBuf bytes(byteslen); // allocate a buffer
- io.readOrThrow(bytes.data(), byteslen, kerCorruptedMetadata); // read
+ io.readOrThrow(bytes.data(), byteslen, ErrorCode::kerCorruptedMetadata); // read
MemIo memIo(bytes.c_data(), byteslen) ; // create a file
printTiffStructure(memIo,out,option,depth);
} else {
// tag is an IFD
uint32_t punt = bSony ? 12 : 0 ;
- io.seekOrThrow(0, BasicIo::beg, kerCorruptedMetadata); // position
+ io.seekOrThrow(0, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position
printIFDStructure(io,out,option,offset+punt,bSwap,c,depth);
}
- io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata); // restore
+ io.seekOrThrow(restore, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // restore
}
}
@@ -483,7 +483,7 @@ namespace Exiv2 {
}
}
if ( start ) {
- io.readOrThrow(dir.data(), 4, kerCorruptedMetadata);
+ io.readOrThrow(dir.data(), 4, ErrorCode::kerCorruptedMetadata);
start = byteSwap4(dir,0,bSwap);
}
} while (start) ;
@@ -502,7 +502,7 @@ namespace Exiv2 {
DataBuf dir(dirSize);
// read header (we already know for certain that we have a Tiff file)
- io.readOrThrow(dir.data(), 8, kerCorruptedMetadata);
+ io.readOrThrow(dir.data(), 8, ErrorCode::kerCorruptedMetadata);
auto c = static_cast(dir.read_uint8(0));
bool bSwap = ( c == 'M' && isLittleEndianPlatform() )
|| ( c == 'I' && isBigEndianPlatform() )
@@ -598,7 +598,7 @@ namespace Exiv2 {
void Image::setXmpPacket(const std::string& xmpPacket)
{
if ( XmpParser::decode(xmpData_, xmpPacket) ) {
- throw Error(kerInvalidXMP);
+ throw Error(ErrorCode::kerInvalidXMP);
}
xmpPacket_ = xmpPacket;
}
@@ -638,11 +638,11 @@ namespace Exiv2 {
{
if ( bTestValid ) {
if (iccProfile.size() < static_cast(sizeof(long))) {
- throw Error(kerInvalidIccProfile);
+ throw Error(ErrorCode::kerInvalidIccProfile);
}
const size_t size = iccProfile.read_uint32(0, bigEndian);
if (size != iccProfile.size()) {
- throw Error(kerInvalidIccProfile);
+ throw Error(ErrorCode::kerInvalidIccProfile);
}
}
iccProfile_ = std::move(iccProfile);
@@ -755,7 +755,7 @@ namespace Exiv2 {
{
const Registry* r = find(registry, type);
if (!r)
- throw Error(kerUnsupportedImageType, static_cast(type));
+ throw Error(ErrorCode::kerUnsupportedImageType, static_cast(type));
AccessMode am = amNone;
switch (metadataId) {
case mdNone:
@@ -839,7 +839,7 @@ namespace Exiv2 {
{
auto image = open(ImageFactory::createIo(path, useCurl)); // may throw
if (!image)
- throw Error(kerFileContainsUnknownImageType, path);
+ throw Error(ErrorCode::kerFileContainsUnknownImageType, path);
return image;
}
@@ -848,14 +848,14 @@ namespace Exiv2 {
auto io = std::make_unique(data, size);
auto image = open(std::move(io)); // may throw
if (!image)
- throw Error(kerMemoryContainsUnknownImageType);
+ throw Error(ErrorCode::kerMemoryContainsUnknownImageType);
return image;
}
Image::UniquePtr ImageFactory::open(BasicIo::UniquePtr io)
{
if (io->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io->path(), strError());
}
for (unsigned int i = 0; registry[i].imageType_ != ImageType::none; ++i) {
if (registry[i].isThisType_(*io, false)) {
@@ -870,14 +870,14 @@ namespace Exiv2 {
auto fileIo = std::make_unique(path);
// Create or overwrite the file, then close it
if (fileIo->open("w+b") != 0) {
- throw Error(kerFileOpenFailed, path, "w+b", strError());
+ throw Error(ErrorCode::kerFileOpenFailed, path, "w+b", strError());
}
fileIo->close();
BasicIo::UniquePtr io(std::move(fileIo));
auto image = create(type, std::move(io));
if (!image)
- throw Error(kerUnsupportedImageType, static_cast(type));
+ throw Error(ErrorCode::kerUnsupportedImageType, static_cast(type));
return image;
}
@@ -886,7 +886,7 @@ namespace Exiv2 {
auto io = std::make_unique();
auto image = create(type, std::move(io));
if (!image)
- throw Error(kerUnsupportedImageType, static_cast(type));
+ throw Error(ErrorCode::kerUnsupportedImageType, static_cast(type));
return image;
}
diff --git a/src/iptc.cpp b/src/iptc.cpp
index b303bb38d5..953da4e1e8 100644
--- a/src/iptc.cpp
+++ b/src/iptc.cpp
@@ -131,7 +131,7 @@ namespace Exiv2 {
const Value& Iptcdatum::value() const
{
if (!value_)
- throw Error(kerValueNotSet);
+ throw Error(ErrorCode::kerValueNotSet);
return *value_;
}
@@ -287,12 +287,12 @@ namespace Exiv2 {
char buff[100];
uint16_t record = bytes.at(i + 1);
uint16_t dataset = bytes.at(i + 2);
- enforce(bytes.size() - i >= 5, kerCorruptedMetadata);
+ enforce(bytes.size() - i >= 5, ErrorCode::kerCorruptedMetadata);
uint16_t len = getUShort(bytes.subSlice(i + 3, bytes.size()), bigEndian);
snprintf(buff, sizeof(buff), " %6d | %7d | %-24s | %6d | ", record, dataset,
Exiv2::IptcDataSets::dataSetName(dataset, record).c_str(), len);
- enforce(bytes.size() - i >= 5 + static_cast(len), kerCorruptedMetadata);
+ enforce(bytes.size() - i >= 5 + static_cast(len), ErrorCode::kerCorruptedMetadata);
out << buff << Internal::binaryToString(makeSlice(bytes, i + 5, i + 5 + (len > 40 ? 40 : len)))
<< (len > 40 ? "..." : "")
<< std::endl;
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
index 2d2dbbcc13..96e37c1e88 100644
--- a/src/jp2image.cpp
+++ b/src/jp2image.cpp
@@ -137,7 +137,7 @@ namespace Exiv2
void Jp2Image::setComment(std::string_view /*comment*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Image comment", "JP2"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "JP2"));
}
static void lf(std::ostream& out,bool& bLF)
@@ -176,7 +176,7 @@ static void boxes_check(size_t b,size_t m)
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata box maximum exceeded" << std::endl;
#endif
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
}
@@ -187,14 +187,14 @@ static void boxes_check(size_t b,size_t m)
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isJp2Type(*io_, true))
{
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "JPEG-2000");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "JPEG-2000");
}
Jp2BoxHeader box = {0,0};
@@ -216,7 +216,7 @@ static void boxes_check(size_t b,size_t m)
<< " length: " << box.length
<< std::endl;
#endif
- enforce(box.length <= sizeof(box)+io_->size()-io_->tell() , Exiv2::kerCorruptedMetadata);
+ enforce(box.length <= sizeof(box)+io_->size()-io_->tell() , Exiv2::ErrorCode::kerCorruptedMetadata);
if (box.length == 0) return ;
@@ -240,7 +240,7 @@ static void boxes_check(size_t b,size_t m)
subBox.length = getLong(reinterpret_cast(&subBox.length), bigEndian);
subBox.type = getLong(reinterpret_cast(&subBox.type), bigEndian);
if (subBox.length > io_->size() ) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
@@ -257,7 +257,7 @@ static void boxes_check(size_t b,size_t m)
const size_t data_length = Safe::add(subBox.length, static_cast(8));
// data_length makes no sense if it is larger than the rest of the file
if (data_length > io_->size() - io_->tell()) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
DataBuf data(data_length);
io_->read(data.data(), data.size());
@@ -265,7 +265,7 @@ static void boxes_check(size_t b,size_t m)
// subtracting pad from data.size() is safe:
// data.size() is at least 8 and pad = 3
if (iccLength > data.size() - pad) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
DataBuf icc(iccLength);
icc.copyBytes(0, data.c_data(pad), icc.size());
@@ -299,7 +299,7 @@ static void boxes_check(size_t b,size_t m)
io_->seek(restore,BasicIo::beg);
if ( io_->seek(subBox.length, Exiv2::BasicIo::cur) != 0 ) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
restore = io_->tell();
}
@@ -324,11 +324,11 @@ static void boxes_check(size_t b,size_t m)
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: Exif data found" << std::endl ;
#endif
- enforce(box.length >= sizeof(box) + sizeof(uuid), kerCorruptedMetadata);
+ enforce(box.length >= sizeof(box) + sizeof(uuid), ErrorCode::kerCorruptedMetadata);
rawData.alloc(box.length - (sizeof(box) + sizeof(uuid)));
bufRead = io_->read(rawData.data(), rawData.size());
- if (io_->error()) throw Error(kerFailedToReadImageData);
- if (bufRead != rawData.size()) throw Error(kerInputDataReadFailed);
+ if (io_->error()) throw Error(ErrorCode::kerFailedToReadImageData);
+ if (bufRead != rawData.size()) throw Error(ErrorCode::kerInputDataReadFailed);
if (rawData.size() > 8) // "II*\0long"
{
@@ -378,11 +378,11 @@ static void boxes_check(size_t b,size_t m)
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: Iptc data found" << std::endl;
#endif
- enforce(box.length >= sizeof(box) + sizeof(uuid), kerCorruptedMetadata);
+ enforce(box.length >= sizeof(box) + sizeof(uuid), ErrorCode::kerCorruptedMetadata);
rawData.alloc(box.length - (sizeof(box) + sizeof(uuid)));
bufRead = io_->read(rawData.data(), rawData.size());
- if (io_->error()) throw Error(kerFailedToReadImageData);
- if (bufRead != rawData.size()) throw Error(kerInputDataReadFailed);
+ if (io_->error()) throw Error(ErrorCode::kerFailedToReadImageData);
+ if (bufRead != rawData.size()) throw Error(ErrorCode::kerInputDataReadFailed);
if (IptcParser::decode(iptcData_, rawData.c_data(), static_cast(rawData.size())))
{
@@ -398,13 +398,13 @@ static void boxes_check(size_t b,size_t m)
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found" << std::endl;
#endif
- enforce(box.length >= sizeof(box) + sizeof(uuid), kerCorruptedMetadata);
+ enforce(box.length >= sizeof(box) + sizeof(uuid), ErrorCode::kerCorruptedMetadata);
rawData.alloc(box.length - static_cast(sizeof(box) + sizeof(uuid)));
bufRead = io_->read(rawData.data(), rawData.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != rawData.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
xmpPacket_.assign(rawData.c_str(), rawData.size());
std::string::size_type idx = xmpPacket_.find_first_of('<');
@@ -434,7 +434,7 @@ static void boxes_check(size_t b,size_t m)
// Move to the next box.
io_->seek(static_cast(position - sizeof(box) + box.length), BasicIo::beg);
- if (io_->error()) throw Error(kerFailedToReadImageData);
+ if (io_->error()) throw Error(ErrorCode::kerFailedToReadImageData);
}
} // Jp2Image::readMetadata
@@ -442,13 +442,13 @@ static void boxes_check(size_t b,size_t m)
void Jp2Image::printStructure(std::ostream& out, PrintStructureOption option, int depth)
{
if (io_->open() != 0)
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if (!isJp2Type(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
bool bPrint = option == kpsBasic || option == kpsRecursive;
@@ -474,7 +474,7 @@ static void boxes_check(size_t b,size_t m)
long position = io_->tell();
box.length = getLong(reinterpret_cast(&box.length), bigEndian);
box.type = getLong(reinterpret_cast(&box.type), bigEndian);
- enforce(box.length <= sizeof(box)+io_->size()-io_->tell() , Exiv2::kerCorruptedMetadata);
+ enforce(box.length <= sizeof(box)+io_->size()-io_->tell() , Exiv2::ErrorCode::kerCorruptedMetadata);
if (bPrint) {
out << Internal::stringFormat("%8ld | %8ld | ", position - sizeof(box),
@@ -499,7 +499,7 @@ static void boxes_check(size_t b,size_t m)
subBox.type = getLong(reinterpret_cast(&subBox.type), bigEndian);
if (subBox.length < sizeof(box) || subBox.length > io_->size() - io_->tell()) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
DataBuf data(subBox.length - sizeof(box));
@@ -515,7 +515,7 @@ static void boxes_check(size_t b,size_t m)
const size_t pad = 3; // don't know why there are 3 padding bytes
// Bounds-check for the `getULong()` below, which reads 4 bytes, starting at `pad`.
- enforce(data.size() >= pad + 4, kerCorruptedMetadata);
+ enforce(data.size() >= pad + 4, ErrorCode::kerCorruptedMetadata);
if (bPrint) {
out << " | pad:";
@@ -527,7 +527,7 @@ static void boxes_check(size_t b,size_t m)
if (bPrint) {
out << " | iccLength:" << iccLength;
}
- enforce(iccLength <= data.size() - pad, kerCorruptedMetadata);
+ enforce(iccLength <= data.size() - pad, ErrorCode::kerCorruptedMetadata);
if (bICC) {
out.write(data.c_str(pad), iccLength);
}
@@ -556,13 +556,13 @@ static void boxes_check(size_t b,size_t m)
}
DataBuf rawData;
- enforce(box.length >= sizeof(uuid) + sizeof(box), kerCorruptedMetadata);
+ enforce(box.length >= sizeof(uuid) + sizeof(box), ErrorCode::kerCorruptedMetadata);
rawData.alloc(box.length - sizeof(uuid) - sizeof(box));
const size_t bufRead = io_->read(rawData.data(), rawData.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != rawData.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if (bPrint) {
out << Internal::binaryToString(
@@ -597,7 +597,7 @@ static void boxes_check(size_t b,size_t m)
// Move to the next box.
io_->seek(static_cast(position - sizeof(box) + box.length), BasicIo::beg);
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bPrint)
lf(out, bLF);
}
@@ -608,7 +608,7 @@ static void boxes_check(size_t b,size_t m)
{
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -630,16 +630,16 @@ static void boxes_check(size_t b,size_t m)
DataBuf output(boxBuf.size() + iccProfile_.size() + 100); // allocate sufficient space
long outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output?
long inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf?
- enforce(sizeof(Jp2BoxHeader) <= output.size(), Exiv2::kerCorruptedMetadata);
+ enforce(sizeof(Jp2BoxHeader) <= output.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
auto pBox = reinterpret_cast(boxBuf.c_data());
uint32_t length = getLong(reinterpret_cast(&pBox->length), bigEndian);
- enforce(length <= output.size(), Exiv2::kerCorruptedMetadata);
+ enforce(length <= output.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t count = sizeof (Jp2BoxHeader);
auto p = boxBuf.c_str();
bool bWroteColor = false ;
while ( count < length && !bWroteColor ) {
- enforce(sizeof(Jp2BoxHeader) <= length - count, Exiv2::kerCorruptedMetadata);
+ enforce(sizeof(Jp2BoxHeader) <= length - count, Exiv2::ErrorCode::kerCorruptedMetadata);
auto pSubBox = reinterpret_cast(p + count);
// copy data. pointer could be into a memory mapped file which we will decode!
@@ -652,8 +652,8 @@ static void boxes_check(size_t b,size_t m)
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Jp2Image::encodeJp2Header subbox: "<< toAscii(subBox.type) << " length = " << subBox.length << std::endl;
#endif
- enforce(subBox.length > 0, Exiv2::kerCorruptedMetadata);
- enforce(subBox.length <= length - count, Exiv2::kerCorruptedMetadata);
+ enforce(subBox.length > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
+ enforce(subBox.length <= length - count, Exiv2::ErrorCode::kerCorruptedMetadata);
count += subBox.length;
newBox.type = subBox.type;
} else {
@@ -669,7 +669,7 @@ static void boxes_check(size_t b,size_t m)
const char* pad = "\x01\x00\x00\x00\x00\x00\x10\x00\x00\x05\x1cuuid";
uint32_t psize = 15;
newlen = sizeof(newBox) + psize ;
- enforce(newlen <= output.size() - outlen, Exiv2::kerCorruptedMetadata);
+ enforce(newlen <= output.size() - outlen, Exiv2::ErrorCode::kerCorruptedMetadata);
ul2Data(reinterpret_cast(&newBox.length), psize, bigEndian);
ul2Data(reinterpret_cast(&newBox.type), newBox.type, bigEndian);
output.copyBytes(outlen ,&newBox ,sizeof(newBox));
@@ -678,7 +678,7 @@ static void boxes_check(size_t b,size_t m)
const char* pad = "\x02\x00\x00";
uint32_t psize = 3;
newlen = sizeof(newBox) + psize + static_cast(iccProfile_.size());
- enforce(newlen <= static_cast(output.size() - outlen), Exiv2::kerCorruptedMetadata);
+ enforce(newlen <= static_cast(output.size() - outlen), Exiv2::ErrorCode::kerCorruptedMetadata);
ul2Data(reinterpret_cast(&newBox.length), newlen, bigEndian);
ul2Data(reinterpret_cast(&newBox.type), newBox.type, bigEndian);
output.copyBytes(outlen ,&newBox ,sizeof(newBox) );
@@ -686,7 +686,7 @@ static void boxes_check(size_t b,size_t m)
output.copyBytes(outlen+sizeof(newBox)+psize,iccProfile_.c_data(),iccProfile_.size());
}
} else {
- enforce(newlen <= static_cast(output.size() - outlen), Exiv2::kerCorruptedMetadata);
+ enforce(newlen <= static_cast(output.size() - outlen), Exiv2::ErrorCode::kerCorruptedMetadata);
output.copyBytes(outlen,boxBuf.c_data(inlen),subBox.length);
}
@@ -708,8 +708,8 @@ static void boxes_check(size_t b,size_t m)
void Jp2Image::doWriteMetadata(BasicIo& outIo)
{
- if (!io_->isopen()) throw Error(kerInputDataReadFailed);
- if (!outIo.isopen()) throw Error(kerImageWriteFailed);
+ if (!io_->isopen()) throw Error(ErrorCode::kerInputDataReadFailed);
+ if (!outIo.isopen()) throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Writing JPEG-2000 file " << io_->path() << std::endl;
@@ -719,12 +719,12 @@ static void boxes_check(size_t b,size_t m)
// Ensure that this is the correct image type
if (!isJp2Type(*io_, true))
{
- if (io_->error() || io_->eof()) throw Error(kerInputDataReadFailed);
- throw Error(kerNoImageInInputData);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerInputDataReadFailed);
+ throw Error(ErrorCode::kerNoImageInInputData);
}
// Write JPEG2000 Signature.
- if (outIo.write(Jp2Signature, 12) != 12) throw Error(kerImageWriteFailed);
+ if (outIo.write(Jp2Signature, 12) != 12) throw Error(ErrorCode::kerImageWriteFailed);
Jp2BoxHeader box = {0,0};
@@ -743,9 +743,9 @@ static void boxes_check(size_t b,size_t m)
// Read chunk header.
size_t bufRead = io_->read(bheaderBuf.data(), bheaderBuf.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != bheaderBuf.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
// Decode box header.
@@ -768,11 +768,11 @@ static void boxes_check(size_t b,size_t m)
if (box.length < 8)
{
// box is broken, so there is nothing we can do here
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
// Prevent a malicious file from causing a large memory allocation.
- enforce(box.length - 8 <= static_cast(io_->size() - io_->tell()), kerCorruptedMetadata);
+ enforce(box.length - 8 <= static_cast(io_->size() - io_->tell()), ErrorCode::kerCorruptedMetadata);
// Read whole box : Box header + Box data (not fixed size - can be null).
DataBuf boxBuf(box.length); // Box header (8 bytes) + box data.
@@ -784,14 +784,14 @@ static void boxes_check(size_t b,size_t m)
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Error reading source file" << std::endl;
#endif
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
if (bufRead != (box.length - 8)) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Cannot read source file data" << std::endl;
#endif
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
}
switch(box.type)
@@ -804,7 +804,7 @@ static void boxes_check(size_t b,size_t m)
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write JP2Header box (length: " << box.length << ")" << std::endl;
#endif
if (outIo.write(newBuf.data(), newBuf.size()) != newBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write all updated metadata here, just after JP2Header.
@@ -831,7 +831,7 @@ static void boxes_check(size_t b,size_t m)
<< boxData.size() << std::endl;
#endif
if (outIo.write(boxData.c_data(), boxData.size()) != boxData.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -854,7 +854,7 @@ static void boxes_check(size_t b,size_t m)
<< boxData.size() << std::endl;
#endif
if (outIo.write(boxData.c_data(), boxData.size()) != boxData.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -883,7 +883,7 @@ static void boxes_check(size_t b,size_t m)
<< boxData.size() << ")" << std::endl;
#endif
if (outIo.write(boxData.c_data(), boxData.size()) != boxData.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
break;
@@ -891,7 +891,7 @@ static void boxes_check(size_t b,size_t m)
case kJp2BoxTypeUuid:
{
- enforce(boxBuf.size() >= 24, Exiv2::kerCorruptedMetadata);
+ enforce(boxBuf.size() >= 24, Exiv2::ErrorCode::kerCorruptedMetadata);
if (boxBuf.cmpBytes(8, kJp2UuidExif, 16) == 0)
{
#ifdef EXIV2_DEBUG_MESSAGES
@@ -916,7 +916,7 @@ static void boxes_check(size_t b,size_t m)
std::cout << "Exiv2::Jp2Image::doWriteMetadata: write Uuid box (length: " << box.length << ")" << std::endl;
#endif
if (outIo.write(boxBuf.c_data(), boxBuf.size()) != boxBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
break;
}
@@ -927,7 +927,7 @@ static void boxes_check(size_t b,size_t m)
std::cout << "Exiv2::Jp2Image::doWriteMetadata: write box (length: " << box.length << ")" << std::endl;
#endif
if (outIo.write(boxBuf.c_data(), boxBuf.size()) != boxBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
break;
}
diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp
index 11f4eb1917..fbcaecf5ce 100644
--- a/src/jpgimage.cpp
+++ b/src/jpgimage.cpp
@@ -287,12 +287,12 @@ namespace Exiv2 {
{
int rc = 0; // Todo: this should be the return value
- if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ if (io_->open() != 0) throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isThisType(*io_, true)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
clearMetadata();
int search = 6 ; // Exif, ICC, XMP, Comment, IPTC, SOF
@@ -303,23 +303,23 @@ namespace Exiv2 {
bool foundIccData = false;
// Read section marker
- byte marker = advanceToMarker(kerNotAJpeg);
+ byte marker = advanceToMarker(ErrorCode::kerNotAJpeg);
while (marker != sos_ && marker != eoi_ && search > 0) {
// 2-byte buffer for reading the size.
byte sizebuf[2];
uint16_t size = 0; // Size of the segment, including the 2-byte size field
if (markerHasLength(marker)) {
- io_->readOrThrow(sizebuf, 2, kerFailedToReadImageData);
+ io_->readOrThrow(sizebuf, 2, ErrorCode::kerFailedToReadImageData);
size = getUShort(sizebuf, bigEndian);
- enforce(size >= 2, kerFailedToReadImageData);
+ enforce(size >= 2, ErrorCode::kerFailedToReadImageData);
}
// Read the rest of the segment.
DataBuf buf(size);
/// \todo check if it makes sense to check for size
if (size > 0) {
- io_->readOrThrow(buf.data(2), size - 2, kerFailedToReadImageData);
+ io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
buf.copyBytes(0, sizebuf, 2);
}
@@ -407,7 +407,7 @@ namespace Exiv2 {
// #1286 profile can be padded
size_t icc_size = size-2-14;
if (chunk==1 && chunks==1) {
- enforce(s <= static_cast(icc_size), kerInvalidIccProfile);
+ enforce(s <= static_cast(icc_size), ErrorCode::kerInvalidIccProfile);
icc_size = s;
}
@@ -431,7 +431,7 @@ namespace Exiv2 {
// Read the beginning of the next segment
try {
- marker = advanceToMarker(kerFailedToReadImageData);
+ marker = advanceToMarker(ErrorCode::kerFailedToReadImageData);
} catch (Error&) {
rc = 5;
break;
@@ -479,12 +479,12 @@ namespace Exiv2 {
void JpegBase::printStructure(std::ostream& out, PrintStructureOption option, int depth)
{
if (io_->open() != 0)
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if (!isThisType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
bool bPrint = option == kpsBasic || option == kpsRecursive;
@@ -517,7 +517,7 @@ namespace Exiv2 {
bool bExtXMP = false;
// Read section marker
- byte marker = advanceToMarker(kerNotAJpeg);
+ byte marker = advanceToMarker(ErrorCode::kerNotAJpeg);
bool done = false;
bool first = true;
@@ -535,18 +535,18 @@ namespace Exiv2 {
byte sizebuf[2];
uint16_t size = 0;
if (markerHasLength(marker)) {
- io_->readOrThrow(sizebuf, 2, kerFailedToReadImageData);
+ io_->readOrThrow(sizebuf, 2, ErrorCode::kerFailedToReadImageData);
size = getUShort(sizebuf, bigEndian);
// `size` is the size of the segment, including the 2-byte size field
// that we just read.
- enforce(size >= 2, kerFailedToReadImageData);
+ enforce(size >= 2, ErrorCode::kerFailedToReadImageData);
}
// Read the rest of the segment.
DataBuf buf(size);
if (size > 0) {
assert(size >= 2); // enforced above
- io_->readOrThrow(buf.data(2), size - 2, kerFailedToReadImageData);
+ io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
buf.copyBytes(0, sizebuf, 2);
}
@@ -596,7 +596,7 @@ namespace Exiv2 {
start = 2 + 35 + 32 + 4 + 4; // Adobe Spec, p19
}
- enforce(start <= size, kerInvalidXmpText);
+ enforce(start <= size, ErrorCode::kerInvalidXmpText);
out.write(reinterpret_cast(&xmp[start]), size - start);
done = !bExtXMP;
} else if (option == kpsIccProfile && signature == iccId_) {
@@ -709,7 +709,7 @@ namespace Exiv2 {
if (marker != sos_) {
// Read the beginning of the next segment
- marker = advanceToMarker(kerNoImageInInputData);
+ marker = advanceToMarker(ErrorCode::kerNoImageInInputData);
REPORT_MARKER;
}
done |= marker == eoi_ || marker == sos_;
@@ -764,16 +764,16 @@ namespace Exiv2 {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << start << ":" << length << std::endl;
#endif
- io_->seekOrThrow(start, BasicIo::beg, kerFailedToReadImageData);
+ io_->seekOrThrow(start, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
DataBuf buf(length);
- io_->readOrThrow(buf.data(), buf.size(), kerFailedToReadImageData);
+ io_->readOrThrow(buf.data(), buf.size(), ErrorCode::kerFailedToReadImageData);
tempIo->write(buf.c_data(), buf.size());
}
}
- io_->seekOrThrow(0, BasicIo::beg, kerFailedToReadImageData);
+ io_->seekOrThrow(0, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
io_->transfer(*tempIo); // may throw
- io_->seekOrThrow(0, BasicIo::beg, kerFailedToReadImageData);
+ io_->seekOrThrow(0, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
readMetadata();
}
} // JpegBase::printStructure
@@ -781,7 +781,7 @@ namespace Exiv2 {
void JpegBase::writeMetadata()
{
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -797,18 +797,18 @@ namespace Exiv2 {
byte sizebuf[2];
uint16_t size = 0;
if (markerHasLength(marker)) {
- io_->readOrThrow(sizebuf, 2, kerFailedToReadImageData);
+ io_->readOrThrow(sizebuf, 2, ErrorCode::kerFailedToReadImageData);
size = getUShort(sizebuf, bigEndian);
// `size` is the size of the segment, including the 2-byte size field
// that we just read.
- enforce(size >= 2, kerFailedToReadImageData);
+ enforce(size >= 2, ErrorCode::kerFailedToReadImageData);
}
// Read the rest of the segment.
DataBuf buf(size);
if (size > 0) {
assert(size >= 2); // enforced above
- io_->readOrThrow(buf.data(2), size - 2, kerFailedToReadImageData);
+ io_->readOrThrow(buf.data(2), size - 2, ErrorCode::kerFailedToReadImageData);
buf.copyBytes(0, sizebuf, 2);
}
return buf;
@@ -817,15 +817,15 @@ namespace Exiv2 {
void JpegBase::doWriteMetadata(BasicIo& outIo)
{
if (!io_->isopen())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if (!outIo.isopen())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Ensure that this is the correct image type
if (!isThisType(*io_, true)) {
if (io_->error() || io_->eof())
- throw Error(kerInputDataReadFailed);
- throw Error(kerNoImageInInputData);
+ throw Error(ErrorCode::kerInputDataReadFailed);
+ throw Error(ErrorCode::kerNoImageInInputData);
}
// Used to initialize search variables such as skipCom.
@@ -849,10 +849,10 @@ namespace Exiv2 {
// Write image header
if (writeHeader(outIo))
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Read section marker
- byte marker = advanceToMarker(kerNoImageInInputData);
+ byte marker = advanceToMarker(ErrorCode::kerNoImageInInputData);
// First find segments of interest. Normally app0 is first and we want
// to insert after it. But if app0 comes after com, app1 and app13 then
@@ -916,12 +916,12 @@ namespace Exiv2 {
comPos = count;
++search;
}
- marker = advanceToMarker(kerNoImageInInputData);
+ marker = advanceToMarker(ErrorCode::kerNoImageInInputData);
++count;
}
if (!foundCompletePsData && !psBlob.empty())
- throw Error(kerNoImageInInputData);
+ throw Error(ErrorCode::kerNoImageInInputData);
search += skipApp13Ps3.size() + skipApp2Icc.size();
if (comPos == 0) {
@@ -942,9 +942,9 @@ namespace Exiv2 {
if (!comment_.empty())
++search;
- io_->seekOrThrow(seek, BasicIo::beg, kerNoImageInInputData);
+ io_->seekOrThrow(seek, BasicIo::beg, ErrorCode::kerNoImageInInputData);
count = 0;
- marker = advanceToMarker(kerNoImageInInputData);
+ marker = advanceToMarker(ErrorCode::kerNoImageInInputData);
// To simplify this a bit, new segments are inserts at either the start
// or right after app0. This is standard in most jpegs, but has the
@@ -977,17 +977,17 @@ namespace Exiv2 {
tmpBuf[1] = app1_;
if (exifSize > 0xffff - 8)
- throw Error(kerTooLargeJpegSegment, "Exif");
+ throw Error(ErrorCode::kerTooLargeJpegSegment, "Exif");
us2Data(tmpBuf.data() + 2, static_cast(exifSize + 8), bigEndian);
std::memcpy(tmpBuf.data() + 4, exifId_, 6);
if (outIo.write(tmpBuf.data(), 10) != 10)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write new Exif data buffer
if (outIo.write(pExifData, exifSize) != exifSize)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
--search;
}
}
@@ -1006,18 +1006,18 @@ namespace Exiv2 {
tmpBuf[1] = app1_;
if (xmpPacket_.size() > 0xffff - 31)
- throw Error(kerTooLargeJpegSegment, "XMP");
+ throw Error(ErrorCode::kerTooLargeJpegSegment, "XMP");
us2Data(tmpBuf.data() + 2, static_cast(xmpPacket_.size() + 31), bigEndian);
std::memcpy(tmpBuf.data() + 4, xmpId_, 29);
if (outIo.write(tmpBuf.data(), 33) != 33)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write new XMP packet
if (outIo.write(reinterpret_cast(xmpPacket_.data()),
xmpPacket_.size()) != xmpPacket_.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
--search;
}
@@ -1032,7 +1032,7 @@ namespace Exiv2 {
size_t size = iccProfile_.size();
assert(size > 0); // Because iccProfileDefined() == true
if (size >= 255 * chunk_size)
- throw Error(kerTooLargeJpegSegment, "IccProfile");
+ throw Error(ErrorCode::kerTooLargeJpegSegment, "IccProfile");
const size_t chunks = 1 + (size - 1) / chunk_size;
assert(chunks <= 255); // Because size < 255 * chunk_size
for (size_t chunk = 0; chunk < chunks; chunk++) {
@@ -1041,11 +1041,11 @@ namespace Exiv2 {
// write JPEG marker (2 bytes)
if (outIo.write(tmpBuf.data(), 2) != 2)
- throw Error(kerImageWriteFailed); // JPEG Marker
+ throw Error(ErrorCode::kerImageWriteFailed); // JPEG Marker
// write length (2 bytes). length includes the 2 bytes for the length
us2Data(tmpBuf.data() + 2, static_cast(2 + 14 + bytes), bigEndian);
if (outIo.write(tmpBuf.data() + 2, 2) != 2)
- throw Error(kerImageWriteFailed); // JPEG Length
+ throw Error(ErrorCode::kerImageWriteFailed); // JPEG Length
// write the ICC_PROFILE header (14 bytes)
uint8_t pad[2];
@@ -1054,9 +1054,9 @@ namespace Exiv2 {
outIo.write(reinterpret_cast(iccId_), 12);
outIo.write(reinterpret_cast(pad), 2);
if (outIo.write(iccProfile_.c_data(chunk * chunk_size), bytes) != bytes)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
--search;
}
@@ -1090,15 +1090,15 @@ namespace Exiv2 {
us2Data(tmpBuf.data() + 2, static_cast(chunkSize + 16), bigEndian);
std::memcpy(tmpBuf.data() + 4, Photoshop::ps3Id_, 14);
if (outIo.write(tmpBuf.data(), 18) != 18)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write next chunk of the Photoshop IRB data buffer
if (outIo.write(chunkStart, chunkSize) != chunkSize)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
chunkStart += chunkSize;
}
@@ -1113,18 +1113,18 @@ namespace Exiv2 {
tmpBuf[1] = com_;
if (comment_.length() > 0xffff - 3)
- throw Error(kerTooLargeJpegSegment, "JPEG comment");
+ throw Error(ErrorCode::kerTooLargeJpegSegment, "JPEG comment");
us2Data(tmpBuf.data() + 2, static_cast(comment_.length() + 3), bigEndian);
if (outIo.write(tmpBuf.data(), 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.write(reinterpret_cast(const_cast(comment_.data())),
comment_.length()) != comment_.length())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.putb(0) == EOF)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
--search;
}
--search;
@@ -1142,15 +1142,15 @@ namespace Exiv2 {
tmpBuf[0] = 0xff;
tmpBuf[1] = marker;
if (outIo.write(tmpBuf.data(), 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.write(buf.c_data(), buf.size()) != buf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
// Next marker
- marker = advanceToMarker(kerNoImageInInputData);
+ marker = advanceToMarker(ErrorCode::kerNoImageInInputData);
++count;
}
@@ -1163,16 +1163,16 @@ namespace Exiv2 {
tmpBuf[0] = 0xff;
tmpBuf[1] = marker;
if (outIo.write(tmpBuf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
DataBuf buf(4096);
size_t readSize = 0;
while ((readSize = io_->read(buf.data(), buf.size()))) {
if (outIo.write(buf.c_data(), readSize) != readSize)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
} // JpegBase::doWriteMetadata
diff --git a/src/mrwimage.cpp b/src/mrwimage.cpp
index 639392b033..983157cee6 100644
--- a/src/mrwimage.cpp
+++ b/src/mrwimage.cpp
@@ -46,19 +46,19 @@ namespace Exiv2 {
void MrwImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "MRW"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "MRW"));
}
void MrwImage::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "MRW"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "MRW"));
}
void MrwImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "MRW"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "MRW"));
}
void MrwImage::readMetadata()
@@ -67,13 +67,13 @@ namespace Exiv2 {
std::cerr << "Reading MRW file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isMrwType(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "MRW");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "MRW");
}
clearMetadata();
@@ -85,21 +85,21 @@ namespace Exiv2 {
uint32_t const end = getULong(tmp + 4, bigEndian);
pos += len;
- enforce(pos <= end, kerFailedToReadImageData);
+ enforce(pos <= end, ErrorCode::kerFailedToReadImageData);
io_->read(tmp, len);
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
while (memcmp(tmp + 1, "TTW", 3) != 0) {
uint32_t const siz = getULong(tmp + 4, bigEndian);
- enforce(siz <= end - pos, kerFailedToReadImageData);
+ enforce(siz <= end - pos, ErrorCode::kerFailedToReadImageData);
pos += siz;
io_->seek(siz, BasicIo::cur);
- enforce(!io_->error() && !io_->eof(), kerFailedToReadImageData);
+ enforce(!io_->error() && !io_->eof(), ErrorCode::kerFailedToReadImageData);
- enforce(len <= end - pos, kerFailedToReadImageData);
+ enforce(len <= end - pos, ErrorCode::kerFailedToReadImageData);
pos += len;
io_->read(tmp, len);
- enforce(!io_->error() && !io_->eof(), kerFailedToReadImageData);
+ enforce(!io_->error() && !io_->eof(), ErrorCode::kerFailedToReadImageData);
}
const uint32_t siz = getULong(tmp + 4, bigEndian);
@@ -108,10 +108,10 @@ namespace Exiv2 {
// greater than io_->size() then it is definitely invalid. But the
// exact bounds checking is done by the call to io_->read, which
// will fail if there are fewer than siz bytes left to read.
- enforce(siz <= io_->size(), kerFailedToReadImageData);
+ enforce(siz <= io_->size(), ErrorCode::kerFailedToReadImageData);
DataBuf buf(siz);
io_->read(buf.data(), buf.size());
- enforce(!io_->error() && !io_->eof(), kerFailedToReadImageData);
+ enforce(!io_->error() && !io_->eof(), ErrorCode::kerFailedToReadImageData);
ByteOrder bo = TiffParser::decode(exifData_,
iptcData_,
@@ -124,7 +124,7 @@ namespace Exiv2 {
void MrwImage::writeMetadata()
{
// Todo: implement me!
- throw(Error(kerWritingImageFormatUnsupported, "MRW"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "MRW"));
} // MrwImage::writeMetadata
// *************************************************************************
diff --git a/src/orfimage.cpp b/src/orfimage.cpp
index 3412a577bd..d14b729249 100644
--- a/src/orfimage.cpp
+++ b/src/orfimage.cpp
@@ -53,17 +53,17 @@ namespace Exiv2 {
void OrfImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "ORF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "ORF"));
}
void OrfImage::printStructure(std::ostream& out, PrintStructureOption option, int depth) {
out << "ORF IMAGE" << std::endl;
- if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ if (io_->open() != 0) throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if ( imageType() == ImageType::none )
if (!isOrfType(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
io_->seek(0,BasicIo::beg);
@@ -77,13 +77,13 @@ namespace Exiv2 {
std::cerr << "Reading ORF file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isOrfType(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "ORF");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "ORF");
}
clearMetadata();
ByteOrder bo =
diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp
index daab5b3cc4..0d84593ad9 100644
--- a/src/pgfimage.cpp
+++ b/src/pgfimage.cpp
@@ -81,14 +81,14 @@ namespace Exiv2 {
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isPgfType(*io_, true))
{
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "PGF");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "PGF");
}
clearMetadata();
@@ -99,10 +99,10 @@ namespace Exiv2 {
// And now, the most interesting, the user data byte array where metadata are stored as small image.
- enforce(headerSize <= std::numeric_limits::max() - 8, kerCorruptedMetadata);
+ enforce(headerSize <= std::numeric_limits::max() - 8, ErrorCode::kerCorruptedMetadata);
#if LONG_MAX < UINT_MAX
enforce(headerSize + 8 <= static_cast(std::numeric_limits::max()),
- kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
#endif
long size = static_cast(headerSize) + 8 - io_->tell();
@@ -111,16 +111,16 @@ namespace Exiv2 {
#endif
if (size < 0 || static_cast(size) > io_->size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if (size == 0)
return;
DataBuf imgData(size);
const size_t bufRead = io_->read(imgData.data(), imgData.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != imgData.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
auto image = Exiv2::ImageFactory::open(imgData.c_data(), imgData.size());
image->readMetadata();
@@ -133,7 +133,7 @@ namespace Exiv2 {
{
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -146,8 +146,8 @@ namespace Exiv2 {
void PgfImage::doWriteMetadata(BasicIo& outIo)
{
- if (!io_->isopen()) throw Error(kerInputDataReadFailed);
- if (!outIo.isopen()) throw Error(kerImageWriteFailed);
+ if (!io_->isopen()) throw Error(ErrorCode::kerInputDataReadFailed);
+ if (!outIo.isopen()) throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PgfImage::doWriteMetadata: Writing PGF file " << io_->path() << "\n";
@@ -157,8 +157,8 @@ namespace Exiv2 {
// Ensure that this is the correct image type
if (!isPgfType(*io_, true))
{
- if (io_->error() || io_->eof()) throw Error(kerInputDataReadFailed);
- throw Error(kerNoImageInInputData);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerInputDataReadFailed);
+ throw Error(ErrorCode::kerNoImageInInputData);
}
// Ensure PGF version.
@@ -185,17 +185,17 @@ namespace Exiv2 {
//---------------------------------------------------------------
// Write PGF Signature.
- if (outIo.write(pgfSignature, 3) != 3) throw Error(kerImageWriteFailed);
+ if (outIo.write(pgfSignature, 3) != 3) throw Error(ErrorCode::kerImageWriteFailed);
// Write Magic number.
- if (outIo.putb(mnb) == EOF) throw Error(kerImageWriteFailed);
+ if (outIo.putb(mnb) == EOF) throw Error(ErrorCode::kerImageWriteFailed);
// Write new Header size.
uint32_t newHeaderSize = static_cast(header.size()) + imgSize;
DataBuf buffer(4);
buffer.copyBytes(0, &newHeaderSize, 4);
byteSwap_(buffer,0,bSwap_);
- if (outIo.write(buffer.c_data(), 4) != 4) throw Error(kerImageWriteFailed);
+ if (outIo.write(buffer.c_data(), 4) != 4) throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PgfImage: new PGF header size : " << newHeaderSize << " bytes\n";
@@ -208,11 +208,11 @@ namespace Exiv2 {
// Write Header data.
if (outIo.write(header.c_data(), header.size()) != header.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write new metadata byte array.
if (outIo.write(imgBuf.c_data(), imgBuf.size()) != imgBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Copy the rest of PGF image data.
@@ -220,16 +220,16 @@ namespace Exiv2 {
size_t readSize = 0;
while ((readSize=io_->read(buf.data(), buf.size())))
{
- if (outIo.write(buf.c_data(), readSize) != readSize) throw Error(kerImageWriteFailed);
+ if (outIo.write(buf.c_data(), readSize) != readSize) throw Error(ErrorCode::kerImageWriteFailed);
}
- if (outIo.error()) throw Error(kerImageWriteFailed);
+ if (outIo.error()) throw Error(ErrorCode::kerImageWriteFailed);
} // PgfImage::doWriteMetadata
byte PgfImage::readPgfMagicNumber(BasicIo& iIo)
{
byte b = iIo.getb();
- if (iIo.error()) throw Error(kerFailedToReadImageData);
+ if (iIo.error()) throw Error(ErrorCode::kerFailedToReadImageData);
if (b < 0x36) // 0x36 = '6'.
{
@@ -247,12 +247,12 @@ namespace Exiv2 {
DataBuf buffer(4);
const size_t bufRead = iIo.read(buffer.data(), buffer.size());
if (iIo.error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != buffer.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
auto headerSize = static_cast(byteSwap_(buffer, 0, bSwap_));
- if (headerSize <= 0 ) throw Error(kerNoImageInInputData);
+ if (headerSize <= 0 ) throw Error(ErrorCode::kerNoImageInInputData);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PgfImage: PGF header size : " << headerSize << " bytes\n";
@@ -266,9 +266,9 @@ namespace Exiv2 {
DataBuf header(16);
size_t bufRead = iIo.read(header.data(), header.size());
if (iIo.error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != header.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
DataBuf work(8); // don't disturb the binary data - doWriteMetadata reuses it
work.copyBytes(0,header.c_data(),8);
@@ -288,8 +288,8 @@ namespace Exiv2 {
header.alloc(16 + 256*3);
bufRead = iIo.read(header.data(16), 256*3);
- if (iIo.error()) throw Error(kerFailedToReadImageData);
- if (bufRead != 256*3) throw Error(kerInputDataReadFailed);
+ if (iIo.error()) throw Error(ErrorCode::kerFailedToReadImageData);
+ if (bufRead != 256*3) throw Error(ErrorCode::kerInputDataReadFailed);
}
return header;
diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp
index 41d829c2ac..afe2766457 100644
--- a/src/pngchunk_int.cpp
+++ b/src/pngchunk_int.cpp
@@ -81,11 +81,11 @@ namespace Exiv2::Internal {
// From a tEXt, zTXt, or iTXt chunk, we get the keyword which is null terminated.
const size_t offset = stripHeader ? 8ul : 0ul;
if (data.size() <= offset)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
auto it = std::find(data.cbegin() + offset, data.cend(), 0);
if (it == data.cend())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
return {data.c_data() + offset, std::distance(data.cbegin(), it) - offset};
}
@@ -95,7 +95,7 @@ namespace Exiv2::Internal {
DataBuf arr;
if (type == zTXt_Chunk) {
- enforce(data.size() >= Safe::add(keysize, nullSeparators), Exiv2::kerCorruptedMetadata);
+ enforce(data.size() >= Safe::add(keysize, nullSeparators), ErrorCode::kerCorruptedMetadata);
// Extract a deflate compressed Latin-1 text chunk
@@ -106,17 +106,17 @@ namespace Exiv2::Internal {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard zTXt compression method.\n";
#endif
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
// compressed string after the compression technique spec
const byte* compressedText = data.c_data(keysize + nullSeparators);
size_t compressedTextSize = data.size() - keysize - nullSeparators;
- enforce(compressedTextSize < data.size(), kerCorruptedMetadata);
+ enforce(compressedTextSize < data.size(), ErrorCode::kerCorruptedMetadata);
zlibUncompress(compressedText, static_cast(compressedTextSize), arr);
} else if (type == tEXt_Chunk) {
- enforce(data.size() >= Safe::add(keysize, static_cast(1)), Exiv2::kerCorruptedMetadata);
+ enforce(data.size() >= Safe::add(keysize, static_cast(1)), ErrorCode::kerCorruptedMetadata);
// Extract a non-compressed Latin-1 text chunk
// the text comes after the key, but isn't null terminated
@@ -125,9 +125,9 @@ namespace Exiv2::Internal {
arr = DataBuf(text, textsize);
} else if (type == iTXt_Chunk) {
- enforce(data.size() > Safe::add(keysize, static_cast(3)), Exiv2::kerCorruptedMetadata);
+ enforce(data.size() > Safe::add(keysize, static_cast(3)), ErrorCode::kerCorruptedMetadata);
const size_t nullCount = std::count(data.c_data(keysize + 3), data.c_data(data.size()-1), '\0');
- enforce(nullCount >= nullSeparators, Exiv2::kerCorruptedMetadata);
+ enforce(nullCount >= nullSeparators, ErrorCode::kerCorruptedMetadata);
// Extract a deflate compressed or uncompressed UTF-8 text chunk
@@ -136,8 +136,8 @@ namespace Exiv2::Internal {
// we get the compression method after the compression flag
const byte compressionMethod = data.read_uint8(keysize + 2);
- enforce(compressionFlag == 0x00 || compressionFlag == 0x01, Exiv2::kerCorruptedMetadata);
- enforce(compressionMethod == 0x00, Exiv2::kerCorruptedMetadata);
+ enforce(compressionFlag == 0x00 || compressionFlag == 0x01, ErrorCode::kerCorruptedMetadata);
+ enforce(compressionMethod == 0x00, ErrorCode::kerCorruptedMetadata);
// language description string after the compression technique spec
const size_t languageTextMaxSize = data.size() - keysize - 3;
@@ -145,7 +145,7 @@ namespace Exiv2::Internal {
const size_t languageTextSize = languageText.size();
enforce(data.size() >= Safe::add(Safe::add(keysize, static_cast(4)), languageTextSize),
- Exiv2::kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
// translated keyword string after the language description
std::string translatedKeyText = string_from_unterminated(
data.c_str(keysize + 3 + languageTextSize + 1), data.size() - (keysize + 3 + languageTextSize + 1));
@@ -154,7 +154,7 @@ namespace Exiv2::Internal {
if ((compressionFlag == 0x00) || (compressionFlag == 0x01 && compressionMethod == 0x00)) {
enforce(Safe::add(keysize + 3 + languageTextSize + 1,
Safe::add(translatedKeyTextSize, static_cast(1))) <= data.size(),
- Exiv2::kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
const byte* text = data.c_data(keysize + 3 + languageTextSize + 1 + translatedKeyTextSize + 1);
const auto textsize = static_cast(
@@ -180,13 +180,13 @@ namespace Exiv2::Internal {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Exiv2::PngChunk::parseTXTChunk: Non-standard iTXt compression method.\n";
#endif
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
} else {
#ifdef DEBUG
std::cerr << "Exiv2::PngChunk::parseTXTChunk: We found a field, not expected though\n";
#endif
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
return arr;
@@ -383,12 +383,12 @@ namespace Exiv2::Internal {
}
} else {
// something bad happened
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
} while (zlibResult == Z_BUF_ERROR);
if (zlibResult != Z_OK) {
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
} // PngChunk::zlibUncompress
@@ -416,11 +416,11 @@ namespace Exiv2::Internal {
compressedLen *= 2;
// DoS protection. Cap max compressed size
if (compressedLen > 131072)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
break;
default:
// Something bad happened
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
} while (zlibResult == Z_BUF_ERROR);
@@ -565,7 +565,7 @@ namespace Exiv2::Internal {
return {};
}
- enforce(length <= static_cast(eot - sp) / 2, Exiv2::kerCorruptedMetadata);
+ enforce(length <= static_cast(eot - sp) / 2, Exiv2::ErrorCode::kerCorruptedMetadata);
// Allocate space
if (length == 0) {
@@ -587,7 +587,7 @@ namespace Exiv2::Internal {
size_t nibbles = length * 2;
for (size_t i = 0; i < nibbles; i++) {
- enforce(sp < eot, Exiv2::kerCorruptedMetadata);
+ enforce(sp < eot, Exiv2::ErrorCode::kerCorruptedMetadata);
while (*sp < '0' || (*sp > '9' && *sp < 'a') || *sp > 'f') {
if (*sp == '\0') {
#ifdef EXIV2_DEBUG_MESSAGES
@@ -597,7 +597,7 @@ namespace Exiv2::Internal {
}
sp++;
- enforce(sp < eot, Exiv2::kerCorruptedMetadata);
+ enforce(sp < eot, Exiv2::ErrorCode::kerCorruptedMetadata);
}
if (i % 2 == 0)
diff --git a/src/pngimage.cpp b/src/pngimage.cpp
index c1a26d6c10..42d44312d9 100644
--- a/src/pngimage.cpp
+++ b/src/pngimage.cpp
@@ -190,10 +190,10 @@ namespace Exiv2 {
void PngImage::printStructure(std::ostream& out, PrintStructureOption option, int depth)
{
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
if (!isPngType(*io_, true)) {
- throw Error(kerNotAnImage, "PNG");
+ throw Error(ErrorCode::kerNotAnImage, "PNG");
}
char chType[5];
@@ -224,9 +224,9 @@ namespace Exiv2 {
size_t bufRead = io_->read(cheaderBuf.data(), cheaderBuf.size());
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != cheaderBuf.size())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
// Decode chunk data length.
const uint32_t dataOffset = cheaderBuf.read_uint32(0, Exiv2::bigEndian);
@@ -240,12 +240,12 @@ namespace Exiv2 {
|| dataOffset > uint32_t(0x7FFFFFFF)
|| dataOffset > imgSize - restore
){
- throw Exiv2::Error(kerFailedToReadImageData);
+ throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
}
DataBuf buff(dataOffset);
bufRead = io_->read(buff.data(),dataOffset);
- enforce(bufRead == dataOffset, kerFailedToReadImageData);
+ enforce(bufRead == dataOffset, ErrorCode::kerFailedToReadImageData);
io_->seek(restore, BasicIo::beg);
// format output
@@ -265,7 +265,7 @@ namespace Exiv2 {
io_->seek(dataOffset, BasicIo::cur);// jump to checksum
byte checksum[4];
bufRead = io_->read(checksum,4);
- enforce(bufRead == 4, kerFailedToReadImageData);
+ enforce(bufRead == 4, ErrorCode::kerFailedToReadImageData);
io_->seek(restore, BasicIo::beg) ;// restore file pointer
out << Internal::stringFormat("%8d | %-5s |%8d | ", static_cast(address), chType,
@@ -297,15 +297,15 @@ namespace Exiv2 {
if( bDump ) {
DataBuf dataBuf;
- enforce(dataOffset < std::numeric_limits::max(), kerFailedToReadImageData);
+ enforce(dataOffset < std::numeric_limits::max(), ErrorCode::kerFailedToReadImageData);
DataBuf data(dataOffset + 1ul);
data.write_uint8(dataOffset, 0);
bufRead = io_->read(data.data(), dataOffset);
- enforce(bufRead == dataOffset, kerFailedToReadImageData);
+ enforce(bufRead == dataOffset, ErrorCode::kerFailedToReadImageData);
io_->seek(restore, BasicIo::beg);
size_t name_l = std::strlen(data.c_str()) +
1; // leading string length
- enforce(name_l < dataOffset, kerCorruptedMetadata);
+ enforce(name_l < dataOffset, ErrorCode::kerCorruptedMetadata);
auto start = static_cast(name_l);
bool bLF = false;
@@ -379,7 +379,7 @@ namespace Exiv2 {
}
io_->seek(dataOffset+4, BasicIo::cur);// jump past checksum
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
}
}
@@ -391,10 +391,10 @@ namespace Exiv2 {
#endif
const size_t bufRead = io.read(buffer.data(), buffer.size());
if (io.error()) {
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
if (bufRead != buffer.size()) {
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
}
}
@@ -405,11 +405,11 @@ namespace Exiv2 {
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
if (!isPngType(*io_, true)) {
- throw Error(kerNotAnImage, "PNG");
+ throw Error(ErrorCode::kerNotAnImage, "PNG");
}
clearMetadata();
@@ -426,7 +426,7 @@ namespace Exiv2 {
if (pos == -1 ||
chunkLength > uint32_t(0x7FFFFFFF) ||
chunkLength > imgSize - pos) {
- throw Exiv2::Error(kerFailedToReadImageData);
+ throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
}
std::string chunkType(cheaderBuf.c_str(4), 4);
@@ -468,12 +468,12 @@ namespace Exiv2 {
uint32_t iccOffset = 0;
do {
enforce(iccOffset < 80 && iccOffset < chunkLength,
- Exiv2::kerCorruptedMetadata);
+ Exiv2::ErrorCode::kerCorruptedMetadata);
} while(chunkData.read_uint8(iccOffset++) != 0x00);
profileName_ = std::string(chunkData.c_str(), iccOffset-1);
++iccOffset; // +1 = 'compressed' flag
- enforce(iccOffset <= chunkLength, Exiv2::kerCorruptedMetadata);
+ enforce(iccOffset <= chunkLength, Exiv2::ErrorCode::kerCorruptedMetadata);
zlibToDataBuf(chunkData.c_data(iccOffset), chunkLength - iccOffset, iccProfile_);
#ifdef EXIV2_DEBUG_MESSAGES
@@ -495,7 +495,7 @@ namespace Exiv2 {
#endif
io_->seek(chunkLength + 4 , BasicIo::cur);
if (io_->error() || io_->eof()) {
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
}
} // PngImage::readMetadata
@@ -504,7 +504,7 @@ namespace Exiv2 {
{
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -518,9 +518,9 @@ namespace Exiv2 {
void PngImage::doWriteMetadata(BasicIo& outIo)
{
if (!io_->isopen())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if (!outIo.isopen())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: Writing PNG file " << io_->path() << "\n";
@@ -528,12 +528,12 @@ namespace Exiv2 {
#endif
if (!isPngType(*io_, true)) {
- throw Error(kerNoImageInInputData);
+ throw Error(ErrorCode::kerNoImageInInputData);
}
// Write PNG Signature.
if (outIo.write(pngSignature, 8) != 8)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
DataBuf cheaderBuf(8); // Chunk header : 4 bytes (data size) + 4 bytes (chunk type).
@@ -542,15 +542,15 @@ namespace Exiv2 {
// Read chunk header.
size_t bufRead = io_->read(cheaderBuf.data(), 8);
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != 8)
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
// Decode chunk data length.
uint32_t dataOffset = cheaderBuf.read_uint32(0, Exiv2::bigEndian);
if (dataOffset > 0x7FFFFFFF)
- throw Exiv2::Error(kerFailedToReadImageData);
+ throw Exiv2::Error(ErrorCode::kerFailedToReadImageData);
// Read whole chunk : Chunk header + Chunk data (not fixed size - can be null) + CRC (4 bytes).
@@ -558,9 +558,9 @@ namespace Exiv2 {
chunkBuf.copyBytes(0, cheaderBuf.c_data(), 8); // Copy header.
bufRead = io_->read(chunkBuf.data(8), dataOffset + 4); // Extract chunk data + CRC
if (io_->error())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (bufRead != static_cast(dataOffset) + 4)
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
char szChunk[5];
memcpy(szChunk,cheaderBuf.c_data(4),4);
@@ -573,7 +573,7 @@ namespace Exiv2 {
std::cout << "Exiv2::PngImage::doWriteMetadata: Write IEND chunk (length: " << dataOffset << ")\n";
#endif
if (outIo.write(chunkBuf.data(), chunkBuf.size()) != chunkBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
return;
}
if (!strcmp(szChunk, "eXIf")) {
@@ -584,7 +584,7 @@ namespace Exiv2 {
std::cout << "Exiv2::PngImage::doWriteMetadata: Write IHDR chunk (length: " << dataOffset << ")\n";
#endif
if (outIo.write(chunkBuf.data(), chunkBuf.size()) != chunkBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write all updated metadata here, just after IHDR.
if (!comment_.empty())
@@ -592,7 +592,7 @@ namespace Exiv2 {
// Update Comment data to a new PNG chunk
std::string chunk = PngChunk::makeMetadataChunk(comment_, mdComment);
if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) != chunk.size()) {
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -607,7 +607,7 @@ namespace Exiv2 {
std::string(reinterpret_cast(&blob[0]), blob.size());
std::string chunk = PngChunk::makeMetadataChunk(rawExif, mdExif);
if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) != chunk.size()) {
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
}
@@ -620,7 +620,7 @@ namespace Exiv2 {
std::string rawIptc(newPsData.c_str(), newPsData.size());
std::string chunk = PngChunk::makeMetadataChunk(rawIptc, mdIptc);
if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) != chunk.size()) {
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
}
@@ -649,7 +649,7 @@ namespace Exiv2 {
|| outIo.write (compressed.c_data(),compressed.size()) != compressed.size()
|| outIo.write(crc,4) != 4
){
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP"
@@ -670,7 +670,7 @@ namespace Exiv2 {
std::string chunk = PngChunk::makeMetadataChunk(xmpPacket_, mdXmp);
if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) !=
chunk.size()) {
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
} else if (!strcmp(szChunk, "tEXt") || !strcmp(szChunk, "zTXt") || !strcmp(szChunk, "iTXt") ||
@@ -692,7 +692,7 @@ namespace Exiv2 {
<< " chunk (length: " << dataOffset << ")" << std::endl;
#endif
if (outIo.write(chunkBuf.c_data(), chunkBuf.size()) != chunkBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
} else {
// Write all others chunk as well.
@@ -701,7 +701,7 @@ namespace Exiv2 {
<< " chunk (length: " << dataOffset << ")" << std::endl;
#endif
if (outIo.write(chunkBuf.c_data(), chunkBuf.size()) != chunkBuf.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
}
@@ -722,7 +722,7 @@ namespace Exiv2 {
bool isPngType(BasicIo& iIo, bool advance)
{
if (iIo.error() || iIo.eof()) {
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
}
const int32_t len = 8;
byte buf[len];
diff --git a/src/preview.cpp b/src/preview.cpp
index 9dc9144a4c..10b11689fc 100644
--- a/src/preview.cpp
+++ b/src/preview.cpp
@@ -433,7 +433,7 @@ namespace {
BasicIo &io = image_.io();
if (io.open() != 0) {
- throw Error(kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
const byte* data = io.mmap();
@@ -464,7 +464,7 @@ namespace {
}
return {record + sizeHdr + 28, sizeData - 28};
}
- throw Error(kerErrorMessage, "Invalid native preview filter: " + nativePreview_.filter_);
+ throw Error(ErrorCode::kerErrorMessage, "Invalid native preview filter: " + nativePreview_.filter_);
}
bool LoaderNative::readDimensions()
@@ -486,7 +486,7 @@ namespace {
width_ = image->pixelWidth();
height_ = image->pixelHeight();
- } catch (const AnyError& /* error */) {
+ } catch (const Error& /* error */) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Invalid native preview image.\n";
#endif
@@ -544,7 +544,7 @@ namespace {
BasicIo &io = image_.io();
if (io.open() != 0) {
- throw Error(kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
@@ -561,7 +561,7 @@ namespace {
BasicIo &io = image_.io();
if (io.open() != 0) {
- throw Error(kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
const Exiv2::byte* base = io.mmap();
@@ -575,7 +575,7 @@ namespace {
width_ = image->pixelWidth();
height_ = image->pixelHeight();
}
- catch (const AnyError& /* error */ ) {
+ catch (const Error& /* error */ ) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Invalid JPEG preview image.\n";
#endif
@@ -654,7 +654,7 @@ namespace {
width_ = image->pixelWidth();
height_ = image->pixelHeight();
}
- catch (const AnyError& /* error */ ) {
+ catch (const Error& /* error */ ) {
return false;
}
@@ -765,7 +765,7 @@ namespace {
BasicIo &io = image_.io();
if (io.open() != 0) {
- throw Error(kerDataSourceOpenFailed, io.path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io.path(), strError());
}
IoCloser closer(io);
@@ -783,7 +783,7 @@ namespace {
}
else {
// FIXME: the buffer is probably copied twice, it should be optimized
- enforce(size_ <= static_cast(io.size()), kerCorruptedMetadata);
+ enforce(size_ <= static_cast(io.size()), ErrorCode::kerCorruptedMetadata);
DataBuf buf(size_);
uint32_t idxBuf = 0;
for (size_t i = 0; i < sizes.count(); i++) {
@@ -794,7 +794,7 @@ namespace {
// see the constructor of LoaderTiff
// But e.g in malicious files some of these values could be negative
// That's why we check again for each step here to really make sure we don't overstep
- enforce(Safe::add(idxBuf, size) <= size_, kerCorruptedMetadata);
+ enforce(Safe::add(idxBuf, size) <= size_, ErrorCode::kerCorruptedMetadata);
if (size!=0 && Safe::add(offset, size) <= static_cast(io.size())){
buf.copyBytes(idxBuf, base + offset, size);
}
diff --git a/src/properties.cpp b/src/properties.cpp
index a78f299427..4ad55aaf16 100644
--- a/src/properties.cpp
+++ b/src/properties.cpp
@@ -4096,7 +4096,7 @@ namespace Exiv2 {
const XmpNsInfo::Prefix pf(prefix);
const XmpNsInfo* xn = lookupNsRegistryUnsafe(pf);
if (!xn) xn = find(xmpNsInfo, pf);
- if (!xn) throw Error(kerNoNamespaceInfoForXmpPrefix, prefix);
+ if (!xn) throw Error(ErrorCode::kerNoNamespaceInfoForXmpPrefix, prefix);
return xn;
}
@@ -4158,7 +4158,7 @@ namespace Exiv2 {
{
// Validate prefix
if (XmpProperties::ns(prefix).empty())
- throw Error(kerNoNamespaceForPrefix, prefix);
+ throw Error(ErrorCode::kerNoNamespaceForPrefix, prefix);
property_ = property;
prefix_ = prefix;
@@ -4244,29 +4244,29 @@ namespace Exiv2 {
// Get the family name, prefix and property name parts of the key
std::string::size_type pos1 = key.find('.');
if (pos1 == std::string::npos) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
std::string familyName = key.substr(0, pos1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
std::string::size_type pos0 = pos1 + 1;
pos1 = key.find('.', pos0);
if (pos1 == std::string::npos) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
std::string prefix = key.substr(pos0, pos1 - pos0);
if (prefix.empty()) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
std::string property = key.substr(pos1 + 1);
if (property.empty()) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
// Validate prefix
if (XmpProperties::ns(prefix).empty())
- throw Error(kerNoNamespaceForPrefix, prefix);
+ throw Error(ErrorCode::kerNoNamespaceForPrefix, prefix);
property_ = property;
prefix_ = prefix;
diff --git a/src/psdimage.cpp b/src/psdimage.cpp
index 13dea7c443..a3e04303f0 100644
--- a/src/psdimage.cpp
+++ b/src/psdimage.cpp
@@ -104,7 +104,7 @@ namespace Exiv2 {
void PsdImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "Photoshop"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "Photoshop"));
}
void PsdImage::readMetadata()
@@ -114,15 +114,15 @@ namespace Exiv2 {
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isPsdType(*io_, false))
{
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
clearMetadata();
@@ -143,7 +143,7 @@ namespace Exiv2 {
byte buf[26];
if (io_->read(buf, 26) != 26)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
pixelWidth_ = getLong(buf + 18, bigEndian);
pixelHeight_ = getLong(buf + 14, bigEndian);
@@ -152,31 +152,31 @@ namespace Exiv2 {
// the first four bytes of which specify the byte size of the whole section
if (io_->read(buf, 4) != 4)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
// skip it
uint32_t colorDataLength = getULong(buf, bigEndian);
if (io_->seek(colorDataLength, BasicIo::cur))
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
// after the color data section, comes a list of resource blocks, preceded by the total byte size
if (io_->read(buf, 4) != 4)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
uint32_t resourcesLength = getULong(buf, bigEndian);
- enforce(resourcesLength < io_->size(), Exiv2::kerCorruptedMetadata);
+ enforce(resourcesLength < io_->size(), Exiv2::ErrorCode::kerCorruptedMetadata);
while (resourcesLength > 0)
{
- enforce(resourcesLength >= 8, Exiv2::kerCorruptedMetadata);
+ enforce(resourcesLength >= 8, Exiv2::ErrorCode::kerCorruptedMetadata);
resourcesLength -= 8;
if (io_->read(buf, 8) != 8)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
if (!Photoshop::isIrb(buf, 4))
@@ -187,16 +187,16 @@ namespace Exiv2 {
uint32_t resourceNameLength = buf[6] & ~1;
// skip the resource name, plus any padding
- enforce(resourceNameLength <= resourcesLength, Exiv2::kerCorruptedMetadata);
+ enforce(resourceNameLength <= resourcesLength, Exiv2::ErrorCode::kerCorruptedMetadata);
resourcesLength -= resourceNameLength;
io_->seek(resourceNameLength, BasicIo::cur);
// read resource size
- enforce(resourcesLength >= 4, Exiv2::kerCorruptedMetadata);
+ enforce(resourcesLength >= 4, Exiv2::ErrorCode::kerCorruptedMetadata);
resourcesLength -= 4;
if (io_->read(buf, 4) != 4)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
uint32_t resourceSize = getULong(buf, bigEndian);
uint32_t curOffset = io_->tell();
@@ -205,10 +205,10 @@ namespace Exiv2 {
std::cerr << std::hex << "resourceId: " << resourceId << std::dec << " length: " << resourceSize << std::hex << "\n";
#endif
- enforce(resourceSize <= resourcesLength, Exiv2::kerCorruptedMetadata);
+ enforce(resourceSize <= resourcesLength, Exiv2::ErrorCode::kerCorruptedMetadata);
readResourceBlock(resourceId, resourceSize);
resourceSize = (resourceSize + 1) & ~1; // pad to even
- enforce(resourceSize <= resourcesLength, Exiv2::kerCorruptedMetadata);
+ enforce(resourceSize <= resourcesLength, Exiv2::ErrorCode::kerCorruptedMetadata);
resourcesLength -= resourceSize;
io_->seek(curOffset + resourceSize, BasicIo::beg);
}
@@ -224,7 +224,7 @@ namespace Exiv2 {
DataBuf rawIPTC(resourceSize);
io_->read(rawIPTC.data(), rawIPTC.size());
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (IptcParser::decode(iptcData_, rawIPTC.c_data(), static_cast(rawIPTC.size()))) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to decode IPTC metadata.\n";
@@ -239,7 +239,7 @@ namespace Exiv2 {
DataBuf rawExif(resourceSize);
io_->read(rawExif.data(), rawExif.size());
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
ByteOrder bo = ExifParser::decode(exifData_, rawExif.c_data(), rawExif.size());
setByteOrder(bo);
if (!rawExif.empty() && byteOrder() == invalidByteOrder) {
@@ -256,7 +256,7 @@ namespace Exiv2 {
DataBuf xmpPacket(resourceSize);
io_->read(xmpPacket.data(), xmpPacket.size());
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
xmpPacket_.assign(xmpPacket.c_str(), xmpPacket.size());
if (!xmpPacket_.empty() && XmpParser::decode(xmpData_, xmpPacket_)) {
#ifndef SUPPRESS_WARNINGS
@@ -290,7 +290,7 @@ namespace Exiv2 {
byte buf[28];
if (io_->read(buf, 28) != 28)
{
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
NativePreview nativePreview;
nativePreview.position_ = io_->tell();
@@ -302,7 +302,7 @@ namespace Exiv2 {
if (nativePreview.size_ > 0 && nativePreview.position_ >= 0) {
io_->seek(static_cast(nativePreview.size_), BasicIo::cur);
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (format == 1) {
nativePreview.filter_ = "";
@@ -326,7 +326,7 @@ namespace Exiv2 {
{
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -340,9 +340,9 @@ namespace Exiv2 {
void PsdImage::doWriteMetadata(BasicIo& outIo)
{
if (!io_->isopen())
- throw Error(kerInputDataReadFailed);
+ throw Error(ErrorCode::kerInputDataReadFailed);
if (!outIo.isopen())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PsdImage::doWriteMetadata: Writing PSD file " << io_->path() << "\n";
@@ -352,8 +352,8 @@ namespace Exiv2 {
// Ensure that this is the correct image type
if (!isPsdType(*io_, true)) {
if (io_->error() || io_->eof())
- throw Error(kerInputDataReadFailed);
- throw Error(kerNoImageInInputData);
+ throw Error(ErrorCode::kerInputDataReadFailed);
+ throw Error(ErrorCode::kerNoImageInInputData);
}
io_->seek(0, BasicIo::beg); // rewind
@@ -364,22 +364,22 @@ namespace Exiv2 {
// Get Photoshop header from original file
byte psd_head[26];
if (io_->read(psd_head, 26) != 26)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
// Write Photoshop header data out to new PSD file
if (outIo.write(psd_head, 26) != 26)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Read colorDataLength from original PSD
if (io_->read(buf, 4) != 4)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
uint32_t colorDataLength = getULong(buf, bigEndian);
// Write colorDataLength
ul2Data(buf, colorDataLength, bigEndian);
if (outIo.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::dec << "colorDataLength: " << colorDataLength << "\n";
#endif
@@ -390,19 +390,19 @@ namespace Exiv2 {
? static_cast(colorDataLength) - readTotal
: lbuf.size();
if (io_->read(lbuf.data(), toRead) != toRead)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
readTotal += toRead;
if (outIo.write(lbuf.c_data(), toRead) != toRead)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
uint32_t resLenOffset = io_->tell(); // remember for later update
// Read length of all resource blocks from original PSD
if (io_->read(buf, 4) != 4)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
uint32_t oldResLength = getULong(buf, bigEndian);
uint32_t newResLength = 0;
@@ -410,7 +410,7 @@ namespace Exiv2 {
// Write oldResLength (will be updated later)
ul2Data(buf, oldResLength, bigEndian);
if (outIo.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << std::dec << "oldResLength: " << oldResLength << "\n";
@@ -425,14 +425,14 @@ namespace Exiv2 {
bool xmpDone = false;
while (oldResLength > 0) {
if (io_->read(buf, 8) != 8)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
// read resource type and ID
uint32_t resourceType = getULong(buf, bigEndian);
if (!Photoshop::isIrb(buf, 4))
{
- throw Error(kerNotAnImage, "Photoshop"); // bad resource type
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop"); // bad resource type
}
uint16_t resourceId = getUShort(buf + 4, bigEndian);
uint32_t resourceNameLength = buf[6];
@@ -442,11 +442,11 @@ namespace Exiv2 {
// read rest of resource name, plus any padding
DataBuf resName(256);
if (io_->read(resName.data(), adjResourceNameLen) != adjResourceNameLen)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
// read resource size (actual length w/o padding!)
if (io_->read(buf, 4) != 4)
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
uint32_t resourceSize = getULong(buf, bigEndian);
uint32_t pResourceSize = (resourceSize + 1) & ~1; // padded resource size
@@ -485,22 +485,22 @@ namespace Exiv2 {
// Copy resource block to new PSD file
ul2Data(buf, resourceType, bigEndian);
if (outIo.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, resourceId, bigEndian);
if (outIo.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write resource name as Pascal string
buf[0] = resourceNameLength & 0x00ff;
if (outIo.write(buf, 1) != 1)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
buf[0] = resourceNameFirstChar;
if (outIo.write(buf, 1) != 1)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (outIo.write(resName.c_data(), adjResourceNameLen) != static_cast(adjResourceNameLen))
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
ul2Data(buf, resourceSize, bigEndian);
if (outIo.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
readTotal = 0;
while (readTotal < pResourceSize) {
@@ -509,14 +509,14 @@ namespace Exiv2 {
? static_cast(pResourceSize - readTotal)
: static_cast(lbuf.size());
if (io_->read(lbuf.data(), toRead) != toRead) {
- throw Error(kerNotAnImage, "Photoshop");
+ throw Error(ErrorCode::kerNotAnImage, "Photoshop");
}
readTotal += toRead;
if (outIo.write(lbuf.c_data(), toRead) != toRead)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
newResLength += pResourceSize + adjResourceNameLen + 12;
}
@@ -548,10 +548,10 @@ namespace Exiv2 {
size_t readSize = 0;
while ((readSize=io_->read(lbuf.data(), lbuf.size()))) {
if (outIo.write(lbuf.c_data(), readSize) != readSize)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
}
if (outIo.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Update length of resources
#ifdef EXIV2_DEBUG_MESSAGES
@@ -560,7 +560,7 @@ namespace Exiv2 {
outIo.seek(resLenOffset, BasicIo::beg);
ul2Data(buf, newResLength, bigEndian);
if (outIo.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
} // PsdImage::doWriteMetadata
@@ -577,25 +577,25 @@ namespace Exiv2 {
std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size() << "\n";
#endif
if (out.write(reinterpret_cast(Photoshop::irbId_[0]), 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, kPhotoshopResourceID_IPTC_NAA, bigEndian);
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, 0, bigEndian); // NULL resource name
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
ul2Data(buf, static_cast(rawIptc.size()), bigEndian);
if (out.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write encoded Iptc data
if (out.write(rawIptc.c_data(), rawIptc.size()) != rawIptc.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength += static_cast(rawIptc.size()) + 12;
if (rawIptc.size() & 1) // even padding
{
buf[0] = 0;
if (out.write(buf, 1) != 1)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength++;
}
}
@@ -623,25 +623,25 @@ namespace Exiv2 {
std::cerr << std::dec << "Writing ExifInfo: size: " << blob.size() << "\n";
#endif
if (out.write(reinterpret_cast(Photoshop::irbId_[0]), 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, kPhotoshopResourceID_ExifInfo, bigEndian);
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, 0, bigEndian); // NULL resource name
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
ul2Data(buf, static_cast(blob.size()), bigEndian);
if (out.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write encoded Exif data
if (out.write(&blob[0], blob.size()) != blob.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength += static_cast(blob.size()) + 12;
if (blob.size() & 1) // even padding
{
buf[0] = 0;
if (out.write(buf, 1) != 1)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength++;
}
}
@@ -673,27 +673,27 @@ namespace Exiv2 {
std::cerr << std::dec << "Writing XMPPacket: size: " << xmpPacket.size() << "\n";
#endif
if (out.write(reinterpret_cast(Photoshop::irbId_[0]), 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, kPhotoshopResourceID_XMPPacket, bigEndian);
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
us2Data(buf, 0, bigEndian); // NULL resource name
if (out.write(buf, 2) != 2)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
ul2Data(buf, static_cast(xmpPacket.size()), bigEndian);
if (out.write(buf, 4) != 4)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
// Write XMPPacket
if (out.write(reinterpret_cast(xmpPacket.data()), xmpPacket.size()) != xmpPacket.size())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
if (out.error())
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength += static_cast(xmpPacket.size()) + 12;
if (xmpPacket.size() & 1) // even padding
{
buf[0] = 0;
if (out.write(buf, 1) != 1)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
resLength++;
}
}
diff --git a/src/rafimage.cpp b/src/rafimage.cpp
index 5d12fe75a2..d41b75e5f4 100644
--- a/src/rafimage.cpp
+++ b/src/rafimage.cpp
@@ -50,30 +50,30 @@ namespace Exiv2 {
void RafImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "RAF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "RAF"));
}
void RafImage::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RAF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "RAF"));
}
void RafImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "RAF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "RAF"));
}
void RafImage::printStructure(std::ostream& out, PrintStructureOption option, int depth) {
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
// Ensure this is the correct image type
if (!isRafType(*io_, true)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "RAF");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "RAF");
}
const bool bPrint = option==kpsBasic || option==kpsRecursive;
@@ -266,49 +266,49 @@ namespace Exiv2 {
std::cerr << "Reading RAF file " << io_->path() << "\n";
#endif
if (io_->open() != 0)
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isRafType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "RAF");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "RAF");
}
clearMetadata();
if (io_->seek(84,BasicIo::beg) != 0)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
byte jpg_img_offset [4];
if (io_->read(jpg_img_offset, 4) != 4)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
byte jpg_img_length [4];
if (io_->read(jpg_img_length, 4) != 4)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
uint32_t jpg_img_off_u32 = Exiv2::getULong(jpg_img_offset, bigEndian);
uint32_t jpg_img_len_u32 = Exiv2::getULong(jpg_img_length, bigEndian);
- enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), kerCorruptedMetadata);
+ enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), ErrorCode::kerCorruptedMetadata);
#if LONG_MAX < UINT_MAX
enforce(jpg_img_off_u32 <= static_cast(std::numeric_limits::max()),
- kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
enforce(jpg_img_len_u32 <= static_cast(std::numeric_limits::max()),
- kerCorruptedMetadata);
+ ErrorCode::kerCorruptedMetadata);
#endif
auto jpg_img_off = static_cast(jpg_img_off_u32);
auto jpg_img_len = static_cast(jpg_img_len_u32);
- enforce(jpg_img_len >= 12, kerCorruptedMetadata);
+ enforce(jpg_img_len >= 12, ErrorCode::kerCorruptedMetadata);
DataBuf buf(jpg_img_len - 12);
if (io_->seek(jpg_img_off + 12,BasicIo::beg) != 0)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
io_->read(buf.data(), buf.size());
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
io_->seek(0,BasicIo::beg); // rewind
@@ -326,26 +326,26 @@ namespace Exiv2 {
// parse the tiff
byte readBuff[4];
if (io_->seek(100, BasicIo::beg) != 0)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
if (io_->read(readBuff, 4) != 4 )
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
uint32_t tiffOffset = Exiv2::getULong(readBuff, bigEndian);
if (io_->read(readBuff, 4) != 4)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
uint32_t tiffLength = Exiv2::getULong(readBuff, bigEndian);
// sanity check. Does tiff lie inside the file?
- enforce(Safe::add(tiffOffset, tiffLength) <= io_->size(), kerCorruptedMetadata);
+ enforce(Safe::add(tiffOffset, tiffLength) <= io_->size(), ErrorCode::kerCorruptedMetadata);
if (io_->seek(tiffOffset, BasicIo::beg) != 0)
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
// Check if this really is a tiff and then call the tiff parser.
// Check is needed because some older models just embed a raw bitstream.
// For those files we skip the parsing step.
if (io_->read(readBuff, 4) != 4) {
- throw Error(kerFailedToReadImageData); }
+ throw Error(ErrorCode::kerFailedToReadImageData); }
io_->seek(-4, BasicIo::cur);
if (memcmp(readBuff, "\x49\x49\x2A\x00", 4) == 0 ||
memcmp(readBuff, "\x4D\x4D\x00\x2A", 4) == 0)
@@ -367,7 +367,7 @@ namespace Exiv2 {
void RafImage::writeMetadata()
{
//! Todo: implement me!
- throw(Error(kerWritingImageFormatUnsupported, "RAF"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "RAF"));
} // RafImage::writeMetadata
// *************************************************************************
diff --git a/src/rw2image.cpp b/src/rw2image.cpp
index 6d4605a658..89c0668bb7 100644
--- a/src/rw2image.cpp
+++ b/src/rw2image.cpp
@@ -56,29 +56,29 @@ namespace Exiv2 {
void Rw2Image::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "RW2"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "RW2"));
}
void Rw2Image::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RW2"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "RW2"));
}
void Rw2Image::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "RW2"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "RW2"));
}
void Rw2Image::printStructure(std::ostream& out, PrintStructureOption option, int depth) {
out << "RW2 IMAGE" << std::endl;
- if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ if (io_->open() != 0) throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if ( imageType() == ImageType::none )
if (!isRw2Type(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
io_->seek(0,BasicIo::beg);
@@ -92,13 +92,13 @@ namespace Exiv2 {
std::cerr << "Reading RW2 file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isRw2Type(*io_, false)) {
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "RW2");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "RW2");
}
clearMetadata();
ByteOrder bo =
@@ -194,7 +194,7 @@ namespace Exiv2 {
void Rw2Image::writeMetadata()
{
// Todo: implement me!
- throw(Error(kerWritingImageFormatUnsupported, "RW2"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "RW2"));
} // Rw2Image::writeMetadata
ByteOrder Rw2Parser::decode(
diff --git a/src/tags.cpp b/src/tags.cpp
index cd763c36f9..59270a1e40 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -211,31 +211,31 @@ namespace Exiv2 {
{
// Get the family name, IFD name and tag name parts of the key
std::string::size_type pos1 = key.find('.');
- if (pos1 == std::string::npos) throw Error(kerInvalidKey, key);
+ if (pos1 == std::string::npos) throw Error(ErrorCode::kerInvalidKey, key);
std::string familyName = key.substr(0, pos1);
if (0 != strcmp(familyName.c_str(), familyName_)) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
std::string::size_type pos0 = pos1 + 1;
pos1 = key.find('.', pos0);
- if (pos1 == std::string::npos) throw Error(kerInvalidKey, key);
+ if (pos1 == std::string::npos) throw Error(ErrorCode::kerInvalidKey, key);
std::string groupName = key.substr(pos0, pos1 - pos0);
- if (groupName.empty()) throw Error(kerInvalidKey, key);
+ if (groupName.empty()) throw Error(ErrorCode::kerInvalidKey, key);
std::string tn = key.substr(pos1 + 1);
- if (tn.empty()) throw Error(kerInvalidKey, key);
+ if (tn.empty()) throw Error(ErrorCode::kerInvalidKey, key);
// Find IfdId
IfdId ifdId = groupId(groupName);
- if (ifdId == ifdIdNotSet) throw Error(kerInvalidKey, key);
+ if (ifdId == ifdIdNotSet) throw Error(ErrorCode::kerInvalidKey, key);
if (!Internal::isExifIfd(ifdId) && !Internal::isMakerIfd(ifdId)) {
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
}
// Convert tag
uint16_t tag = tagNumber(tn, ifdId);
// Get tag info
tagInfo_ = tagInfo(tag, ifdId);
if (!tagInfo_)
- throw Error(kerInvalidKey, key);
+ throw Error(ErrorCode::kerInvalidKey, key);
tag_ = tag;
ifdId_ = ifdId;
@@ -260,11 +260,11 @@ namespace Exiv2 {
IfdId ifdId = groupId(groupName);
// Todo: Test if this condition can be removed
if (!Internal::isExifIfd(ifdId) && !Internal::isMakerIfd(ifdId)) {
- throw Error(kerInvalidIfdId, ifdId);
+ throw Error(ErrorCode::kerInvalidIfdId, ifdId);
}
const TagInfo* ti = tagInfo(tag, ifdId);
if (!ti) {
- throw Error(kerInvalidIfdId, ifdId);
+ throw Error(ErrorCode::kerInvalidIfdId, ifdId);
}
p_->groupName_ = groupName;
p_->makeKey(tag, ifdId, ti);
@@ -275,7 +275,7 @@ namespace Exiv2 {
{
auto ifdId = static_cast(ti.ifdId_);
if (!Internal::isExifIfd(ifdId) && !Internal::isMakerIfd(ifdId)) {
- throw Error(kerInvalidIfdId, ifdId);
+ throw Error(ErrorCode::kerInvalidIfdId, ifdId);
}
p_->groupName_ = Exiv2::groupName(ifdId);
p_->makeKey(ti.tag_, ifdId, &ti);
diff --git a/src/tags_int.cpp b/src/tags_int.cpp
index 9a68d9bd4b..c1d5379aa4 100644
--- a/src/tags_int.cpp
+++ b/src/tags_int.cpp
@@ -71,16 +71,16 @@ namespace Exiv2::Internal {
{ canonFiId, "Makernote", "CanonFi", CanonMakerNote::tagListFi },
{ canonPaId, "Makernote", "CanonPa", CanonMakerNote::tagListPa },
{ canonPrId, "Makernote", "CanonPr", CanonMakerNote::tagListPr },
- { canonVigCor2Id, "Makernote", "CanonVigCor2", CanonMakerNote::tagListVigCor2 },
- { canonLiOpId, "Makernote", "CanonLiOp", CanonMakerNote::tagListLiOp },
+ { canonVigCor2Id, "Makernote", "CanonVigCor2", CanonMakerNote::tagListVigCor2 },
+ { canonLiOpId, "Makernote", "CanonLiOp", CanonMakerNote::tagListLiOp },
{ canonAfMiAdjId, "Makernote", "CanonAfMiAdj", CanonMakerNote::tagListAfMiAdj },
- { canonLeId, "Makernote", "CanonLe", CanonMakerNote::tagListLe },
- { canonAmId, "Makernote", "CanonAm", CanonMakerNote::tagListAm },
- { canonFilId, "Makernote", "CanonFil", CanonMakerNote::tagListFil },
- { canonMeId, "Makernote", "CanonMe", CanonMakerNote::tagListMe },
- { canonHdrId, "Makernote", "CanonHdr", CanonMakerNote::tagListHdr },
- { canonAfCId, "Makernote", "CanonAfC", CanonMakerNote::tagListAfC },
- { canonRawBId, "Makernote", "CanonRawB", CanonMakerNote::tagListRawB },
+ { canonLeId, "Makernote", "CanonLe", CanonMakerNote::tagListLe },
+ { canonAmId, "Makernote", "CanonAm", CanonMakerNote::tagListAm },
+ { canonFilId, "Makernote", "CanonFil", CanonMakerNote::tagListFil },
+ { canonMeId, "Makernote", "CanonMe", CanonMakerNote::tagListMe },
+ { canonHdrId, "Makernote", "CanonHdr", CanonMakerNote::tagListHdr },
+ { canonAfCId, "Makernote", "CanonAfC", CanonMakerNote::tagListAfC },
+ { canonRawBId, "Makernote", "CanonRawB", CanonMakerNote::tagListRawB },
{ casioId, "Makernote", "Casio", CasioMakerNote::tagList },
{ casio2Id, "Makernote", "Casio2", Casio2MakerNote::tagList },
{ fujiId, "Makernote", "Fujifilm", FujiMakerNote::tagList },
@@ -2642,7 +2642,8 @@ namespace Exiv2::Internal {
const TagInfo* ti = tagInfo(tagName, ifdId);
if (ti && ti->tag_ != 0xffff)
return ti->tag_;
- if (!isHex(tagName, 4, "0x")) throw Error(kerInvalidTag, tagName, ifdId);
+ if (!isHex(tagName, 4, "0x"))
+ throw Error(ErrorCode::kerInvalidTag, tagName, ifdId);
std::istringstream is(tagName);
uint16_t tag = 0;
is >> std::hex >> tag;
diff --git a/src/tgaimage.cpp b/src/tgaimage.cpp
index 437c6147fb..330c173e73 100644
--- a/src/tgaimage.cpp
+++ b/src/tgaimage.cpp
@@ -28,19 +28,19 @@ namespace Exiv2 {
void TgaImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "Exif metadata", "TGA"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Exif metadata", "TGA"));
}
void TgaImage::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
- throw(Error(kerInvalidSettingForImage, "IPTC metadata", "TGA"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "TGA"));
}
void TgaImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "TGA"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "TGA"));
}
void TgaImage::readMetadata()
@@ -50,14 +50,14 @@ namespace Exiv2 {
#endif
if (io_->open() != 0)
{
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isTgaType(*io_, false))
{
- if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "TGA");
+ if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "TGA");
}
clearMetadata();
@@ -94,7 +94,7 @@ namespace Exiv2 {
void TgaImage::writeMetadata()
{
// Todo: implement me!
- throw(Error(kerWritingImageFormatUnsupported, "TGA"));
+ throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "TGA"));
} // TgaImage::writeMetadata
// *************************************************************************
diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp
index 1730cd0213..3d634fd2cc 100644
--- a/src/tiffcomposite_int.cpp
+++ b/src/tiffcomposite_int.cpp
@@ -59,7 +59,7 @@ namespace Exiv2::Internal {
void IoWrapper::setTarget(int id, int64_t target)
{
if (target < 0 || target > std::numeric_limits::max()) {
- throw Error(kerOffsetOutOfRange);
+ throw Error(ErrorCode::kerOffsetOutOfRange);
}
if (pow_) pow_->setTarget(OffsetWriter::OffsetId(id), static_cast(target));
}
@@ -999,7 +999,8 @@ namespace Exiv2::Internal {
// Number of components to write
const uint32_t compCount = count();
- if (compCount > 0xffff) throw Error(kerTooManyTiffDirectoryEntries, groupName(group()));
+ if (compCount > 0xffff)
+ throw Error(ErrorCode::kerTooManyTiffDirectoryEntries, groupName(group()));
// Size of next IFD, if any
uint32_t sizeNext = 0;
@@ -1085,7 +1086,7 @@ namespace Exiv2::Internal {
uint32_t sv = component->size();
if (sv > 4) {
uint32_t d = component->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
- enforce(sv == d, kerImageWriteFailed);
+ enforce(sv == d, ErrorCode::kerImageWriteFailed);
if ((sv & 1) == 1) {
ioWrapper.putb(0x0); // Align value to word boundary
sv += 1;
@@ -1178,7 +1179,8 @@ namespace Exiv2::Internal {
switch(tiffType) {
case ttUnsignedShort:
case ttSignedShort:
- if (static_cast(offset) > 0xffff) throw Error(kerOffsetOutOfRange);
+ if (static_cast(offset) > 0xffff)
+ throw Error(ErrorCode::kerOffsetOutOfRange);
rc = s2Data(buf, static_cast(offset), byteOrder);
break;
case ttUnsignedLong:
@@ -1186,7 +1188,7 @@ namespace Exiv2::Internal {
rc = l2Data(buf, static_cast(offset), byteOrder);
break;
default:
- throw Error(kerUnsupportedDataAreaOffsetType);
+ throw Error(ErrorCode::kerUnsupportedDataAreaOffsetType);
break;
}
return rc;
@@ -1529,7 +1531,7 @@ namespace Exiv2::Internal {
ByteOrder /*byteOrder*/) const
{
if ( !pValue() )
- throw Error(kerImageWriteFailed); // #1296
+ throw Error(ErrorCode::kerImageWriteFailed); // #1296
size_t len = pValue()->sizeDataArea();
if (len > 0) {
diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index bffd7ce7b1..6211fcccc4 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -26,7 +26,7 @@
in crwimage.* :
+ Fix CiffHeader according to TiffHeader
- + Combine Error(kerNotAJpeg) and Error(kerNotACrwImage), add format argument %1
+ + Combine Error(ErrorCode::kerNotAJpeg) and Error(kerNotACrwImage), add format argument %1
+ Search crwimage for todos, fix writeMetadata comment
+ rename loadStack to getPath for consistency
@@ -136,7 +136,7 @@ namespace Exiv2 {
void TiffImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "TIFF"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "TIFF"));
}
void TiffImage::readMetadata()
@@ -145,15 +145,15 @@ namespace Exiv2 {
std::cerr << "Reading TIFF file " << io_->path() << "\n";
#endif
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isTiffType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAnImage, "TIFF");
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAnImage, "TIFF");
}
clearMetadata();
@@ -167,7 +167,7 @@ namespace Exiv2 {
if ( pos != exifData_.end() ) {
size_t size = pos->count() * pos->typeSize();
if (size == 0) {
- throw Error(kerFailedToReadImageData);
+ throw Error(ErrorCode::kerFailedToReadImageData);
}
iccProfile_.alloc(size);
pos->copy(iccProfile_.data(),bo);
@@ -302,13 +302,13 @@ namespace Exiv2 {
void TiffImage::printStructure(std::ostream& out, Exiv2::PrintStructureOption option,int depth)
{
- if (io_->open() != 0) throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ if (io_->open() != 0) throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
// Ensure that this is the correct image type
if (imageType() == ImageType::none) {
if (!isTiffType(*io_, false)) {
if (io_->error() || io_->eof())
- throw Error(kerFailedToReadImageData);
- throw Error(kerNotAJpeg);
+ throw Error(ErrorCode::kerFailedToReadImageData);
+ throw Error(ErrorCode::kerNotAJpeg);
}
}
diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp
index 4b33caa430..aac8014db5 100644
--- a/src/tiffimage_int.cpp
+++ b/src/tiffimage_int.cpp
@@ -2140,7 +2140,7 @@ namespace Exiv2::Internal {
if (!pData || size == 0)
return nullptr;
if (!pHeader->read(pData, size) || pHeader->offset() >= size) {
- throw Error(kerNotAnImage, "TIFF");
+ throw Error(ErrorCode::kerNotAnImage, "TIFF");
}
auto rootDir = TiffCreator::create(root, ifdIdNotSet);
if (rootDir) {
diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp
index f82a53e268..a2e76891dd 100644
--- a/src/tiffvisitor_int.cpp
+++ b/src/tiffvisitor_int.cpp
@@ -1507,7 +1507,7 @@ namespace Exiv2::Internal {
p += 4;
if (count > std::numeric_limits::max() / typeSize) {
- throw Error(kerArithmeticOverflow);
+ throw Error(ErrorCode::kerArithmeticOverflow);
}
auto size = static_cast(typeSize * count);
uint32_t offset = getLong(p, byteOrder());
@@ -1549,10 +1549,10 @@ namespace Exiv2::Internal {
if ((static_cast(baseOffset()) > std::numeric_limits::max() - static_cast(offset))
|| (static_cast(baseOffset() + offset) > std::numeric_limits::max() - reinterpret_cast(pData_)))
{
- throw Error(kerCorruptedMetadata); // #562 don't throw kerArithmeticOverflow
+ throw Error(ErrorCode::kerCorruptedMetadata); // #562 don't throw kerArithmeticOverflow
}
if (pData_ + static_cast(baseOffset()) + static_cast(offset) > pLast_) {
- throw Error(kerCorruptedMetadata);
+ throw Error(ErrorCode::kerCorruptedMetadata);
}
pData = const_cast(pData_) + baseOffset() + offset;
@@ -1576,7 +1576,7 @@ namespace Exiv2::Internal {
}
}
auto v = Value::create(typeId);
- enforce(v != nullptr, kerCorruptedMetadata);
+ enforce(v != nullptr, ErrorCode::kerCorruptedMetadata);
v->read(pData, size, byteOrder());
object->setValue(std::move(v));
@@ -1676,7 +1676,7 @@ namespace Exiv2::Internal {
if (bo == invalidByteOrder) bo = byteOrder();
TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group());
auto v = Value::create(typeId);
- enforce(v != nullptr, kerCorruptedMetadata);
+ enforce(v != nullptr, ErrorCode::kerCorruptedMetadata);
v->read(pData, size, bo);
object->setValue(std::move(v));
diff --git a/src/value.cpp b/src/value.cpp
index b4d6828267..5b3012a9dd 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -417,7 +417,7 @@ namespace Exiv2 {
charsetId = CharsetInfo::charsetIdByName(name);
if (charsetId == invalidCharsetId) {
#ifndef SUPPRESS_WARNINGS
- EXV_WARNING << Error(kerInvalidCharset, name) << "\n";
+ EXV_WARNING << Error(ErrorCode::kerInvalidCharset, name) << "\n";
#endif
return 1;
}
@@ -626,7 +626,7 @@ namespace Exiv2 {
setXmpStruct();
}
else {
- throw Error(kerInvalidXmpText, type);
+ throw Error(ErrorCode::kerInvalidXmpText, type);
}
}
value_ = b;
@@ -782,26 +782,26 @@ namespace Exiv2 {
} else {
lang = buf.substr(5, pos-5);
}
- if (lang.empty()) throw Error(kerInvalidLangAltValue, buf);
+ if (lang.empty()) throw Error(ErrorCode::kerInvalidLangAltValue, buf);
// Strip quotes (so you can also specify the language without quotes)
if (lang[0] == '"') {
lang = lang.substr(1);
if (lang.empty() || lang.find('"') != lang.length() - 1)
- throw Error(kerInvalidLangAltValue, buf);
+ throw Error(ErrorCode::kerInvalidLangAltValue, buf);
lang = lang.substr(0, lang.length()-1);
}
if (lang.empty())
- throw Error(kerInvalidLangAltValue, buf);
+ throw Error(ErrorCode::kerInvalidLangAltValue, buf);
// Check language is in the correct format (see https://www.ietf.org/rfc/rfc3066.txt)
std::string::size_type charPos = lang.find_first_not_of(ALPHA);
if (charPos != std::string::npos) {
static const char* ALPHA_NUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
if (lang.at(charPos) != '-' || lang.find_first_not_of(ALPHA_NUM, charPos+1) != std::string::npos)
- throw Error(kerInvalidLangAltValue, buf);
+ throw Error(ErrorCode::kerInvalidLangAltValue, buf);
}
b.clear();
@@ -920,7 +920,7 @@ namespace Exiv2 {
auto printWarning = [](){
#ifndef SUPPRESS_WARNINGS
- EXV_WARNING << Error(kerUnsupportedDateFormat) << "\n";
+ EXV_WARNING << Error(ErrorCode::kerUnsupportedDateFormat) << "\n";
#endif
};
@@ -1090,7 +1090,7 @@ namespace Exiv2 {
return 0;
}
#ifndef SUPPRESS_WARNINGS
- EXV_WARNING << Error(kerUnsupportedTimeFormat) << "\n";
+ EXV_WARNING << Error(ErrorCode::kerUnsupportedTimeFormat) << "\n";
#endif
return 1;
}
@@ -1115,7 +1115,7 @@ namespace Exiv2 {
time_.hour, time_.minute, time_.second,
plusMinus, abs(time_.tzHour), abs(time_.tzMinute));
- enforce(wrote == 11, Exiv2::kerUnsupportedTimeFormat);
+ enforce(wrote == 11, Exiv2::ErrorCode::kerUnsupportedTimeFormat);
std::memcpy(buf, temp, wrote);
return wrote;
}
diff --git a/src/webpimage.cpp b/src/webpimage.cpp
index ddf83ea108..112911220f 100644
--- a/src/webpimage.cpp
+++ b/src/webpimage.cpp
@@ -110,13 +110,13 @@ namespace Exiv2 {
{
// not supported
// just quietly ignore the request
- // throw(Error(kerInvalidSettingForImage, "IPTC metadata", "WebP"));
+ // throw(Error(ErrorCode::kerInvalidSettingForImage, "IPTC metadata", "WebP"));
}
void WebPImage::setComment(std::string_view /*comment*/)
{
// not supported
- throw(Error(kerInvalidSettingForImage, "Image comment", "WebP"));
+ throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "WebP"));
}
/* =========================================== */
@@ -124,7 +124,7 @@ namespace Exiv2 {
void WebPImage::writeMetadata()
{
if (io_->open() != 0) {
- throw Error(kerDataSourceOpenFailed, io_->path(), strError());
+ throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
auto tempIo = std::make_unique();
@@ -137,8 +137,8 @@ namespace Exiv2 {
void WebPImage::doWriteMetadata(BasicIo& outIo)
{
- if (!io_->isopen()) throw Error(kerInputDataReadFailed);
- if (!outIo.isopen()) throw Error(kerImageWriteFailed);
+ if (!io_->isopen()) throw Error(ErrorCode::kerInputDataReadFailed);
+ if (!outIo.isopen()) throw Error(ErrorCode::kerImageWriteFailed);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Writing metadata" << std::endl;
@@ -148,12 +148,12 @@ namespace Exiv2 {
DataBuf chunkId(WEBP_TAG_SIZE+1);
chunkId.write_uint8(WEBP_TAG_SIZE, '\0');
- io_->readOrThrow(data, WEBP_TAG_SIZE * 3, Exiv2::kerCorruptedMetadata);
+ io_->readOrThrow(data, WEBP_TAG_SIZE * 3, Exiv2::ErrorCode::kerCorruptedMetadata);
uint64_t filesize = Exiv2::getULong(data + WEBP_TAG_SIZE, littleEndian);
/* Set up header */
if (outIo.write(data, WEBP_TAG_SIZE * 3) != WEBP_TAG_SIZE * 3)
- throw Error(kerImageWriteFailed);
+ throw Error(ErrorCode::kerImageWriteFailed);
/* Parse Chunks */
bool has_size = false;
@@ -188,19 +188,19 @@ namespace Exiv2 {
case we have any exif or xmp data, also check
for any chunks with alpha frame/layer set */
while (!io_->eof() && static_cast(io_->tell()) < filesize) {
- io_->readOrThrow(chunkId.data(), WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata);
- io_->readOrThrow(size_buff, WEBP_TAG_SIZE, Exiv2::kerCorruptedMetadata);
+ io_->readOrThrow(chunkId.data(), WEBP_TAG_SIZE, Exiv2::ErrorCode::kerCorruptedMetadata);
+ io_->readOrThrow(size_buff, WEBP_TAG_SIZE, Exiv2::ErrorCode::kerCorruptedMetadata);
const uint32_t size_u32 = Exiv2::getULong(size_buff, littleEndian);
// Check that `size_u32` is safe to cast to `long`.
enforce(size_u32 <= static_cast(std::numeric_limits