[Digikam-devel] extragear/libs/libkexiv2

Gilles Caulier caulier.gilles at gmail.com
Thu Mar 15 09:09:22 GMT 2007


SVN commit 642722 by cgilles:

libkexiv2 from trunk : Fix broken compilation with current Exiv2 implementation (next 0.14.0 release), duing a change with C++ Exception rule. I recommend to cleanup and recompile this library and clients program witch use it.

Note : libkexiv2 still compatible with older Exiv2 releases 0.12 and 0.13

CCMAIL: digikam-devel at kde.org

 M  +66 -62    kexiv2.cpp  
 M  +6 -0      kexiv2.h  


--- trunk/extragear/libs/libkexiv2/kexiv2.cpp #642721:642722
@@ -27,7 +27,6 @@
 #include <cstdlib>
 #include <cstdio>
 #include <cassert>
-#include <string>
 #include <cmath>
 #include <iostream>
 #include <iomanip>
@@ -101,7 +100,11 @@
                               .arg(EXIV2_PATCH_VERSION);
 }
 
-// -- Protected Methods -------------------------------------
+void KExiv2::printExiv2ExceptionError(const QString& msg, Exiv2::Error& e)
+{
+    std::string s(e.what());
+    qDebug("%s (%s)", msg.ascii(), s.c_str());
+}
 
 std::string& KExiv2::commentsMetaData()
 {
@@ -118,8 +121,6 @@
     return d->iptcMetadata;
 }
 
-// -- Public Methods --------------------------------
-
 bool KExiv2::clearComments()
 {
     return setComments(QByteArray());
@@ -134,7 +135,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot clear Exif data using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot clear Exif data using Exiv2 ", e);
     }    
 
     return false;       
@@ -149,7 +150,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot clear Iptc data using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot clear Iptc data using Exiv2 ", e);
     }    
 
     return false;       
@@ -195,7 +196,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot get Exif data using Exiv2 (%s", e.what().c_str());
+        printExiv2ExceptionError("Cannot get Exif data using Exiv2 ", e);
     }       
     
     return QByteArray();
@@ -236,7 +237,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot get Iptc data using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot get Iptc data using Exiv2 ",e);
     }       
     
     return QByteArray();
@@ -265,7 +266,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot set Exif data using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif data using Exiv2 ", e);
     }        
 
     return false;
@@ -288,7 +289,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot set Iptc data using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot set Iptc data using Exiv2 ", e);
     }    
 
     return false;    
@@ -311,7 +312,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot set Exif data using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif data using Exiv2 ", e);
     }    
 
     return false;    
@@ -334,7 +335,7 @@
         if (!d->filePath.isEmpty())
             qDebug ("From file %s", d->filePath.ascii());
 
-        qDebug("Cannot set Iptc data using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot set Iptc data using Exiv2 ", e);
     }        
 
     return false;
@@ -369,9 +370,10 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot load metadata using Exiv2 (%s)", e.what().c_str());
-        return false;
+        printExiv2ExceptionError("Cannot load metadata using Exiv2 ", e);
     }
+    
+    return false;
 }
 
 bool KExiv2::save(const QString& filePath)
@@ -425,9 +427,10 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot save metadata using Exiv2 (%s)", e.what().c_str());
-        return false;
+        printExiv2ExceptionError("Cannot save metadata using Exiv2 ", e);
     }
+
+    return false;
 }
 
 bool KExiv2::applyChanges()
@@ -487,7 +490,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Program identity into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Program identity into image using Exiv2 ", e);
     }
 
     return false;
@@ -542,7 +545,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot parse image dimensions tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot parse image dimensions tag using Exiv2 ", e);
     }        
     
     return QSize();
@@ -563,7 +566,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set image dimensions using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set image dimensions using Exiv2 ", e);
     }        
     
     return false;
@@ -640,7 +643,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get Exif Thumbnail using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get Exif Thumbnail using Exiv2 ", e);
     }        
     
     return thumbnail;
@@ -663,7 +666,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif Thumbnail using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif Thumbnail using Exiv2 ", e);
     }        
     
     return false;
@@ -754,7 +757,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot parse Exif Orientation tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot parse Exif Orientation tag using Exiv2 ", e);
     }
 
     return ORIENTATION_UNSPECIFIED;
@@ -822,7 +825,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif Orientation tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif Orientation tag using Exiv2 ", e);
     }        
     
     return false;
@@ -863,7 +866,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot parse image color workspace tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot parse image color workspace tag using Exiv2 ", e);
     }        
     
     return WORKSPACE_UNSPECIFIED;    
@@ -885,7 +888,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif color workspace tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif color workspace tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1014,7 +1017,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot parse Exif date & time tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot parse Exif date & time tag using Exiv2 ", e);
     }        
     
     return QDateTime();
@@ -1059,7 +1062,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Date & Time into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Date & Time into image using Exiv2 ", e);
     }        
     
     return false;
@@ -1077,7 +1080,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get image preview using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get image preview using Exiv2 ", e);
     }
 
     return false;
@@ -1119,7 +1122,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get image preview using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get image preview using Exiv2 ", e);
     }
 
     return false;
@@ -1146,8 +1149,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Exif key '%s' into image using Exiv2 (%s)",
-               exifTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Exif key '%1' into image using Exiv2 ")
+                                 .arg(exifTagName), e);
     }
 
     return QString();
