#476, #614: Introduced class LogMsg for enhanced logging, migrated all existing warnings and error messages (not the exceptions) to use the new logic. Every log message now has a type (debug, info, warning, error). Applications can set a logging level to determine which messages are processed and supply a custom log message handler at runtime. (Based on a contribution by Simson Garfinkel.)
This commit is contained in:
parent
1fdf4a3ab5
commit
dc264bc00d
@ -571,7 +571,7 @@ namespace Exiv2 {
|
||||
if (::lstat(pf, &buf1) == -1) {
|
||||
statOk = false;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, pf, strError(), "::lstat") << "\n";
|
||||
EXV_WARNING << Error(2, pf, strError(), "::lstat") << "\n";
|
||||
#endif
|
||||
}
|
||||
origStMode = buf1.st_mode;
|
||||
@ -588,7 +588,7 @@ namespace Exiv2 {
|
||||
if (::stat(pf, &buf1) == -1) {
|
||||
statOk = false;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, pf, strError(), "::stat") << "\n";
|
||||
EXV_WARNING << Error(2, pf, strError(), "::stat") << "\n";
|
||||
#endif
|
||||
}
|
||||
origStMode = buf1.st_mode;
|
||||
@ -616,14 +616,14 @@ namespace Exiv2 {
|
||||
if (statOk && ::_wstat(wpf, &buf2) == -1) {
|
||||
statOk = false;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, wpf, strError(), "::_wstat") << "\n";
|
||||
EXV_WARNING << Error(2, wpf, strError(), "::_wstat") << "\n";
|
||||
#endif
|
||||
}
|
||||
if (statOk && origStMode != buf2.st_mode) {
|
||||
// Set original file permissions
|
||||
if (::_wchmod(wpf, origStMode) == -1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, wpf, strError(), "::_wchmod") << "\n";
|
||||
EXV_WARNING << Error(2, wpf, strError(), "::_wchmod") << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -643,14 +643,14 @@ namespace Exiv2 {
|
||||
if (statOk && ::stat(pf, &buf2) == -1) {
|
||||
statOk = false;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, pf, strError(), "::stat") << "\n";
|
||||
EXV_WARNING << Error(2, pf, strError(), "::stat") << "\n";
|
||||
#endif
|
||||
}
|
||||
if (statOk && origStMode != buf2.st_mode) {
|
||||
// Set original file permissions
|
||||
if (::chmod(pf, origStMode) == -1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(2, pf, strError(), "::chmod") << "\n";
|
||||
EXV_WARNING << Error(2, pf, strError(), "::chmod") << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -504,7 +504,7 @@ namespace Exiv2 {
|
||||
const CommentValue* cv = dynamic_cast<const CommentValue*>(&pos->value());
|
||||
if (cv == 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -522,7 +522,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString(i);
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -544,14 +544,14 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (sscanf(value.c_str(), "%d:%d:%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec) != 6) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to
|
||||
<< ", unable to parse '" << value << "'\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to
|
||||
<< ", unable to parse '" << value << "'\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -570,7 +570,7 @@ namespace Exiv2 {
|
||||
}
|
||||
if (!ok) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -583,7 +583,7 @@ namespace Exiv2 {
|
||||
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -611,15 +611,15 @@ namespace Exiv2 {
|
||||
}
|
||||
if (datePos == exifData_->end()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
std::string value = datePos->toString();
|
||||
if (sscanf(value.c_str(), "%d:%d:%d", &year, &month, &day) != 3) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to
|
||||
<< ", unable to parse '" << value << "'\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to
|
||||
<< ", unable to parse '" << value << "'\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -694,7 +694,7 @@ namespace Exiv2 {
|
||||
int value = pos->toLong();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -715,14 +715,14 @@ namespace Exiv2 {
|
||||
if (!prepareXmpTarget(to)) return;
|
||||
if (pos->count() != 3) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
Exiv2::ExifData::iterator refPos = exifData_->findKey(ExifKey(std::string(from) + "Ref"));
|
||||
if (refPos == exifData_->end()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -732,7 +732,7 @@ namespace Exiv2 {
|
||||
const int32_t d = pos->toRational(i).second;
|
||||
if (d == 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -760,7 +760,7 @@ namespace Exiv2 {
|
||||
std::string value;
|
||||
if (!getTextValue(value, pos)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -781,7 +781,7 @@ namespace Exiv2 {
|
||||
std::string value;
|
||||
if (!getTextValue(value, pos)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -800,7 +800,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString(i);
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -820,7 +820,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -830,7 +830,7 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
catch (const XMP_Error& e) {
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << " (" << e.GetErrMsg() << ")\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << " (" << e.GetErrMsg() << ")\n";
|
||||
return;
|
||||
}
|
||||
#else
|
||||
@ -904,7 +904,7 @@ namespace Exiv2 {
|
||||
if (erase_) xmpData_->erase(pos);
|
||||
#else
|
||||
# ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
# endif
|
||||
#endif // !EXV_HAVE_XMP_TOOLKIT
|
||||
}
|
||||
@ -917,7 +917,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok() || value.length() < 4) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -940,7 +940,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -966,7 +966,7 @@ namespace Exiv2 {
|
||||
value |= fired & 1;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else
|
||||
std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Fired" << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired" << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Return"));
|
||||
@ -976,7 +976,7 @@ namespace Exiv2 {
|
||||
value |= (ret & 3) << 1;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else
|
||||
std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Return" << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return" << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Mode"));
|
||||
@ -986,7 +986,7 @@ namespace Exiv2 {
|
||||
value |= (mode & 3) << 3;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else
|
||||
std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Mode" << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode" << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Function"));
|
||||
@ -996,7 +996,7 @@ namespace Exiv2 {
|
||||
value |= (function & 1) << 5;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else
|
||||
std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:Function" << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function" << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:RedEyeMode"));
|
||||
@ -1006,7 +1006,7 @@ namespace Exiv2 {
|
||||
value |= (red & 1) << 6;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else
|
||||
std::cerr << "Warning: Failed to convert " << std::string(from) + "/exif:RedEyeMode" << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode" << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1022,13 +1022,13 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (value.empty()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << from << " is empty\n";
|
||||
EXV_WARNING << from << " is empty\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1059,7 +1059,7 @@ namespace Exiv2 {
|
||||
if ( in.bad() || !(ref == 'N' || ref == 'S' || ref == 'E' || ref == 'W')
|
||||
|| sep1 != ',' || sep2 != ',' || !in.eof()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1089,7 +1089,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString();
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
++pos;
|
||||
continue;
|
||||
@ -1115,7 +1115,7 @@ namespace Exiv2 {
|
||||
std::string value;
|
||||
if (!getTextValue(value, pos)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1131,7 +1131,7 @@ namespace Exiv2 {
|
||||
std::string value = pos->toString(i);
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
@ -1324,7 +1324,7 @@ namespace Exiv2 {
|
||||
cd = iconv_open(to, from);
|
||||
if (cd == (iconv_t)(-1)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: iconv_open: " << strError() << "\n";
|
||||
EXV_WARNING << "iconv_open: " << strError() << "\n";
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -1343,9 +1343,8 @@ namespace Exiv2 {
|
||||
int outbytesProduced = sizeof(outbuf) - 1 - outbytesleft;
|
||||
if (rc == size_t(-1) && errno != E2BIG) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: iconv: "
|
||||
<< strError()
|
||||
<< " inbytesleft = " << inbytesleft << "\n";
|
||||
EXV_WARNING << "iconv: " << strError()
|
||||
<< " inbytesleft = " << inbytesleft << "\n";
|
||||
#endif
|
||||
ret = false;
|
||||
break;
|
||||
|
||||
@ -34,7 +34,9 @@ EXIV2_RCSID("@(#) $Id$")
|
||||
#include "i18n.h" // NLS support.
|
||||
|
||||
// + standard includes
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
// *****************************************************************************
|
||||
namespace {
|
||||
@ -111,6 +113,21 @@ namespace {
|
||||
// class member definitions
|
||||
namespace Exiv2 {
|
||||
|
||||
LogMsg::Level LogMsg::level_ = LogMsg::info; // Default output level
|
||||
LogMsg::Handler LogMsg::handler_ = LogMsg::defaultHandler;
|
||||
|
||||
void LogMsg::defaultHandler(int level, const char* s)
|
||||
{
|
||||
switch (static_cast<LogMsg::Level>(level)) {
|
||||
case LogMsg::debug: std::cerr << "Debug: "; break;
|
||||
case LogMsg::info: break;
|
||||
case LogMsg::warn: std::cerr << "Warning: "; break;
|
||||
case LogMsg::error: std::cerr << "Error: "; break;
|
||||
case LogMsg::mute: assert(true);
|
||||
}
|
||||
std::cerr << s;
|
||||
}
|
||||
|
||||
AnyError::~AnyError() throw()
|
||||
{
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
*/
|
||||
/*!
|
||||
@file error.hpp
|
||||
@brief Error class for exceptions
|
||||
@brief Error class for exceptions, log message class
|
||||
@version $Rev$
|
||||
@author Andreas Huggel (ahu)
|
||||
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
|
||||
@ -38,6 +38,7 @@
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
|
||||
// *****************************************************************************
|
||||
// namespace extensions
|
||||
@ -46,6 +47,97 @@ namespace Exiv2 {
|
||||
// *****************************************************************************
|
||||
// class definitions
|
||||
|
||||
/*!
|
||||
@brief Class for a log message, used by the library. Applications can set
|
||||
the log level and provide a customer log message handler (callback
|
||||
function).
|
||||
|
||||
This class is meant to be used as a temporary object like this:
|
||||
|
||||
<code>
|
||||
LogMsg(LogMsg::warn) << "Warning! Something looks fishy.\n";
|
||||
</code>
|
||||
|
||||
The convenience macros EXV_DEBUG, EXV_INFO, EXV_WARN and EXV_ERROR
|
||||
are just shorthands for the constructor calls.
|
||||
*/
|
||||
class EXIV2API LogMsg {
|
||||
public:
|
||||
/*!
|
||||
@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 };
|
||||
/*!
|
||||
@brief Type for a log message handler function. The function receives
|
||||
the log level and message and can process it in an application
|
||||
specific way. The default handler sends the log message to
|
||||
standard error.
|
||||
*/
|
||||
typedef void (*Handler)(int, const char*);
|
||||
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor, takes the log message type as an argument
|
||||
explicit LogMsg(Level msgType) : msgType_(msgType) {}
|
||||
//! Destructor, passes the log message to the message handler depending on the log level
|
||||
~LogMsg() { if (msgType_ >= level_ && handler_) handler_(msgType_, os_.str().c_str()); }
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
/*!
|
||||
@brief Output operator, to pass the message to a log message object.
|
||||
(This is not perfect. It can deal with some std manipulators
|
||||
but not all, e.g., not std::endl.)
|
||||
*/
|
||||
template<typename T>
|
||||
LogMsg& operator<<(const T& t)
|
||||
{
|
||||
os_ << t;
|
||||
return *this;
|
||||
}
|
||||
//@}
|
||||
|
||||
/*!
|
||||
@brief Set the log level. Only log messages with a level greater or
|
||||
equal \em level are sent to the log message handler. Default
|
||||
log level is \c info. To suppress all log messages, set the log
|
||||
level to \c mute (or set the log message handler to 0).
|
||||
*/
|
||||
static void setLevel(Level level) { level_ = level; }
|
||||
/*!
|
||||
@brief Set the log message handler. The default handler writes log
|
||||
messages to standard error. To suppress all log messages, set
|
||||
the log message handler to 0 (or set the log level to \c mute).
|
||||
*/
|
||||
static void setHandler(Handler handler) { handler_ = handler; }
|
||||
//! Return the current log level
|
||||
static Level level() { return level_; }
|
||||
//! Return the current log message handler
|
||||
static Handler handler() { return handler_; }
|
||||
//! The default log handler. Sends the log message to standard error.
|
||||
static void defaultHandler(int level, const char* s);
|
||||
|
||||
private:
|
||||
// DATA
|
||||
// The output level. Only messages with type >= level_ will be written
|
||||
static Level level_;
|
||||
// The log handler in use
|
||||
static Handler handler_;
|
||||
// The type of this log message
|
||||
const Level msgType_;
|
||||
// Holds the log message until it is passed to the message handler
|
||||
std::ostringstream os_;
|
||||
|
||||
}; // class LogMsg
|
||||
|
||||
// Macros for simple access
|
||||
#define EXV_DEBUG LogMsg(LogMsg::debug) //!< Shorthand for a debug log message object
|
||||
#define EXV_INFO LogMsg(LogMsg::info) //!< Shorthand for an info log message object
|
||||
#define EXV_WARNING LogMsg(LogMsg::warn) //!< Shorthand for a warning log message object
|
||||
#define EXV_ERROR LogMsg(LogMsg::error) //!< Shorthand for an error log message object
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Disable MSVC warnings "non - DLL-interface classkey 'identifier' used as base
|
||||
// for DLL-interface classkey 'identifier'"
|
||||
|
||||
12
src/exif.cpp
12
src/exif.cpp
@ -634,10 +634,10 @@ namespace Exiv2 {
|
||||
size);
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
if (!iptcData.empty()) {
|
||||
std::cerr << "Warning: Ignoring IPTC information encoded in the Exif data.\n";
|
||||
EXV_WARNING << "Ignoring IPTC information encoded in the Exif data.\n";
|
||||
}
|
||||
if (!xmpData.empty()) {
|
||||
std::cerr << "Warning: Ignoring XMP information encoded in the Exif data.\n";
|
||||
EXV_WARNING << "Ignoring XMP information encoded in the Exif data.\n";
|
||||
}
|
||||
#endif
|
||||
return bo;
|
||||
@ -765,7 +765,7 @@ namespace Exiv2 {
|
||||
if (pos != ed.end() && sumToLong(*pos) > 32768) {
|
||||
delTags = true;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n";
|
||||
EXV_WARNING << "Exif tag " << pos->key() << " not encoded\n";
|
||||
#endif
|
||||
ed.erase(pos);
|
||||
}
|
||||
@ -775,7 +775,7 @@ namespace Exiv2 {
|
||||
pos = ed.findKey(ExifKey(filteredPvTags[i].key_));
|
||||
if (pos != ed.end()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n";
|
||||
EXV_WARNING << "Exif tag " << pos->key() << " not encoded\n";
|
||||
#endif
|
||||
ed.erase(pos);
|
||||
}
|
||||
@ -784,7 +784,7 @@ namespace Exiv2 {
|
||||
case pttIfd:
|
||||
if (delTags) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Exif IFD " << filteredPvTags[i].key_ << " not encoded\n";
|
||||
EXV_WARNING << "Exif IFD " << filteredPvTags[i].key_ << " not encoded\n";
|
||||
#endif
|
||||
eraseIfd(ed, Internal::groupId(filteredPvTags[i].key_));
|
||||
}
|
||||
@ -797,7 +797,7 @@ namespace Exiv2 {
|
||||
if ( pos->size() > 4096
|
||||
&& pos->tagName().substr(0, 2) == "0x") {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n";
|
||||
EXV_WARNING << "Exif tag " << pos->key() << " not encoded\n";
|
||||
#endif
|
||||
pos = ed.erase(pos);
|
||||
}
|
||||
|
||||
12
src/iptc.cpp
12
src/iptc.cpp
@ -451,18 +451,16 @@ namespace Exiv2 {
|
||||
int rc = 0;
|
||||
if ((rc = readData(iptcData, dataSet, record, pRead, sizeData)) != 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Failed to read IPTC dataset "
|
||||
<< IptcKey(dataSet, record)
|
||||
<< " (rc = " << rc << "); skipped.\n";
|
||||
EXV_WARNING << "Failed to read IPTC dataset "
|
||||
<< IptcKey(dataSet, record)
|
||||
<< " (rc = " << rc << "); skipped.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else {
|
||||
std::cerr << "Warning: "
|
||||
<< "IPTC dataset " << IptcKey(dataSet, record)
|
||||
<< " has invalid size " << sizeData << "; skipped.\n";
|
||||
EXV_WARNING << "IPTC dataset " << IptcKey(dataSet, record)
|
||||
<< " has invalid size " << sizeData << "; skipped.\n";
|
||||
}
|
||||
#endif
|
||||
pRead += sizeData;
|
||||
|
||||
@ -286,7 +286,7 @@ namespace Exiv2
|
||||
else
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::Jp2Image::readMetadata: Failed to decode Exif metadata.\n";
|
||||
EXV_WARNING << "Failed to decode Exif metadata.\n";
|
||||
#endif
|
||||
exifData_.clear();
|
||||
}
|
||||
@ -305,7 +305,7 @@ namespace Exiv2
|
||||
if (IptcParser::decode(iptcData_, rawData.pData_, rawData.size_))
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode IPTC metadata.\n";
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
iptcData_.clear();
|
||||
}
|
||||
@ -327,9 +327,8 @@ namespace Exiv2
|
||||
if (idx != std::string::npos && idx > 0)
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::Jp2Image::readMetadata: Removing "
|
||||
<< static_cast<uint32_t>(idx)
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
EXV_WARNING << "Removing " << static_cast<uint32_t>(idx)
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
#endif
|
||||
xmpPacket_ = xmpPacket_.substr(idx);
|
||||
}
|
||||
@ -337,7 +336,7 @@ namespace Exiv2
|
||||
if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_))
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::Jp2Image::readMetadata: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -532,7 +531,7 @@ namespace Exiv2
|
||||
if (XmpParser::encode(xmpPacket_, xmpData_) > 1)
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ namespace Exiv2 {
|
||||
setByteOrder(bo);
|
||||
if (rawExif.size_ > 0 && byteOrder() == invalidByteOrder) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode Exif metadata.\n";
|
||||
EXV_WARNING << "Failed to decode Exif metadata.\n";
|
||||
#endif
|
||||
exifData_.clear();
|
||||
}
|
||||
@ -368,7 +368,7 @@ namespace Exiv2 {
|
||||
xmpPacket_.assign(reinterpret_cast<char*>(xmpPacket.pData_), xmpPacket.size_);
|
||||
if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
--search;
|
||||
@ -474,7 +474,7 @@ namespace Exiv2 {
|
||||
&iptcBlob[0],
|
||||
static_cast<uint32_t>(iptcBlob.size()))) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode IPTC metadata.\n";
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
iptcData_.clear();
|
||||
}
|
||||
@ -482,7 +482,7 @@ namespace Exiv2 {
|
||||
|
||||
if (rc != 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: JPEG format error, rc = " << rc << "\n";
|
||||
EXV_WARNING << "JPEG format error, rc = " << rc << "\n";
|
||||
#endif
|
||||
}
|
||||
} // JpegBase::readMetadata
|
||||
@ -698,7 +698,7 @@ namespace Exiv2 {
|
||||
if (writeXmpFromPacket() == false) {
|
||||
if (XmpParser::encode(xmpPacket_, xmpData_, XmpParser::useCompactFormat | XmpParser::omitAllFormatting) > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ namespace Exiv2 {
|
||||
else
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::PngChunk::parseChunkContent: Failed to decode Exif metadata.\n";
|
||||
EXV_WARNING << "Failed to decode Exif metadata.\n";
|
||||
#endif
|
||||
pImage->exifData().clear();
|
||||
}
|
||||
@ -317,7 +317,7 @@ namespace Exiv2 {
|
||||
&iptcBlob[0],
|
||||
static_cast<uint32_t>(iptcBlob.size()))) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode IPTC metadata.\n";
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
pImage->clearIptcData();
|
||||
}
|
||||
@ -327,7 +327,7 @@ namespace Exiv2 {
|
||||
psData.pData_,
|
||||
psData.size_)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode IPTC metadata.\n";
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
pImage->clearIptcData();
|
||||
}
|
||||
@ -351,15 +351,15 @@ namespace Exiv2 {
|
||||
if (idx != std::string::npos && idx > 0)
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::PngChunk::parseChunkContent: Removing " << idx
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
EXV_WARNING << "Removing " << idx
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
#endif
|
||||
xmpPacket = xmpPacket.substr(idx);
|
||||
}
|
||||
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Exiv2::PngChunk::parseChunkContent: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -379,15 +379,15 @@ namespace Exiv2 {
|
||||
if (idx != std::string::npos && idx > 0)
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Removing " << idx << " characters "
|
||||
<< "from the beginning of the XMP packet\n";
|
||||
EXV_WARNING << "Removing " << idx << " characters "
|
||||
<< "from the beginning of the XMP packet\n";
|
||||
#endif
|
||||
xmpPacket = xmpPacket.substr(idx);
|
||||
}
|
||||
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ namespace Exiv2 {
|
||||
if (writeXmpFromPacket() == false) {
|
||||
if (XmpParser::encode(xmpPacket_, xmpData_) > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ namespace {
|
||||
}
|
||||
catch (const AnyError& /* error */ ) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Invalid JPEG preview image.\n";
|
||||
EXV_WARNING << "Invalid JPEG preview image.\n";
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ namespace Exiv2 {
|
||||
if (io_->error() || io_->eof()) throw Error(14);
|
||||
if (IptcParser::decode(iptcData_, rawIPTC.pData_, rawIPTC.size_)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode IPTC metadata.\n";
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
iptcData_.clear();
|
||||
}
|
||||
@ -275,7 +275,7 @@ namespace Exiv2 {
|
||||
setByteOrder(bo);
|
||||
if (rawExif.size_ > 0 && byteOrder() == invalidByteOrder) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode Exif metadata.\n";
|
||||
EXV_WARNING << "Failed to decode Exif metadata.\n";
|
||||
#endif
|
||||
exifData_.clear();
|
||||
}
|
||||
@ -290,7 +290,7 @@ namespace Exiv2 {
|
||||
xmpPacket_.assign(reinterpret_cast<char *>(xmpPacket.pData_), xmpPacket.size_);
|
||||
if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -608,7 +608,7 @@ namespace Exiv2 {
|
||||
if (writeXmpFromPacket() == false) {
|
||||
if (XmpParser::encode(xmpPacket, xmpData) > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ namespace Exiv2 {
|
||||
// Todo: What if there are more preview images?
|
||||
if (list.size() > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: RW2 image contains more than one preview. None used.\n";
|
||||
EXV_WARNING << "RW2 image contains more than one preview. None used.\n";
|
||||
#endif
|
||||
}
|
||||
if (list.size() != 1) return;
|
||||
@ -143,7 +143,7 @@ namespace Exiv2 {
|
||||
Image::AutoPtr image = ImageFactory::open(preview.pData(), preview.size());
|
||||
if (image.get() == 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to open RW2 preview image.\n";
|
||||
EXV_WARNING << "Failed to open RW2 preview image.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2084,7 +2084,7 @@ namespace Exiv2 {
|
||||
cd = iconv_open("UTF-8", "UCS-2LE");
|
||||
if (cd == (iconv_t)(-1)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: iconv_open: " << strError() << "\n";
|
||||
EXV_WARNING << "iconv_open: " << strError() << "\n";
|
||||
#endif
|
||||
go = false;
|
||||
}
|
||||
@ -2106,9 +2106,8 @@ namespace Exiv2 {
|
||||
&outbytesleft);
|
||||
if (rc == size_t(-1)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: iconv: "
|
||||
<< strError()
|
||||
<< " inbytesleft = " << inbytesleft << "\n";
|
||||
EXV_WARNING << "iconv: " << strError()
|
||||
<< " inbytesleft = " << inbytesleft << "\n";
|
||||
#endif
|
||||
go = false;
|
||||
}
|
||||
|
||||
@ -399,32 +399,29 @@ namespace Exiv2 {
|
||||
{
|
||||
if (!pValue() || !pSize) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size or data offset value not set, ignoring them.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size or data offset value not set, ignoring them.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (pValue()->count() == 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data offset entry value is empty, ignoring it.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data offset entry value is empty, ignoring it.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (pValue()->count() != pSize->count()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size and data offset entries have different"
|
||||
<< " number of components, ignoring them.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size and data offset entries have different"
|
||||
<< " number of components, ignoring them.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -439,11 +436,10 @@ namespace Exiv2 {
|
||||
+ static_cast<uint32_t>(pSize->toLong(pSize->count()-1))
|
||||
- offset != size) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data area is not contiguous, ignoring it.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data area is not contiguous, ignoring it.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -451,11 +447,10 @@ namespace Exiv2 {
|
||||
|| size > sizeData
|
||||
|| baseOffset + offset > sizeData - size) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data area exceeds data buffer, ignoring it.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Data area exceeds data buffer, ignoring it.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -471,22 +466,20 @@ namespace Exiv2 {
|
||||
{
|
||||
if (!pValue() || !pSize) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size or data offset value not set, ignoring them.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size or data offset value not set, ignoring them.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (pValue()->count() != pSize->count()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size and data offset entries have different"
|
||||
<< " number of components, ignoring them.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Size and data offset entries have different"
|
||||
<< " number of components, ignoring them.\n";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -499,12 +492,11 @@ namespace Exiv2 {
|
||||
|| size > sizeData
|
||||
|| baseOffset + offset > sizeData - size) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Strip " << std::dec << i
|
||||
<< " is outside of the data area; ignored.\n";
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << tag()
|
||||
<< ": Strip " << std::dec << i
|
||||
<< " is outside of the data area; ignored.\n";
|
||||
#endif
|
||||
}
|
||||
else if (size != 0) {
|
||||
@ -1824,7 +1816,7 @@ namespace Exiv2 {
|
||||
{
|
||||
if (static_cast<uint32_t>(typeId) > 0xffff) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: '" << TypeInfo::typeName(typeId)
|
||||
EXV_ERROR << "'" << TypeInfo::typeName(typeId)
|
||||
<< "' is not a valid Exif (TIFF) type; using type '"
|
||||
<< TypeInfo::typeName(undefined) << "'.\n";
|
||||
#endif
|
||||
|
||||
@ -404,14 +404,14 @@ namespace Exiv2 {
|
||||
std::string::size_type idx = xmpPacket.find_first_of('<');
|
||||
if (idx != std::string::npos && idx > 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Removing " << static_cast<unsigned long>(idx)
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
EXV_WARNING << "Removing " << static_cast<unsigned long>(idx)
|
||||
<< " characters from the beginning of the XMP packet\n";
|
||||
#endif
|
||||
xmpPacket = xmpPacket.substr(idx);
|
||||
}
|
||||
if (XmpParser::decode(xmpData_, xmpPacket)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -438,8 +438,8 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else {
|
||||
std::cerr << "Warning: Failed to decode IPTC block found in "
|
||||
<< "Directory Image, entry 0x83bb\n";
|
||||
EXV_WARNING << "Failed to decode IPTC block found in "
|
||||
<< "Directory Image, entry 0x83bb\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -462,8 +462,8 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else {
|
||||
std::cerr << "Warning: Failed to decode IPTC block found in "
|
||||
<< "Directory Image, entry 0x8649\n";
|
||||
EXV_WARNING << "Failed to decode IPTC block found in "
|
||||
<< "Directory Image, entry 0x8649\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -624,7 +624,7 @@ namespace Exiv2 {
|
||||
std::string xmpPacket;
|
||||
if (XmpParser::encode(xmpPacket, xmpData_) > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
if (!xmpPacket.empty()) {
|
||||
@ -942,7 +942,7 @@ namespace Exiv2 {
|
||||
const byte* zero = 0;
|
||||
if (pos == exifData_.end()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Size tag " << key
|
||||
EXV_ERROR << "Size tag " << key
|
||||
<< " not found. Writing only one strip.\n";
|
||||
#endif
|
||||
object->strips_.clear();
|
||||
@ -959,7 +959,7 @@ namespace Exiv2 {
|
||||
if (sizeTotal != sizeDataArea) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
ExifKey key2(object->tag(), groupName(object->group()));
|
||||
std::cerr << "Error: Sum of all sizes of " << key
|
||||
EXV_ERROR << "Sum of all sizes of " << key
|
||||
<< " != data size of " << key2 << ". "
|
||||
<< "This results in an invalid image.\n";
|
||||
#endif
|
||||
@ -984,7 +984,7 @@ namespace Exiv2 {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else {
|
||||
ExifKey key2(object->tag(), groupName(object->group()));
|
||||
std::cerr << "Warning: No image data to encode " << key2 << ".\n";
|
||||
EXV_WARNING << "No image data to encode " << key2 << ".\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1227,8 +1227,7 @@ namespace Exiv2 {
|
||||
DirList::const_iterator pos = dirList_.find(start);
|
||||
if (pos != dirList_.end()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< groupName(group) << " pointer references previously read "
|
||||
EXV_ERROR << groupName(group) << " pointer references previously read "
|
||||
<< groupName(pos->second) << " directory. Ignored.\n";
|
||||
#endif
|
||||
return true;
|
||||
@ -1262,8 +1261,7 @@ namespace Exiv2 {
|
||||
|
||||
if (p + 2 > pLast_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ": IFD exceeds data buffer, cannot read entry count.\n";
|
||||
#endif
|
||||
return;
|
||||
@ -1273,8 +1271,7 @@ namespace Exiv2 {
|
||||
// Sanity check with an "unreasonably" large number
|
||||
if (n > 256) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group()) << " with "
|
||||
EXV_ERROR << "Directory " << groupName(object->group()) << " with "
|
||||
<< n << " entries considered invalid; not read.\n";
|
||||
#endif
|
||||
return;
|
||||
@ -1282,8 +1279,7 @@ namespace Exiv2 {
|
||||
for (uint16_t i = 0; i < n; ++i) {
|
||||
if (p + 12 > pLast_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ": IFD entry " << i
|
||||
<< " lies outside of the data buffer.\n";
|
||||
#endif
|
||||
@ -1302,8 +1298,7 @@ namespace Exiv2 {
|
||||
if (object->hasNext()) {
|
||||
if (p + 4 > pLast_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ": IFD exceeds data buffer, cannot read next pointer.\n";
|
||||
#endif
|
||||
return;
|
||||
@ -1314,17 +1309,15 @@ namespace Exiv2 {
|
||||
tc = TiffCreator::create(Tag::next, object->group());
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
if (tc.get() == 0) {
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
<< " has an unhandled next pointer.\n";
|
||||
EXV_WARNING << "Directory " << groupName(object->group())
|
||||
<< " has an unhandled next pointer.\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (tc.get()) {
|
||||
if (baseOffset() + next > size_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ": Next pointer is out of bounds; ignored.\n";
|
||||
#endif
|
||||
return;
|
||||
@ -1349,8 +1342,7 @@ namespace Exiv2 {
|
||||
if ( baseOffset() + offset > size_
|
||||
|| static_cast<int32_t>(baseOffset()) + offset < 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " Sub-IFD pointer " << i
|
||||
@ -1360,11 +1352,10 @@ namespace Exiv2 {
|
||||
}
|
||||
if (object->newGroup_ + i == subImage9Id + 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< ": Skipping sub-IFDs beyond the first " << i << ".\n";
|
||||
EXV_WARNING << "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< ": Skipping sub-IFDs beyond the first " << i << ".\n";
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -1377,11 +1368,10 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
else {
|
||||
std::cerr << "Warning: "
|
||||
<< "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " doesn't look like a sub-IFD.\n";
|
||||
EXV_WARNING << "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " doesn't look like a sub-IFD.\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1421,7 +1411,7 @@ namespace Exiv2 {
|
||||
static_cast<uint32_t>(pLast_ - object->start()),
|
||||
byteOrder())) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to read "
|
||||
EXV_ERROR << "Failed to read "
|
||||
<< groupName(object->ifd_.group())
|
||||
<< " IFD Makernote header.\n";
|
||||
#ifdef DEBUG
|
||||
@ -1460,7 +1450,7 @@ namespace Exiv2 {
|
||||
|
||||
if (p + 12 > pLast_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Entry in directory " << groupName(object->group())
|
||||
EXV_ERROR << "Entry in directory " << groupName(object->group())
|
||||
<< "requests access to memory beyond the data buffer. "
|
||||
<< "Skipping entry.\n";
|
||||
#endif
|
||||
@ -1473,11 +1463,11 @@ namespace Exiv2 {
|
||||
long typeSize = TypeInfo::typeSize(typeId);
|
||||
if (0 == typeSize) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " has unknown Exif (TIFF) type " << std::dec << tiffType
|
||||
<< "; setting type size 1.\n";
|
||||
EXV_WARNING << "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " has unknown Exif (TIFF) type " << std::dec << tiffType
|
||||
<< "; setting type size 1.\n";
|
||||
#endif
|
||||
typeSize = 1;
|
||||
}
|
||||
@ -1485,7 +1475,7 @@ namespace Exiv2 {
|
||||
uint32_t count = getULong(p, byteOrder());
|
||||
if (count >= 0x10000000) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Directory " << groupName(object->group())
|
||||
EXV_ERROR << "Directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " has invalid size "
|
||||
@ -1502,14 +1492,13 @@ namespace Exiv2 {
|
||||
&& ( baseOffset() + offset >= size_
|
||||
|| static_cast<int32_t>(baseOffset()) + offset <= 0)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Offset of "
|
||||
<< "directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " is out of bounds: "
|
||||
<< "Offset = 0x" << std::setw(8)
|
||||
<< std::setfill('0') << std::hex << offset
|
||||
<< "; truncating the entry\n";
|
||||
EXV_ERROR << "Offset of directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
<< " is out of bounds: "
|
||||
<< "Offset = 0x" << std::setw(8)
|
||||
<< std::setfill('0') << std::hex << offset
|
||||
<< "; truncating the entry\n";
|
||||
#endif
|
||||
size = 0;
|
||||
}
|
||||
@ -1517,7 +1506,7 @@ namespace Exiv2 {
|
||||
pData = const_cast<byte*>(pData_) + baseOffset() + offset;
|
||||
if (size > static_cast<uint32_t>(pLast_ - pData)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Upper boundary of data for "
|
||||
EXV_ERROR << "Upper boundary of data for "
|
||||
<< "directory " << groupName(object->group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
<< std::setfill('0') << std::hex << object->tag()
|
||||
|
||||
@ -473,7 +473,7 @@ namespace Exiv2 {
|
||||
charsetId = CharsetInfo::charsetIdByName(name);
|
||||
if (charsetId == invalidCharsetId) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(28, name) << "\n";
|
||||
EXV_WARNING << Error(28, name) << "\n";
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -925,7 +925,7 @@ namespace Exiv2 {
|
||||
// Hard coded to read Iptc style dates
|
||||
if (len != 8) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(29) << "\n";
|
||||
EXV_WARNING << Error(29) << "\n";
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -936,7 +936,7 @@ namespace Exiv2 {
|
||||
&date_.year, &date_.month, &date_.day);
|
||||
if (scanned != 3) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(29) << "\n";
|
||||
EXV_WARNING << Error(29) << "\n";
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -948,7 +948,7 @@ namespace Exiv2 {
|
||||
// Hard coded to read Iptc style dates
|
||||
if (buf.length() < 8) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(29) << "\n";
|
||||
EXV_WARNING << Error(29) << "\n";
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -956,7 +956,7 @@ namespace Exiv2 {
|
||||
&date_.year, &date_.month, &date_.day);
|
||||
if (scanned != 3) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(29) << "\n";
|
||||
EXV_WARNING << Error(29) << "\n";
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ namespace Exiv2 {
|
||||
if (rc) {
|
||||
rc = 1;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(30) << "\n";
|
||||
EXV_WARNING << Error(30) << "\n";
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
@ -1091,7 +1091,7 @@ namespace Exiv2 {
|
||||
if (rc) {
|
||||
rc = 1;
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: " << Error(30) << "\n";
|
||||
EXV_WARNING << Error(30) << "\n";
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
|
||||
12
src/xmp.cpp
12
src/xmp.cpp
@ -449,7 +449,7 @@ namespace Exiv2 {
|
||||
|
||||
if (!initialize()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "XMP Toolkit initialization failed.\n";
|
||||
EXV_ERROR << "XMP toolkit initialization failed.\n";
|
||||
#endif
|
||||
return 2;
|
||||
}
|
||||
@ -568,7 +568,7 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
catch (const XMP_Error& e) {
|
||||
std::cerr << Error(40, e.GetID(), e.GetErrMsg()) << "\n";
|
||||
EXV_ERROR << Error(40, e.GetID(), e.GetErrMsg()) << "\n";
|
||||
xmpData.clear();
|
||||
return 3;
|
||||
}
|
||||
@ -586,7 +586,7 @@ namespace Exiv2 {
|
||||
xmpData.clear();
|
||||
if (!xmpPacket.empty()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: XMP toolkit support not compiled in.\n";
|
||||
EXV_WARNING << "XMP toolkit support not compiled in.\n";
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
@ -606,7 +606,7 @@ namespace Exiv2 {
|
||||
|
||||
if (!initialize()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "XMP Toolkit initialization failed.\n";
|
||||
EXV_ERROR << "XMP toolkit initialization failed.\n";
|
||||
#endif
|
||||
return 2;
|
||||
}
|
||||
@ -689,7 +689,7 @@ namespace Exiv2 {
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
catch (const XMP_Error& e) {
|
||||
std::cerr << Error(40, e.GetID(), e.GetErrMsg()) << "\n";
|
||||
EXV_ERROR << Error(40, e.GetID(), e.GetErrMsg()) << "\n";
|
||||
return 3;
|
||||
}
|
||||
#else
|
||||
@ -706,7 +706,7 @@ namespace Exiv2 {
|
||||
{
|
||||
if (!xmpData.empty()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: XMP toolkit support not compiled in.\n";
|
||||
EXV_WARNING << "XMP toolkit support not compiled in.\n";
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
|
||||
@ -106,7 +106,7 @@ namespace Exiv2 {
|
||||
xmpPacket_ = xmpPacket;
|
||||
if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_)) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
||||
EXV_WARNING << "Failed to decode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
copyXmpToIptc(xmpData_, iptcData_);
|
||||
@ -126,7 +126,7 @@ namespace Exiv2 {
|
||||
if (XmpParser::encode(xmpPacket_, xmpData_,
|
||||
XmpParser::omitPacketWrapper|XmpParser::useCompactFormat) > 1) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Error: Failed to encode XMP metadata.\n";
|
||||
EXV_ERROR << "Failed to encode XMP metadata.\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user