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

get rid of EXV_CALL_MEMBER_FN #2555

Merged
merged 1 commit into from
Mar 25, 2023
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
11 changes: 0 additions & 11 deletions include/exiv2/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
#include <sstream>
#include <vector>

/*!
@brief Macro to make calls to member functions through a pointer more readable.
See the C++ FAQ LITE, item
<a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.5" title="[33.5] How can I avoid
syntax errors when calling a member function using a pointer-to-member-function?">[33.5] How can I avoid syntax errors
when calling a member function using a pointer-to-member-function?</a>.
*/
#define EXV_CALL_MEMBER_FN(object, ptrToMember) ((object).*(ptrToMember))

// *****************************************************************************

// *****************************************************************************
// namespace extensions
namespace Exiv2 {
Expand Down
5 changes: 3 additions & 2 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

// + standard includes
#include <algorithm>
#include <functional>
#include <iomanip>

#if defined _WIN32
Expand Down Expand Up @@ -499,15 +500,15 @@ Converter::Converter(IptcData& iptcData, XmpData& xmpData, const char* iptcChars
void Converter::cnvToXmp() {
for (auto&& c : conversion_) {
if ((c.metadataId_ == mdExif && exifData_) || (c.metadataId_ == mdIptc && iptcData_)) {
EXV_CALL_MEMBER_FN(*this, c.key1ToKey2_)(c.key1_, c.key2_);
std::invoke(c.key1ToKey2_, *this, c.key1_, c.key2_);
}
}
}

void Converter::cnvFromXmp() {
for (auto&& c : conversion_) {
if ((c.metadataId_ == mdExif && exifData_) || (c.metadataId_ == mdIptc && iptcData_)) {
EXV_CALL_MEMBER_FN(*this, c.key2ToKey1_)(c.key2_, c.key1_);
std::invoke(c.key2ToKey1_, *this, c.key2_, c.key1_);
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/tiffvisitor_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "tiffvisitor_int.hpp" // see bug #487
#include "value.hpp"

#include <functional>
#include <iostream>

// *****************************************************************************
Expand Down Expand Up @@ -421,11 +422,9 @@ void TiffDecoder::decodeTiffEntry(const TiffEntryBase* object) {
if (!object->pValue())
return;

const DecoderFct decoderFct = findDecoderFct_(make_, object->tag(), object->group());
// skip decoding if decoderFct == 0
if (decoderFct) {
EXV_CALL_MEMBER_FN(*this, decoderFct)(object);
}
if (auto decoderFct = findDecoderFct_(make_, object->tag(), object->group()))
std::invoke(decoderFct, *this, object);
} // TiffDecoder::decodeTiffEntry

void TiffDecoder::decodeStdTiffEntry(const TiffEntryBase* object) {
Expand Down Expand Up @@ -737,10 +736,9 @@ void TiffEncoder::encodeTiffComponent(TiffEntryBase* object, const Exifdatum* da
// Skip encoding image tags of existing TIFF image - they were copied earlier -
// but encode image tags of new images (creation)
if (ed && !isImageTag(object->tag(), object->group())) {
const EncoderFct fct = findEncoderFct_(make_, object->tag(), object->group());
if (fct) {
if (auto fct = findEncoderFct_(make_, object->tag(), object->group())) {
// If an encoding function is registered for the tag, use it
EXV_CALL_MEMBER_FN(*this, fct)(object, ed);
std::invoke(fct, *this, object, ed);
} else {
// Else use the encode function at the object (results in a double-dispatch
// to the appropriate encoding function of the encoder.
Expand Down