From 0aed79ff573e1a6911564f5b495d074f41b0b818 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 20 Mar 2023 20:31:02 -0700 Subject: [PATCH] remove several constructors Just direct initialize Signed-off-by: Rosen Penev --- src/crwimage_int.cpp | 51 +++++++++++++++++++++------------------ src/crwimage_int.hpp | 22 ++--------------- src/tiffcomposite_int.cpp | 13 ++++++++++ src/tiffcomposite_int.hpp | 13 +++------- src/tiffimage_int.cpp | 6 ++--- src/tiffimage_int.hpp | 6 ----- src/tiffvisitor_int.cpp | 10 ++++++-- src/tiffvisitor_int.hpp | 6 ++--- 8 files changed, 59 insertions(+), 68 deletions(-) diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 7006deea..22c2eebe 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -81,31 +81,31 @@ namespace Exiv2::Internal { const CrwMapping CrwMap::crwMapping_[] = { // CrwTag CrwDir Size ExifTag IfdId decodeFct encodeFct // ------ ------ ---- ------- ----- --------- --------- - CrwMapping(0x0805, 0x300a, 0, 0, IfdId::canonId, decode0x0805, encode0x0805), - CrwMapping(0x080a, 0x2807, 0, 0, IfdId::canonId, decode0x080a, encode0x080a), - CrwMapping(0x080b, 0x3004, 0, 0x0007, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x0810, 0x2807, 0, 0x0009, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x0815, 0x2804, 0, 0x0006, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x1029, 0x300b, 0, 0x0002, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x102a, 0x300b, 0, 0x0004, IfdId::canonId, decodeArray, encodeArray), - CrwMapping(0x102d, 0x300b, 0, 0x0001, IfdId::canonId, decodeArray, encodeArray), - CrwMapping(0x1033, 0x300b, 0, 0x000f, IfdId::canonId, decodeArray, encodeArray), - CrwMapping(0x1038, 0x300b, 0, 0x0012, IfdId::canonId, decodeArray, encodeArray), - CrwMapping(0x10a9, 0x300b, 0, 0x00a9, IfdId::canonId, decodeBasic, encodeBasic), + {0x0805, 0x300a, 0, 0, IfdId::canonId, decode0x0805, encode0x0805}, + {0x080a, 0x2807, 0, 0, IfdId::canonId, decode0x080a, encode0x080a}, + {0x080b, 0x3004, 0, 0x0007, IfdId::canonId, decodeBasic, encodeBasic}, + {0x0810, 0x2807, 0, 0x0009, IfdId::canonId, decodeBasic, encodeBasic}, + {0x0815, 0x2804, 0, 0x0006, IfdId::canonId, decodeBasic, encodeBasic}, + {0x1029, 0x300b, 0, 0x0002, IfdId::canonId, decodeBasic, encodeBasic}, + {0x102a, 0x300b, 0, 0x0004, IfdId::canonId, decodeArray, encodeArray}, + {0x102d, 0x300b, 0, 0x0001, IfdId::canonId, decodeArray, encodeArray}, + {0x1033, 0x300b, 0, 0x000f, IfdId::canonId, decodeArray, encodeArray}, + {0x1038, 0x300b, 0, 0x0012, IfdId::canonId, decodeArray, encodeArray}, + {0x10a9, 0x300b, 0, 0x00a9, IfdId::canonId, decodeBasic, encodeBasic}, // Mapped to Exif.Photo.ColorSpace instead (see below) - // CrwMapping(0x10b4, 0x300b, 0, 0x00b4, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x10b4, 0x300b, 0, 0xa001, IfdId::exifId, decodeBasic, encodeBasic), - CrwMapping(0x10b5, 0x300b, 0, 0x00b5, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x10c0, 0x300b, 0, 0x00c0, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x10c1, 0x300b, 0, 0x00c1, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x1807, 0x3002, 0, 0x9206, IfdId::exifId, decodeBasic, encodeBasic), - CrwMapping(0x180b, 0x3004, 0, 0x000c, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x180e, 0x300a, 0, 0x9003, IfdId::exifId, decode0x180e, encode0x180e), - CrwMapping(0x1810, 0x300a, 0, 0xa002, IfdId::exifId, decode0x1810, encode0x1810), - CrwMapping(0x1817, 0x300a, 4, 0x0008, IfdId::canonId, decodeBasic, encodeBasic), - // CrwMapping(0x1818, 0x3002, 0, 0x9204, IfdId::exifId, decodeBasic, encodeBasic), - CrwMapping(0x183b, 0x300b, 0, 0x0015, IfdId::canonId, decodeBasic, encodeBasic), - CrwMapping(0x2008, 0x0000, 0, 0, IfdId::ifd1Id, decode0x2008, encode0x2008), + // {0x10b4, 0x300b, 0, 0x00b4, IfdId::canonId, decodeBasic, encodeBasic}, + {0x10b4, 0x300b, 0, 0xa001, IfdId::exifId, decodeBasic, encodeBasic}, + {0x10b5, 0x300b, 0, 0x00b5, IfdId::canonId, decodeBasic, encodeBasic}, + {0x10c0, 0x300b, 0, 0x00c0, IfdId::canonId, decodeBasic, encodeBasic}, + {0x10c1, 0x300b, 0, 0x00c1, IfdId::canonId, decodeBasic, encodeBasic}, + {0x1807, 0x3002, 0, 0x9206, IfdId::exifId, decodeBasic, encodeBasic}, + {0x180b, 0x3004, 0, 0x000c, IfdId::canonId, decodeBasic, encodeBasic}, + {0x180e, 0x300a, 0, 0x9003, IfdId::exifId, decode0x180e, encode0x180e}, + {0x1810, 0x300a, 0, 0xa002, IfdId::exifId, decode0x1810, encode0x1810}, + {0x1817, 0x300a, 4, 0x0008, IfdId::canonId, decodeBasic, encodeBasic}, + // {0x1818, 0x3002, 0, 0x9204, IfdId::exifId, decodeBasic, encodeBasic}, + {0x183b, 0x300b, 0, 0x0015, IfdId::canonId, decodeBasic, encodeBasic}, + {0x2008, 0x0000, 0, 0, IfdId::ifd1Id, decode0x2008, encode0x2008}, }; // CrwMap::crwMapping_[] /* @@ -130,6 +130,9 @@ const CrwSubDir CrwMap::crwSubDir_[] = { {0x2807, 0x300a}, {0x2804, 0x300a}, {0x300a, 0x0000}, {0x0000, 0xffff}, }; +CiffComponent::CiffComponent(uint16_t tag, uint16_t dir) : dir_(dir), tag_(tag) { +} + CiffDirectory::~CiffDirectory() { for (auto&& component : components_) { delete component; diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index 6f55be6d..6629d15b 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -61,8 +61,7 @@ class CiffComponent { //! Default constructor CiffComponent() = default; //! Constructor taking a tag and directory - CiffComponent(uint16_t tag, uint16_t dir) : dir_(dir), tag_(tag) { - } + CiffComponent(uint16_t tag, uint16_t dir); CiffComponent(const CiffComponent&) = delete; CiffComponent& operator=(const CiffComponent&) = delete; //! Virtual destructor. @@ -482,22 +481,6 @@ class CiffHeader { image metadata and vice versa. */ struct CrwMapping { - //! @name Creators - //@{ - //! Default constructor - CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, IfdId ifdId, CrwDecodeFct toExif, - CrwEncodeFct fromExif) : - crwTagId_(crwTagId), - crwDir_(crwDir), - size_(size), - tag_(tag), - ifdId_(ifdId), - toExif_(toExif), - fromExif_(fromExif) { - } - //@} - - // DATA uint16_t crwTagId_; //!< CRW tag id uint16_t crwDir_; //!< CRW directory tag uint32_t size_; //!< Data size (overwrites the size from the entry) @@ -505,8 +488,7 @@ struct CrwMapping { IfdId ifdId_; //!< Exif Ifd id to map to CrwDecodeFct toExif_; //!< Conversion function CrwEncodeFct fromExif_; //!< Reverse conversion function - -}; // struct CrwMapping +}; /*! @brief Static class providing mapping functionality from CRW entries diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index af15e720..c3e66aa0 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -62,10 +62,20 @@ void IoWrapper::setTarget(int id, size_t target) { TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) { } +TiffDirectory::TiffDirectory(uint16_t tag, IfdId group, bool hasNext) : TiffComponent(tag, group), hasNext_(hasNext) { +} + TiffEntryBase::TiffEntryBase(uint16_t tag, IfdId group, TiffType tiffType) : TiffComponent(tag, group), tiffType_(tiffType) { } +TiffSizeEntry::TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) : + TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) { +} + +TiffEntry::TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) { +} + TiffSubIfd::TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup) : TiffEntryBase(tag, group, ttUnsignedLong), newGroup_(newGroup) { } @@ -92,6 +102,9 @@ TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arra // We'll figure out the correct cfg later } +TiffPathItem::TiffPathItem(uint32_t extendedTag, IfdId group) : extendedTag_(extendedTag), group_(group) { +} + TiffDirectory::~TiffDirectory() { for (auto&& component : components_) { delete component; diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 54ddc68f..cc889be2 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -64,8 +64,7 @@ class TiffPathItem { //! @name Creators //@{ //! Constructor - constexpr TiffPathItem(uint32_t extendedTag, IfdId group) : extendedTag_(extendedTag), group_(group) { - } + TiffPathItem(uint32_t extendedTag, IfdId group); //@} //! @name Accessors @@ -567,8 +566,7 @@ class TiffEntry : public TiffEntryBase { //! @name Creators //@{ //! Constructor - TiffEntry(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) { - } + TiffEntry(uint16_t tag, IfdId group); //@} protected: @@ -781,9 +779,7 @@ class TiffSizeEntry : public TiffEntryBase { //! @name Creators //@{ //! Constructor - TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup) : - TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) { - } + TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup); //@} //! @name Accessors @@ -829,8 +825,7 @@ class TiffDirectory : public TiffComponent { //! @name Creators //@{ //! Default constructor - TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true) : TiffComponent(tag, group), hasNext_(hasNext) { - } + TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true); //! Virtual destructor ~TiffDirectory() override; //@} diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index 22086760..b01c2c4c 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -2099,8 +2099,8 @@ TiffComponent::UniquePtr TiffParserWorker::parse(const byte* pData, size_t size, auto rootDir = TiffCreator::create(root, IfdId::ifdIdNotSet); if (rootDir) { rootDir->setStart(pData + pHeader->offset()); - TiffRwState state(pHeader->byteOrder(), 0); - TiffReader reader(pData, size, rootDir.get(), state); + auto state = TiffRwState{pHeader->byteOrder(), 0}; + auto reader = TiffReader{pData, size, rootDir.get(), state}; rootDir->accept(reader); reader.postProcess(); } @@ -2345,7 +2345,7 @@ bool TiffHeader::isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPri } // TiffHeader::isImageTag void OffsetWriter::setOrigin(OffsetId id, uint32_t origin, ByteOrder byteOrder) { - offsetList_[id] = OffsetData(origin, byteOrder); + offsetList_[id] = OffsetData{origin, 0, byteOrder}; } void OffsetWriter::setTarget(OffsetId id, uint32_t target) { diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index 84085aab..90111d30 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -327,12 +327,6 @@ class OffsetWriter { private: //! Data structure for the offset list. struct OffsetData { - //! Default constructor - OffsetData() = default; - //! Constructor - OffsetData(uint32_t origin, ByteOrder byteOrder) : origin_(origin), byteOrder_(byteOrder) { - } - // DATA uint32_t origin_{}; //!< Origin address uint32_t target_{}; //!< Target address ByteOrder byteOrder_{littleEndian}; //!< Byte order to use to encode target address diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 8d83e66b..b8aac960 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -71,6 +71,9 @@ void TiffVisitor::visitIfdMakernoteEnd(TiffIfdMakernote* /*object*/) { void TiffVisitor::visitBinaryArrayEnd(TiffBinaryArray* /*object*/) { } +TiffFinder::TiffFinder(uint16_t tag, IfdId group) : tag_(tag), group_(group) { +} + void TiffFinder::init(uint16_t tag, IfdId group) { tag_ = tag; group_ = group; @@ -981,6 +984,9 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32 } // TiffEncoder::add +TiffRwState::TiffRwState(ByteOrder byteOrder, size_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) { +} + TiffReader::TiffReader(const byte* pData, size_t size, TiffComponent* pRoot, TiffRwState state) : pData_(pData), size_(size), pLast_(pData + size), pRoot_(pRoot), origState_(state), mnState_(state) { pState_ = &origState_; @@ -995,7 +1001,7 @@ void TiffReader::setMnState(const TiffRwState* state) { if (state) { // invalidByteOrder indicates 'no change' if (state->byteOrder() == invalidByteOrder) { - mnState_ = TiffRwState(origState_.byteOrder(), state->baseOffset()); + mnState_ = TiffRwState{origState_.byteOrder(), state->baseOffset()}; } else { mnState_ = *state; } @@ -1221,7 +1227,7 @@ void TiffReader::visitIfdMakernote(TiffIfdMakernote* object) { // Modify reader for Makernote peculiarities, byte order and offset object->mnOffset_ = object->start() - pData_; - TiffRwState state(object->byteOrder(), object->baseOffset()); + auto state = TiffRwState{object->byteOrder(), object->baseOffset()}; setMnState(&state); } // TiffReader::visitIfdMakernote diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp index ffc1e167..48138be6 100644 --- a/src/tiffvisitor_int.hpp +++ b/src/tiffvisitor_int.hpp @@ -130,8 +130,7 @@ class TiffFinder : public TiffVisitor { //! @name Creators //@{ //! Constructor, taking \em tag and \em group of the component to find. - TiffFinder(uint16_t tag, IfdId group) : tag_(tag), group_(group) { - } + TiffFinder(uint16_t tag, IfdId group); TiffFinder(const TiffFinder&) = delete; TiffFinder& operator=(const TiffFinder&) = delete; //! Virtual destructor @@ -538,8 +537,7 @@ class TiffRwState { //! @name Creators //@{ //! Constructor. - TiffRwState(ByteOrder byteOrder, size_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) { - } + TiffRwState(ByteOrder byteOrder, size_t baseOffset); //@} //! @name Accessors