[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:41:54 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=45c2eb2
The following commit has been merged in the master branch:
commit 45c2eb2d343bcec8640dfe431a913cf9483a50a3
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Tue Aug 24 15:45:30 2010 +0000
#721: Use Pimpl idiom for class ExifKey in preparation for more changes.
---
src/exif.cpp | 5 --
src/exif.hpp | 2 -
src/properties.cpp | 1 +
src/tags.cpp | 171 +++++++++++++++++++++++++++++++++-------------------
src/tags.hpp | 37 +++---------
src/tiffvisitor.cpp | 2 +-
6 files changed, 118 insertions(+), 100 deletions(-)
diff --git a/src/exif.cpp b/src/exif.cpp
index 6530093..db6b537 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -352,11 +352,6 @@ namespace Exiv2 {
return key_.get() == 0 ? "" : key_->ifdName();
}
- std::string Exifdatum::ifdItem() const
- {
- return key_.get() == 0 ? "" : key_->ifdItem();
- }
-
int Exifdatum::idx() const
{
return key_.get() == 0 ? 0 : key_->idx();
diff --git a/src/exif.hpp b/src/exif.hpp
index 613e644..3b276ab 100644
--- a/src/exif.hpp
+++ b/src/exif.hpp
@@ -165,8 +165,6 @@ namespace Exiv2 {
IfdId ifdId() const;
//! Return the name of the IFD
const char* ifdName() const;
- //! Return the related image item (deprecated)
- std::string ifdItem() const;
//! Return the index (unique id of this key within the original IFD)
int idx() const;
/*!
diff --git a/src/properties.cpp b/src/properties.cpp
index 8f5af3a..3dc3915 100644
--- a/src/properties.cpp
+++ b/src/properties.cpp
@@ -1238,6 +1238,7 @@ namespace Exiv2 {
XmpKey& XmpKey::operator=(const XmpKey& rhs)
{
if (this == &rhs) return *this;
+ Key::operator=(rhs);
*p_ = *rhs.p_;
return *this;
}
diff --git a/src/tags.cpp b/src/tags.cpp
index b088d26..fdf5492 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -2721,84 +2721,158 @@ namespace Exiv2 {
}
} // ExifTags::taglist
- const char* ExifKey::familyName_ = "Exif";
+ //! Internal Pimpl structure with private members and data of class ExifKey.
+ struct ExifKey::Impl {
+ //! @name Creators
+ //@{
+ Impl(); //!< Default constructor
+ //@}
+
+ //! @name Manipulators
+ //@{
+ /*!
+ @brief Set the key corresponding to the tag and IFD id.
+ The key is of the form '<b>Exif</b>.ifdItem.tagName'.
+ */
+ void makeKey(uint16_t tag, IfdId ifdId, const std::string& ifdItem);
+ /*!
+ @brief Parse and convert the key string into tag and IFD Id.
+ Updates data members if the string can be decomposed,
+ or throws \em Error .
+
+ @throw Error if the key cannot be decomposed.
+ */
+ void decomposeKey(const std::string& key);
+ //@}
+
+ // DATA
+ static const char* familyName_; //!< "Exif"
+
+ uint16_t tag_; //!< Tag value
+ IfdId ifdId_; //!< The IFD associated with this tag
+ std::string ifdItem_; //!< The IFD item
+ int idx_; //!< Unique id of the Exif key in the image
+ std::string key_; //!< Key
+ };
+ //! @endcond
- ExifKey::ExifKey(const std::string& key)
- : tag_(0), ifdId_(ifdIdNotSet), ifdItem_(""),
- idx_(0), key_(key)
+ const char* ExifKey::Impl::familyName_ = "Exif";
+
+ ExifKey::Impl::Impl()
+ : tag_(0), ifdId_(ifdIdNotSet), idx_(0)
{
- decomposeKey();
}
- ExifKey::ExifKey(uint16_t tag, const std::string& ifdItem)
- : tag_(0), ifdId_(ifdIdNotSet), ifdItem_(""),
- idx_(0), key_("")
+ void ExifKey::Impl::decomposeKey(const std::string& key)
{
+ // 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(6, key);
+ std::string familyName = key.substr(0, pos1);
+ if (0 != strcmp(familyName.c_str(), familyName_)) {
+ throw Error(6, key);
+ }
+ std::string::size_type pos0 = pos1 + 1;
+ pos1 = key.find('.', pos0);
+ if (pos1 == std::string::npos) throw Error(6, key);
+ std::string ifdItem = key.substr(pos0, pos1 - pos0);
+ if (ifdItem == "") throw Error(6, key);
+ std::string tagName = key.substr(pos1 + 1);
+ if (tagName == "") throw Error(6, key);
+
+ // Find IfdId
IfdId ifdId = ExifTags::ifdIdByIfdItem(ifdItem);
+ if (ifdId == ifdIdNotSet) throw Error(6, key);
if (!ExifTags::isExifIfd(ifdId) && !ExifTags::isMakerIfd(ifdId)) {
- throw Error(23, ifdId);
+ throw Error(6, key);
}
+ // Convert tag
+ uint16_t tag = ExifTags::tag(tagName, ifdId);
+
+ // Translate hex tag name (0xabcd) to a real tag name if there is one
+ tagName = ExifTags::tagName(tag, ifdId);
+
tag_ = tag;
ifdId_ = ifdId;
ifdItem_ = ifdItem;
- makeKey();
+ key_ = familyName + "." + ifdItem + "." + tagName;
+ }
+
+ void ExifKey::Impl::makeKey(uint16_t tag, IfdId ifdId, const std::string& ifdItem)
+ {
+ tag_ = tag;
+ ifdId_ = ifdId;
+ ifdItem_ = ifdItem;
+ key_ = std::string(familyName_) + "." + ifdItem + "." + ExifTags::tagName(tag, ifdId);
+ }
+
+ ExifKey::ExifKey(const std::string& key)
+ : p_(new Impl)
+ {
+ p_->decomposeKey(key);
+ }
+
+ ExifKey::ExifKey(uint16_t tag, const std::string& ifdItem)
+ : p_(new Impl)
+ {
+ IfdId ifdId = ExifTags::ifdIdByIfdItem(ifdItem);
+ if (!ExifTags::isExifIfd(ifdId) && !ExifTags::isMakerIfd(ifdId)) {
+ throw Error(23, ifdId);
+ }
+ p_->makeKey(tag, ifdId, ifdItem);
}
ExifKey::ExifKey(const ExifKey& rhs)
- : Key(rhs), tag_(rhs.tag_), ifdId_(rhs.ifdId_), ifdItem_(rhs.ifdItem_),
- idx_(rhs.idx_), key_(rhs.key_)
+ : Key(rhs), p_(new Impl(*rhs.p_))
{
}
ExifKey::~ExifKey()
{
+ delete p_;
}
ExifKey& ExifKey::operator=(const ExifKey& rhs)
{
if (this == &rhs) return *this;
Key::operator=(rhs);
- tag_ = rhs.tag_;
- ifdId_ = rhs.ifdId_;
- ifdItem_ = rhs.ifdItem_;
- idx_ = rhs.idx_;
- key_ = rhs.key_;
+ *p_ = *rhs.p_;
return *this;
}
void ExifKey::setIdx(int idx)
{
- idx_ = idx;
+ p_->idx_ = idx;
}
std::string ExifKey::key() const
{
- return key_;
+ return p_->key_;
}
const char* ExifKey::familyName() const
{
- return familyName_;
+ return p_->familyName_;
}
std::string ExifKey::groupName() const
{
- return ifdItem();
+ return p_->ifdItem_;
}
std::string ExifKey::tagName() const
{
- return ExifTags::tagName(tag_, ifdId_);
+ return ExifTags::tagName(p_->tag_, p_->ifdId_);
}
std::string ExifKey::tagLabel() const
- {
- return ExifTags::tagLabel(tag_, ifdId_);
+ {
+ return ExifTags::tagLabel(p_->tag_, p_->ifdId_);
}
uint16_t ExifKey::tag() const
{
- return tag_;
+ return p_->tag_;
}
ExifKey::AutoPtr ExifKey::clone() const
@@ -2811,51 +2885,24 @@ namespace Exiv2 {
return new ExifKey(*this);
}
- std::string ExifKey::sectionName() const
+ IfdId ExifKey::ifdId() const
{
- return ExifTags::sectionName(tag(), ifdId());
+ return p_->ifdId_;
}
- void ExifKey::decomposeKey()
+ const char* ExifKey::ifdName() const
{
- // 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(6, key_);
- std::string familyName = key_.substr(0, pos1);
- if (0 != strcmp(familyName.c_str(), familyName_)) {
- throw Error(6, key_);
- }
- std::string::size_type pos0 = pos1 + 1;
- pos1 = key_.find('.', pos0);
- if (pos1 == std::string::npos) throw Error(6, key_);
- std::string ifdItem = key_.substr(pos0, pos1 - pos0);
- if (ifdItem == "") throw Error(6, key_);
- std::string tagName = key_.substr(pos1 + 1);
- if (tagName == "") throw Error(6, key_);
-
- // Find IfdId
- IfdId ifdId = ExifTags::ifdIdByIfdItem(ifdItem);
- if (ifdId == ifdIdNotSet) throw Error(6, key_);
- if (!ExifTags::isExifIfd(ifdId) && !ExifTags::isMakerIfd(ifdId)) {
- throw Error(6, key_);
- }
- // Convert tag
- uint16_t tag = ExifTags::tag(tagName, ifdId);
-
- // Translate hex tag name (0xabcd) to a real tag name if there is one
- tagName = ExifTags::tagName(tag, ifdId);
+ return ExifTags::ifdName(p_->ifdId_);
+ }
- tag_ = tag;
- ifdId_ = ifdId;
- ifdItem_ = ifdItem;
- key_ = familyName + "." + ifdItem + "." + tagName;
+ std::string ExifKey::sectionName() const
+ {
+ return ExifTags::sectionName(p_->tag_, p_->ifdId_);
}
- void ExifKey::makeKey()
+ int ExifKey::idx() const
{
- key_ = std::string(familyName_)
- + "." + ifdItem_
- + "." + ExifTags::tagName(tag_, ifdId_);
+ return p_->idx_;
}
// *************************************************************************
diff --git a/src/tags.hpp b/src/tags.hpp
index 3f44a65..fab5bff 100644
--- a/src/tags.hpp
+++ b/src/tags.hpp
@@ -310,47 +310,24 @@ namespace Exiv2 {
AutoPtr clone() const;
//! Return the IFD id
- IfdId ifdId() const { return ifdId_; }
+ IfdId ifdId() const;
//! Return the name of the IFD
- const char* ifdName() const { return ExifTags::ifdName(ifdId()); }
- //! Return the related image item
- std::string ifdItem() const { return ifdItem_; }
+ const char* ifdName() const;
//! Return the name of the Exif section (deprecated)
std::string sectionName() const;
//! Return the index (unique id of this key within the original Exif data, 0 if not set)
- int idx() const { return idx_; }
- //@}
-
- protected:
- //! @name Manipulators
- //@{
- /*!
- @brief Set the key corresponding to the tag and IFD id.
- The key is of the form '<b>Exif</b>.ifdItem.tagName'.
- */
- void makeKey();
- /*!
- @brief Parse and convert the key string into tag and IFD Id.
- Updates data members if the string can be decomposed,
- or throws \em Error .
-
- @throw Error if the key cannot be decomposed.
- */
- void decomposeKey();
+ int idx() const;
//@}
private:
//! Internal virtual copy constructor.
EXV_DLLLOCAL virtual ExifKey* clone_() const;
- // DATA
- static const char* familyName_;
+ private:
+ // Pimpl idiom
+ struct Impl;
+ Impl* p_;
- uint16_t tag_; //!< Tag value
- IfdId ifdId_; //!< The IFD associated with this tag
- std::string ifdItem_; //!< The IFD item
- int idx_; //!< Unique id of the Exif key in the image
- std::string key_; //!< Key
}; // class ExifKey
// *****************************************************************************
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 94c71b4..67db77e 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -64,7 +64,7 @@ namespace {
//! Returns true if group and index match.
bool operator()(const Exiv2::Exifdatum& md) const
{
- return idx_ == md.idx() && 0 == strcmp(md.ifdItem().c_str(), groupName_);
+ return idx_ == md.idx() && 0 == strcmp(md.groupName().c_str(), groupName_);
}
private:
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list