From 3f7cb78a3b04bea8e41cf7eb23c77b7517f49886 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Fri, 8 Jul 2022 12:03:53 +0100 Subject: [PATCH] Move enums from tags_int.hpp to tags.hpp --- include/exiv2/tags.hpp | 194 +++++++++++++++++++++++++++++++++++++--- src/cr2image.cpp | 2 +- src/crwimage_int.hpp | 2 +- src/exif.cpp | 4 +- src/makernote_int.cpp | 15 ++-- src/preview.cpp | 2 +- src/tags.cpp | 4 +- src/tags_int.hpp | 174 ----------------------------------- src/tiffimage_int.hpp | 4 +- src/tiffvisitor_int.cpp | 2 +- 10 files changed, 201 insertions(+), 202 deletions(-) diff --git a/include/exiv2/tags.hpp b/include/exiv2/tags.hpp index d043cca4..ee092375 100644 --- a/include/exiv2/tags.hpp +++ b/include/exiv2/tags.hpp @@ -47,18 +47,192 @@ struct EXIV2API GroupInfo::GroupName { std::string g_; //!< Group name }; +//! Type to specify the IFD to which a metadata belongs +enum IfdId { + ifdIdNotSet, + ifd0Id, + ifd1Id, + ifd2Id, + ifd3Id, + exifId, + gpsId, + iopId, + mpfId, + subImage1Id, + subImage2Id, + subImage3Id, + subImage4Id, + subImage5Id, + subImage6Id, + subImage7Id, + subImage8Id, + subImage9Id, + subThumb1Id, + panaRawId, + mnId, + canonId, + canonAfCId, + canonAfMiAdjId, + canonAmId, + canonAsId, + canonCbId, + canonCiId, + canonCsId, + canonFilId, + canonFlId, + canonHdrId, + canonLeId, + canonMeId, + canonMoID, + canonMvId, + canonRawBId, + canonSiId, + canonCfId, + canonContrastId, + canonFcd1Id, + canonFcd2Id, + canonFcd3Id, + canonLiOpId, + canonMyColorID, + canonPiId, + canonPaId, + canonTiId, + canonFiId, + canonPrId, + canonPreID, + canonVigCorId, + canonVigCor2Id, + canonWbId, + casioId, + casio2Id, + fujiId, + minoltaId, + minoltaCs5DId, + minoltaCs7DId, + minoltaCsOldId, + minoltaCsNewId, + nikon1Id, + nikon2Id, + nikon3Id, + nikonPvId, + nikonVrId, + nikonPcId, + nikonWtId, + nikonIiId, + nikonAfId, + nikonAf21Id, + nikonAf22Id, + nikonAFTId, + nikonFiId, + nikonMeId, + nikonFl1Id, + nikonFl2Id, + nikonFl3Id, + nikonFl7Id, + nikonSi1Id, + nikonSi2Id, + nikonSi3Id, + nikonSi4Id, + nikonSi5Id, + nikonSi6Id, + nikonLd1Id, + nikonLd2Id, + nikonLd3Id, + nikonLd4Id, + nikonCb1Id, + nikonCb2Id, + nikonCb2aId, + nikonCb2bId, + nikonCb3Id, + nikonCb4Id, + olympusId, + olympus2Id, + olympusCsId, + olympusEqId, + olympusRdId, + olympusRd2Id, + olympusIpId, + olympusFiId, + olympusFe1Id, + olympusFe2Id, + olympusFe3Id, + olympusFe4Id, + olympusFe5Id, + olympusFe6Id, + olympusFe7Id, + olympusFe8Id, + olympusFe9Id, + olympusRiId, + panasonicId, + pentaxId, + pentaxDngId, + samsung2Id, + samsungPvId, + samsungPwId, + sigmaId, + sony1Id, + sony2Id, + sonyMltId, + sony1CsId, + sony1Cs2Id, + sony2CsId, + sony2Cs2Id, + sony2FpId, + sonyMisc1Id, + sonyMisc2bId, + sonyMisc3cId, + sonySInfo1Id, + sony2010eId, + sony1MltCs7DId, + sony1MltCsOldId, + sony1MltCsNewId, + sony1MltCsA100Id, + tagInfoMvId, + lastId, + ignoreId = lastId +}; + +/*! + @brief Section identifiers to logically group tags. A section consists + of nothing more than a name, based on the Exif standard. + */ +enum SectionId { + sectionIdNotSet, + imgStruct, // 4.6.4 A + recOffset, // 4.6.4 B + imgCharacter, // 4.6.4 C + otherTags, // 4.6.4 D + exifFormat, // 4.6.3 + exifVersion, // 4.6.5 A + imgConfig, // 4.6.5 C + userInfo, // 4.6.5 D + relatedFile, // 4.6.5 E + dateTime, // 4.6.5 F + captureCond, // 4.6.5 G + gpsTags, // 4.6.6 + iopTags, // 4.6.7 + mpfTags, + makerTags, // MakerNote + dngTags, // DNG Spec + panaRaw, + tiffEp, // TIFF-EP Spec + tiffPm6, + adobeOpi, + lastSectionId +}; + //! Tag information struct EXIV2API TagInfo { - uint16_t tag_; //!< Tag - const char* name_; //!< One word tag label - const char* title_; //!< Tag title - const char* desc_; //!< Short tag description - int ifdId_; //!< Link to the (preferred) IFD - int sectionId_; //!< Section id - TypeId typeId_; //!< Type id - int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known. - PrintFct printFct_; //!< Pointer to tag print function -}; // struct TagInfo + uint16_t tag_; //!< Tag + const char* name_; //!< One word tag label + const char* title_; //!< Tag title + const char* desc_; //!< Short tag description + IfdId ifdId_; //!< Link to the (preferred) IFD + SectionId sectionId_; //!< Section id + TypeId typeId_; //!< Type id + int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known. + PrintFct printFct_; //!< Pointer to tag print function +}; // struct TagInfo //! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class. class EXIV2API ExifTags { diff --git a/src/cr2image.cpp b/src/cr2image.cpp index 79814811..f77adebe 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -112,7 +112,7 @@ WriteMethod Cr2Parser::encode(BasicIo& io, const byte* pData, size_t size, ByteO // Delete IFDs which do not occur in TIFF images static constexpr auto filteredIfds = std::array{ - Internal::panaRawId, + panaRawId, }; for (auto&& filteredIfd : filteredIfds) { #ifdef EXIV2_DEBUG_MESSAGES diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index 2c2318e9..48b32641 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -496,7 +496,7 @@ struct CrwMapping { //! @name Creators //@{ //! Default constructor - CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, Internal::IfdId ifdId, + CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, IfdId ifdId, CrwDecodeFct toExif, CrwEncodeFct fromExif) : crwTagId_(crwTagId), crwDir_(crwDir), diff --git a/src/exif.cpp b/src/exif.cpp index 8ca9f517..2bd23026 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -128,7 +128,7 @@ class JpegThumbnail : public Thumbnail { int64_t sumToLong(const Exiv2::Exifdatum& md); //! Helper function to delete all tags of a specific IFD from the metadata. -void eraseIfd(Exiv2::ExifData& ed, Exiv2::Internal::IfdId ifdId); +void eraseIfd(Exiv2::ExifData& ed, Exiv2::IfdId ifdId); } // namespace @@ -301,7 +301,7 @@ int Exifdatum::ifdId() const { } const char* Exifdatum::ifdName() const { - return key_ ? Internal::ifdName(static_cast(key_->ifdId())) : ""; + return key_ ? Internal::ifdName(static_cast(key_->ifdId())) : ""; } int Exifdatum::idx() const { diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 033743d0..a47a7302 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -37,8 +37,7 @@ namespace fs = std::filesystem; namespace { // Todo: Can be generalized further - get any tag as a string/long/... //! Get the Value for a tag within a particular group -const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const uint16_t& tag, - const Exiv2::Internal::IfdId& group); +const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const uint16_t& tag, const Exiv2::IfdId& group); //! Get the model name from tag Exif.Image.Model std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot); @@ -969,9 +968,9 @@ int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, // > First byte must be 9 or 12 or 13 or 15 or 16 and 4th byte must be 2 (deciphered) // Get the value from the image format that is being used - auto value = getExifValue(pRoot, 0x9404, Exiv2::Internal::sony1Id); + auto value = getExifValue(pRoot, 0x9404, Exiv2::sony1Id); if (!value) { - value = getExifValue(pRoot, 0x9404, Exiv2::Internal::sony2Id); + value = getExifValue(pRoot, 0x9404, Exiv2::sony2Id); if (!value) return -1; } @@ -996,9 +995,9 @@ int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, // > first byte decoded: 62, 48, 215, 28, 106 respectively // Get the value from the image format that is being used - auto value = getExifValue(pRoot, 0x9400, Exiv2::Internal::sony1Id); + auto value = getExifValue(pRoot, 0x9400, Exiv2::sony1Id); if (!value) { - value = getExifValue(pRoot, 0x9400, Exiv2::Internal::sony2Id); + value = getExifValue(pRoot, 0x9400, Exiv2::sony2Id); if (!value) return -1; } @@ -1024,7 +1023,7 @@ int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, // local definitions namespace { const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const uint16_t& tag, - const Exiv2::Internal::IfdId& group) { + const Exiv2::IfdId& group) { Exiv2::Internal::TiffFinder finder(tag, group); if (!pRoot) return nullptr; @@ -1035,7 +1034,7 @@ const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const ui std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot) { // Lookup the Exif.Image.Model tag - const auto value = getExifValue(pRoot, 0x0110, Exiv2::Internal::ifd0Id); + const auto value = getExifValue(pRoot, 0x0110, Exiv2::ifd0Id); return (!value || value->count() == 0) ? std::string("") : static_cast(value->toString()); } diff --git a/src/preview.cpp b/src/preview.cpp index 2d578006..3383aa32 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -697,7 +697,7 @@ DataBuf LoaderTiff::getData() const { consistent result for all previews, including JPEG */ uint16_t tag = pos.tag(); - if (tag != 0x00fe && tag != 0x00ff && Internal::isTiffImageTag(tag, Internal::ifd0Id)) { + if (tag != 0x00fe && tag != 0x00ff && Internal::isTiffImageTag(tag, ifd0Id)) { preview.add(ExifKey(tag, "Image"), &pos.value()); } } diff --git a/src/tags.cpp b/src/tags.cpp index f084dd9d..65777283 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -75,7 +75,7 @@ bool GroupInfo::operator==(const GroupName& groupName) const { } const char* ExifTags::sectionName(const ExifKey& key) { - const TagInfo* ti = tagInfo(key.tag(), static_cast(key.ifdId())); + const TagInfo* ti = tagInfo(key.tag(), static_cast(key.ifdId())); if (!ti) return sectionInfo[unknownTag.sectionId_].name_; return sectionInfo[ti->sectionId_].name_; @@ -83,7 +83,7 @@ const char* ExifTags::sectionName(const ExifKey& key) { /// \todo not used internally. At least we should test it uint16_t ExifTags::defaultCount(const ExifKey& key) { - const TagInfo* ti = tagInfo(key.tag(), static_cast(key.ifdId())); + const TagInfo* ti = tagInfo(key.tag(), static_cast(key.ifdId())); if (!ti) return unknownTag.count_; return ti->count_; diff --git a/src/tags_int.hpp b/src/tags_int.hpp index f8f73845..c7b76554 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -14,180 +14,6 @@ namespace Exiv2::Internal { // ***************************************************************************** // class definitions -//! Type to specify the IFD to which a metadata belongs -enum IfdId { - ifdIdNotSet, - ifd0Id, - ifd1Id, - ifd2Id, - ifd3Id, - exifId, - gpsId, - iopId, - mpfId, - subImage1Id, - subImage2Id, - subImage3Id, - subImage4Id, - subImage5Id, - subImage6Id, - subImage7Id, - subImage8Id, - subImage9Id, - subThumb1Id, - panaRawId, - mnId, - canonId, - canonAfCId, - canonAfMiAdjId, - canonAmId, - canonAsId, - canonCbId, - canonCiId, - canonCsId, - canonFilId, - canonFlId, - canonHdrId, - canonLeId, - canonMeId, - canonMoID, - canonMvId, - canonRawBId, - canonSiId, - canonCfId, - canonContrastId, - canonFcd1Id, - canonFcd2Id, - canonFcd3Id, - canonLiOpId, - canonMyColorID, - canonPiId, - canonPaId, - canonTiId, - canonFiId, - canonPrId, - canonPreID, - canonVigCorId, - canonVigCor2Id, - canonWbId, - casioId, - casio2Id, - fujiId, - minoltaId, - minoltaCs5DId, - minoltaCs7DId, - minoltaCsOldId, - minoltaCsNewId, - nikon1Id, - nikon2Id, - nikon3Id, - nikonPvId, - nikonVrId, - nikonPcId, - nikonWtId, - nikonIiId, - nikonAfId, - nikonAf21Id, - nikonAf22Id, - nikonAFTId, - nikonFiId, - nikonMeId, - nikonFl1Id, - nikonFl2Id, - nikonFl3Id, - nikonFl7Id, - nikonSi1Id, - nikonSi2Id, - nikonSi3Id, - nikonSi4Id, - nikonSi5Id, - nikonSi6Id, - nikonLd1Id, - nikonLd2Id, - nikonLd3Id, - nikonLd4Id, - nikonCb1Id, - nikonCb2Id, - nikonCb2aId, - nikonCb2bId, - nikonCb3Id, - nikonCb4Id, - olympusId, - olympus2Id, - olympusCsId, - olympusEqId, - olympusRdId, - olympusRd2Id, - olympusIpId, - olympusFiId, - olympusFe1Id, - olympusFe2Id, - olympusFe3Id, - olympusFe4Id, - olympusFe5Id, - olympusFe6Id, - olympusFe7Id, - olympusFe8Id, - olympusFe9Id, - olympusRiId, - panasonicId, - pentaxId, - pentaxDngId, - samsung2Id, - samsungPvId, - samsungPwId, - sigmaId, - sony1Id, - sony2Id, - sonyMltId, - sony1CsId, - sony1Cs2Id, - sony2CsId, - sony2Cs2Id, - sony2FpId, - sonyMisc1Id, - sonyMisc2bId, - sonyMisc3cId, - sonySInfo1Id, - sony2010eId, - sony1MltCs7DId, - sony1MltCsOldId, - sony1MltCsNewId, - sony1MltCsA100Id, - tagInfoMvId, - lastId, - ignoreId = lastId -}; - -/*! - @brief Section identifiers to logically group tags. A section consists - of nothing more than a name, based on the Exif standard. - */ -enum SectionId { - sectionIdNotSet, - imgStruct, // 4.6.4 A - recOffset, // 4.6.4 B - imgCharacter, // 4.6.4 C - otherTags, // 4.6.4 D - exifFormat, // 4.6.3 - exifVersion, // 4.6.5 A - imgConfig, // 4.6.5 C - userInfo, // 4.6.5 D - relatedFile, // 4.6.5 E - dateTime, // 4.6.5 F - captureCond, // 4.6.5 G - gpsTags, // 4.6.6 - iopTags, // 4.6.7 - mpfTags, - makerTags, // MakerNote - dngTags, // DNG Spec - panaRaw, - tiffEp, // TIFF-EP Spec - tiffPm6, - adobeOpi, - lastSectionId -}; - //! The details of a section. struct SectionInfo { constexpr SectionInfo(SectionId sectionId, const char* name, const char* desc) : diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index a928ca9c..d134cf80 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -393,7 +393,7 @@ class OffsetWriter { class FindExifdatum { public: //! Constructor, initializes the object with the IfdId to look for. - explicit FindExifdatum(Exiv2::Internal::IfdId ifdId) : ifdId_(ifdId) { + explicit FindExifdatum(Exiv2::IfdId ifdId) : ifdId_(ifdId) { } //! Returns true if IFD id matches. bool operator()(const Exiv2::Exifdatum& md) const { @@ -401,7 +401,7 @@ class FindExifdatum { } private: - Exiv2::Internal::IfdId ifdId_; + Exiv2::IfdId ifdId_; }; // class FindExifdatum diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 61ea1d29..c62e822b 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -23,7 +23,7 @@ namespace { class FindExifdatum2 { public: //! Constructor, initializes the object with the group and index to look for. - FindExifdatum2(Exiv2::Internal::IfdId group, int idx) : groupName_(Exiv2::Internal::groupName(group)), idx_(idx) { + FindExifdatum2(Exiv2::IfdId group, int idx) : groupName_(Exiv2::Internal::groupName(group)), idx_(idx) { } //! Returns true if group and index match. bool operator()(const Exiv2::Exifdatum& md) const {