Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace structs with std::pair #2300

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/tiffimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ EncoderFct TiffMapping::findEncoder(const std::string& make, uint32_t extendedTa
}

bool TiffTreeStruct::operator==(const TiffTreeStruct::Key& key) const {
return key.r_ == root_ && key.g_ == group_;
return key.first == root_ && key.second == group_;
}

TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group) {
Expand Down Expand Up @@ -2036,7 +2036,7 @@ bool TiffHeaderBase::isImageTag(uint16_t /*tag*/, IfdId /*group*/, const Primary

bool isTiffImageTag(uint16_t tag, IfdId group) {
//! List of TIFF image tags
static const TiffImgTagStruct tiffImageTags[] = {
static constexpr TiffImgTagStruct tiffImageTags[] = {
{0x00fe, IfdId::ifd0Id}, // Exif.Image.NewSubfileType
{0x00ff, IfdId::ifd0Id}, // Exif.Image.SubfileType
{0x0100, IfdId::ifd0Id}, // Exif.Image.ImageWidth
Expand Down Expand Up @@ -2107,15 +2107,15 @@ bool isTiffImageTag(uint16_t tag, IfdId group) {

// If tag, group is one of the image tags listed above -> bingo!
#ifdef EXIV2_DEBUG_MESSAGES
if (find(tiffImageTags, TiffImgTagStruct::Key(tag, group))) {
if (find(tiffImageTags, TiffImgTagStruct(tag, group))) {
ExifKey key(tag, groupName(group));
std::cerr << "Image tag: " << key << " (3)\n";
return true;
}
std::cerr << "Not an image tag: " << tag << " (4)\n";
return false;
#endif
return find(tiffImageTags, TiffImgTagStruct::Key(tag, group));
return find(tiffImageTags, TiffImgTagStruct(tag, group));
}

TiffHeader::TiffHeader(ByteOrder byteOrder, uint32_t offset, bool hasImageTags) :
Expand Down
25 changes: 2 additions & 23 deletions src/tiffimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,7 @@ class TiffHeader : public TiffHeaderBase {
/*!
@brief Data structure used to list image tags for TIFF and TIFF-like images.
*/
struct TiffImgTagStruct {
//! Search key for TIFF image tag structure.
using Key = std::pair<uint16_t, IfdId>;
//! Comparison operator to compare a TiffImgTagStruct with a TiffImgTagStruct::Key
bool operator==(const Key& key) const {
auto [t, g] = key;
return g == group_ && t == tag_;
}

// DATA
uint16_t tag_; //!< Image tag
IfdId group_; //!< Group that contains the image tag
}; // struct TiffImgTagStruct
using TiffImgTagStruct = std::pair<uint16_t, IfdId>;

/*!
@brief Data structure used as a row (element) of a table (array)
Expand Down Expand Up @@ -176,7 +164,7 @@ struct TiffGroupStruct {
use standard TIFF layout.
*/
struct TiffTreeStruct {
struct Key;
using Key = std::pair<uint32_t, IfdId>;
//! Comparison operator to compare a TiffTreeStruct with a TiffTreeStruct::Key
bool operator==(const Key& key) const;

Expand All @@ -187,15 +175,6 @@ struct TiffTreeStruct {
uint32_t parentExtTag_; //!< Parent tag (32 bit so that it can contain special tags)
};

//! Search key for TIFF tree structure.
struct TiffTreeStruct::Key {
//! Constructor
Key(uint32_t r, IfdId g) : r_(r), g_(g) {
}
uint32_t r_; //!< Root
IfdId g_; //!< %Group
};

/*!
@brief TIFF component factory.
*/
Expand Down