From d49caba41eae0d29448f14ebd4f62a7ea570a9e7 Mon Sep 17 00:00:00 2001 From: HumanDynamo Date: Fri, 24 Sep 2010 08:46:58 +0000 Subject: [PATCH] new ExifKey constructor based on TagInfo container. Factoring duplicate code with other ExifKey constructor --- src/tags.cpp | 15 +++++++++++++-- src/tags.hpp | 9 +++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tags.cpp b/src/tags.cpp index 6331c20a..8c0bf26c 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -2801,8 +2801,7 @@ namespace Exiv2 { key_ = std::string(familyName_) + "." + groupName_ + "." + tagName(); } - ExifKey::ExifKey(uint16_t tag, const std::string& groupName) - : p_(new Impl) + void ExifKey::create_internal(uint16_t tag, const std::string& groupName) { IfdId ifdId = groupId(groupName); // Todo: Test if this condition can be removed @@ -2817,6 +2816,18 @@ namespace Exiv2 { p_->makeKey(tag, ifdId, ti); } + ExifKey::ExifKey(uint16_t tag, const std::string& groupName) + : p_(new Impl) + { + create_internal(tag, groupName); + } + + ExifKey::ExifKey(const TagInfo& ti) + : p_(new Impl) + { + create_internal(ti.tag_, Internal::groupName(static_cast(ti.ifdId_))); + } + ExifKey::ExifKey(const std::string& key) : p_(new Impl) { diff --git a/src/tags.hpp b/src/tags.hpp index 3c2610ad..f39937d0 100644 --- a/src/tags.hpp +++ b/src/tags.hpp @@ -173,6 +173,13 @@ namespace Exiv2 { and group name. */ ExifKey(uint16_t tag, const std::string& groupName); + /*! + @brief Constructor to create an Exif key from a TagInfo instance. + @param ti The TagInfo instance + @throw Error if the key cannot be constructed from the tag number + and group name. + */ + ExifKey(const TagInfo& ti); //! Copy constructor ExifKey(const ExifKey& rhs); //! Destructor @@ -212,6 +219,8 @@ namespace Exiv2 { private: //! Internal virtual copy constructor. EXV_DLLLOCAL virtual ExifKey* clone_() const; + //! Internal construction method. + void create_internal(uint16_t tag, const std::string& groupName); private: // Pimpl idiom