[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:36:53 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=7f33baf

The following commit has been merged in the master branch:
commit 7f33baf6672522a5784121e383459e996b3542b0
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sun Dec 26 05:00:51 2004 +0000

    Removed raw data buffer from IptcData and modified flag from IptcData and IptcDatum.
    Allowed copy construction and assignment of IptcData.
---
 src/iptc.cpp | 79 +++++++++---------------------------------------------------
 src/iptc.hpp | 42 +-------------------------------
 2 files changed, 12 insertions(+), 109 deletions(-)

diff --git a/src/iptc.cpp b/src/iptc.cpp
index 420a1fa..21a8105 100644
--- a/src/iptc.cpp
+++ b/src/iptc.cpp
@@ -50,13 +50,13 @@ namespace Exiv2 {
 
     Iptcdatum::Iptcdatum(const IptcKey& key, 
                          const Value* pValue)
-        : key_(key.clone()), modified_(false)
+        : key_(key.clone())
     {
         if (pValue) value_ = pValue->clone();
     }
 
     Iptcdatum::Iptcdatum(const Iptcdatum& rhs)
-        : Metadatum(rhs), modified_(false)
+        : Metadatum(rhs)
     {
         if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
         if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
@@ -70,7 +70,6 @@ namespace Exiv2 {
     {
         if (this == &rhs) return *this;
         Metadatum::operator=(rhs);
-        modified_ = true;
 
         key_.reset();
         if (rhs.key_.get() != 0) key_ = rhs.key_->clone(); // deep copy
@@ -86,7 +85,6 @@ namespace Exiv2 {
         UShortValue::AutoPtr v = UShortValue::AutoPtr(new UShortValue);
         v->value_.push_back(value);
         value_ = v;
-        modified_ = true;
         return *this;
     }
 
@@ -104,7 +102,6 @@ namespace Exiv2 {
 
     void Iptcdatum::setValue(const Value* pValue)
     {
-        modified_ = true;
         value_.reset();
         if (pValue) value_ = pValue->clone();
     }
@@ -116,21 +113,10 @@ namespace Exiv2 {
             value_ = Value::create(type);
         }
         value_->read(value);
-        modified_ = true;
     }
 
     const byte IptcData::marker_ = 0x1C;          // Dataset marker
 
-    IptcData::IptcData() 
-        : size_(0), pData_(0), modified_(false)
-    {
-    }
-
-    IptcData::~IptcData()
-    {
-        delete[] pData_;
-    }
-
     Iptcdatum& IptcData::operator[](const std::string& key)
     {
         IptcKey iptcKey(key);
@@ -165,12 +151,7 @@ namespace Exiv2 {
 
     int IptcData::read(const byte* buf, long len)
     {
-        // Copy the data buffer
-        delete[] pData_;
-        pData_ = new byte[len];
-        memcpy(pData_, buf, len);
-        size_ = len;
-        const byte* pRead = pData_;
+        const byte* pRead = buf;
         iptcMetadata_.clear();
 
         int rc = 0;
@@ -179,7 +160,7 @@ namespace Exiv2 {
         uint32_t sizeData = 0;
         byte extTest = 0;
 
-        while (pRead < pData_ + size_) {
+        while (pRead < buf + len) {
             if (*pRead++ != marker_) return 5;
             record = *pRead++;
             dataSet = *pRead++;
@@ -205,7 +186,6 @@ namespace Exiv2 {
             pRead += sizeData;
         }
 
-        modified_ = false;
         return rc;
     } // IptcData::read
 
@@ -245,55 +225,21 @@ namespace Exiv2 {
         Image::AutoPtr image = ImageFactory::instance().open(path);
         if (image.get() == 0) return -2;
 
-        updateBuffer();
+        DataBuf buf(copy());
 
         // Read all metadata to preserve non-Iptc data
         int rc = image->readMetadata();
         if (rc == 0) {
-            image->setIptcData(pData_, size_);
+            image->setIptcData(buf.pData_, buf.size_);
             rc = image->writeMetadata();
         }
         return rc;
     } // IptcData::write
-
-    bool IptcData::modified() const
-    {
-        if (!modified_) {
-            // check each metadata entry
-            const_iterator iter = iptcMetadata_.begin();
-            const_iterator end = iptcMetadata_.end();
-            for( ; iter != end && !modified_; ++iter ) {
-                modified_ = iter->modified();
-            }
-        }
-        return modified_;
-    }
-
-    void IptcData::clearModified()
-    {
-        // check each metadata entry
-        iterator iter = iptcMetadata_.begin();
-        iterator end = iptcMetadata_.end();
-        for( ; iter != end; ++iter ) {
-            iter->clearModified();
-        }
-        modified_ = false;
-    }
     
     DataBuf IptcData::copy()
     {
-        updateBuffer();
-        return DataBuf(pData_, size_);
-    }
-
-    void IptcData::updateBuffer() 
-    {
-        if (!modified()) return;
-
-        delete [] pData_;
-        size_ = size();
-        pData_ = new byte[size_];
-        byte *pWrite = pData_;
+        DataBuf buf(size());
+        byte *pWrite = buf.pData_;
 
         const_iterator iter = iptcMetadata_.begin();
         const_iterator end = iptcMetadata_.end();
@@ -321,12 +267,11 @@ namespace Exiv2 {
             pWrite += iter->value().copy(pWrite, bigEndian);
         }
 
-        clearModified();
+        return buf;
     }
 
     long IptcData::size() const
     {
-        if (!modified()) return size_;
         long newSize = 0;
         const_iterator iter = iptcMetadata_.begin();
         const_iterator end = iptcMetadata_.end();
@@ -345,10 +290,10 @@ namespace Exiv2 {
 
     int IptcData::writeIptcData(const std::string& path)
     {
-        updateBuffer();
+        DataBuf buf(copy());
         ExvImage exvImage(path, true);
         if (!exvImage.good()) return -1;
-        exvImage.setIptcData(pData_, size_);
+        exvImage.setIptcData(buf.pData_, buf.size_);
         return exvImage.writeMetadata();
     } // IptcData::writeIptcData
 
@@ -364,7 +309,6 @@ namespace Exiv2 {
                findId(iptcDatum.tag(), iptcDatum.record()) != end()) {
              return 6;
         }
-        modified_ = true;
         // allow duplicates
         iptcMetadata_.push_back(iptcDatum);
         return 0;
@@ -406,7 +350,6 @@ namespace Exiv2 {
 
     IptcData::iterator IptcData::erase(IptcData::iterator pos)
     {
-        modified_ = true;
         return iptcMetadata_.erase(pos);
     }
 
diff --git a/src/iptc.hpp b/src/iptc.hpp
index bdde1fd..97e3a79 100644
--- a/src/iptc.hpp
+++ b/src/iptc.hpp
@@ -167,8 +167,6 @@ namespace Exiv2 {
         long count() const { return value_.get() == 0 ? 0 : value_->count(); }
         //! Return the size of the value in bytes
         long size() const { return value_.get() == 0 ? 0 : value_->size(); }
-        //! Return true if value was modified, otherwise false
-        bool modified() const { return modified_; }
         //! Return the value as a string.
         std::string toString() const 
             { return value_.get() == 0 ? "" : value_->toString(); }
@@ -234,17 +232,10 @@ namespace Exiv2 {
             { if (value_.get() != 0) return *value_; throw Error("Value not set"); }
         //@}
 
-        /*! 
-          @brief Not really meant for public use, but public so IptcData doesn't
-                 have to be made a friend
-         */
-        void clearModified() { modified_ = false; }
-
     private:
         // DATA
         IptcKey::AutoPtr key_;                  //!< Key
         Value::AutoPtr   value_;                //!< Value
-        bool modified_;                         //!< Change indicator
 
     }; // class Iptcdatum
 
@@ -288,26 +279,13 @@ namespace Exiv2 {
       - extract Iptc metadata to files, insert from these files
     */
     class IptcData {
-        //! @name Not implemented
-        //@{
-        //! Copying not allowed
-        IptcData(const IptcData& rhs);
-        //! Assignment not allowed
-        IptcData& operator=(const IptcData& rhs);
-        //@}
     public:
         //! IptcMetadata iterator type
         typedef IptcMetadata::iterator iterator;
         //! IptcMetadata const iterator type
         typedef IptcMetadata::const_iterator const_iterator;
 
-        //! @name Creators
-        //@{
-        //! Default constructor
-        IptcData();
-        //! Destructor
-        ~IptcData();
-        //@}
+        // Use the compiler generated constructors and assignment operator
 
         //! @name Manipulators
         //@{
@@ -427,8 +405,6 @@ namespace Exiv2 {
                     if the call to this function fails;<BR>
          */
         int erase(const std::string& path) const;
-        //! Return true if any metadata was modified, added, or erased.
-        bool modified() const;
         //! Begin of the metadata
         const_iterator begin() const { return iptcMetadata_.begin(); }
         //! End of the metadata
@@ -480,27 +456,11 @@ namespace Exiv2 {
         int readData(uint16_t dataSet, uint16_t record, 
                      const byte* data, uint32_t sizeData);
 
-        //! Resets modified flag
-        void clearModified();
-        
-        //! @name Manipulators
-        //@{
-        /*!
-          @brief Rebuilds the Iptc data buffer from scratch using the current
-                metadata. After this method is called, pData_ points to the
-                updated data.
-         */
-        void updateBuffer();
-        //@}
-
         // Constant data
         static const byte marker_;          // Dataset marker
         
         // DATA
         IptcMetadata iptcMetadata_;
-        long size_;              //!< Size of the Iptc raw data in bytes
-        byte* pData_;            //!< Iptc raw data buffer
-        mutable bool modified_;
     }; // class IptcData
 
 }                                       // namespace Exiv2

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list