@@ -1165,7 +1168,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif tag string into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif tag string into image using Exiv2 ", e);
     }
 
     return false;
@@ -1192,8 +1195,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Iptc key '%s' into image using Exiv2 (%s)",
-               iptcTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
+                                 .arg(iptcTagName), e);
     }
 
     return QString();
@@ -1211,7 +1214,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Iptc tag string into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Iptc tag string into image using Exiv2 ", e);
     }
 
     return false;
@@ -1232,8 +1235,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Exif key '%s' into image using Exiv2 (%s)", 
-               exifTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Exif key '%1' into image using Exiv2 ")
+                                 .arg(exifTagName), e);
     }        
     
     return false;    
@@ -1256,8 +1259,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Exif key '%s' into image using Exiv2 (%s)",
-               exifTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Exif key '%1' into image using Exiv2 ")
+                                 .arg(exifTagName), e);
     }
 
     return QByteArray();
@@ -1280,8 +1283,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Iptc key '%s' into image using Exiv2 (%s)", 
-                iptcTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
+                                 .arg(iptcTagName), e);
     }
 
     return QByteArray();
@@ -1303,8 +1306,8 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Exif Rational value from key '%s' into image using Exiv2 (%s)",
-               exifTagName, e.what().c_str());
+        printExiv2ExceptionError(QString("Cannot find Exif Rational value from key '%1' " 
+                                         "into image using Exiv2 ").arg(exifTagName), e);
     }
 
     return false;
@@ -1322,7 +1325,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif tag long value into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif tag long value into image using Exiv2 ", e);
     }
 
     return false;
@@ -1340,7 +1343,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif tag rational value into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif tag rational value into image using Exiv2 ", e);
     }
 
     return false;
@@ -1362,7 +1365,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif tag data into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif tag data into image using Exiv2 ", e);
     }
 
     return false;
@@ -1384,7 +1387,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Iptc tag data into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Iptc tag data into image using Exiv2 ", e);
     }
 
     return false;
@@ -1407,7 +1410,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot remove Exif tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot remove Exif tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1430,7 +1433,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot remove Iptc tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot remove Iptc tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1528,7 +1531,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get Exif GPS tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get Exif GPS tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1651,7 +1654,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif GPS tag using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif GPS tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1687,7 +1690,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot remove Exif GPS tag using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot remove Exif GPS tag using Exiv2 ", e);
     }        
     
     return false;
@@ -1778,7 +1781,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get IPTC Keywords from image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get IPTC Keywords from image using Exiv2 ", e);
     }        
     
     return QStringList();
@@ -1835,7 +1838,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set IPTC Keywords into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set IPTC Keywords into image using Exiv2 ", e);
     }        
     
     return false;
@@ -1866,7 +1869,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get IPTC Subjects from image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get IPTC Subjects from image using Exiv2 ", e);
     }        
     
     return QStringList();
@@ -1918,7 +1921,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set IPTC Subjects into image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set IPTC Subjects into image using Exiv2 ", e);
     }        
     
     return false;
@@ -1949,7 +1952,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot get IPTC Sub Categories from image using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot get IPTC Sub Categories from image using Exiv2 ", e);
     }        
     
     return QStringList();
@@ -1981,7 +1984,8 @@
                 ++it;
         };
 
-        // Add new Sub Categories. Note that SubCategories IPTC tag is limited to 32 char but can be redondant.
+        // Add new Sub Categories. Note that SubCategories IPTC tag is limited to 32 
+        // characters but can be redondant.
 
         Exiv2::IptcKey iptcTag("Iptc.Application2.SuppCategory");
 
@@ -2001,7 +2005,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set IPTC Sub Categories into image using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot set IPTC Sub Categories into image using Exiv2 ", e);
     }        
     
     return false;
@@ -2029,7 +2033,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot find Exif User Comment using Exiv2 (%s)",e.what().c_str());
+        printExiv2ExceptionError("Cannot find Exif User Comment using Exiv2 ", e);
     }
 
     return QString();
@@ -2072,7 +2076,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot set Exif Comment using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot set Exif Comment using Exiv2 ", e);
     }
 
     return false;
@@ -2143,7 +2147,7 @@
     }
     catch( Exiv2::Error &e )
     {
-        qDebug("Cannot convert Comment using Exiv2 (%s)", e.what().c_str());
+        printExiv2ExceptionError("Cannot convert Comment using Exiv2 ", e);
     }
 
     return QString();
--- trunk/extragear/libs/libkexiv2/kexiv2.h #642721:642722
@@ -46,6 +46,7 @@
     class Exifdatum;
     class ExifData;
     class IptcData;
+    class Error;
 }
 
 namespace KExiv2Iface
@@ -95,6 +96,11 @@
     /** Return a string version of Exiv2 release in format "major.minor.patch" */ 
     static QString Exiv2Version();
 
+    /** Generic method to print the Exiv2 C++ Exception error message from 'e'.
+        'msg' string is printed just before like debug header.
+    */
+    static void printExiv2ExceptionError(const QString& msg, Exiv2::Error& e);
+
     //-- Metadata manipulation methods ----------------------------------------------
 
     /** Clear the Comments metadata container in memory. */



More information about the Digikam-devel mailing list