From daf7c890e2745670560afed8562e1297a1fb1e9a Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 18:47:52 -0800 Subject: [PATCH 1/2] misc stuff Signed-off-by: Rosen Penev --- src/basicio.cpp | 20 +++++------ src/canonmn_int.hpp | 12 +++---- src/casiomn_int.hpp | 9 +++-- src/cr2header_int.hpp | 9 +++-- src/crwimage_int.hpp | 14 +++----- src/fujimn_int.hpp | 10 +++--- src/image_int.hpp | 9 +++-- src/makernote_int.hpp | 30 ++++++++--------- src/minoltamn_int.hpp | 9 +++-- src/nikonmn_int.hpp | 9 +++-- src/olympusmn_int.hpp | 9 +++-- src/orfimage_int.hpp | 9 +++-- src/panasonicmn_int.hpp | 10 +++--- src/pentaxmn_int.hpp | 11 +++--- src/pngchunk_int.hpp | 15 +++------ src/rw2image_int.hpp | 9 +++-- src/samsungmn_int.hpp | 9 +++-- src/sigmamn_int.hpp | 9 +++-- src/sonymn_int.hpp | 9 +++-- src/tags.cpp | 5 +-- src/tiffcomposite_int.cpp | 49 ++++----------------------- src/tiffcomposite_int.hpp | 71 +++++++++++++++------------------------ src/tiffimage_int.hpp | 24 +++++-------- src/tiffvisitor_int.cpp | 11 ++---- src/tiffvisitor_int.hpp | 14 +++----- 25 files changed, 143 insertions(+), 252 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index bb1744d2..471163dd 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -126,7 +126,7 @@ namespace Exiv2 { int FileIo::Impl::switchMode(OpMode opMode) { - assert(fp_ != 0); + assert(fp_); if (opMode_ == opMode) return 0; OpMode oldOpMode = opMode_; opMode_ = opMode; @@ -231,7 +231,7 @@ namespace Exiv2 { byte* FileIo::mmap(bool isWriteable) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (munmap() != 0) { throw Error(kerCallFailed, path(), strError(), "munmap"); } @@ -304,7 +304,7 @@ namespace Exiv2 { size_t FileIo::write(const byte* data, size_t wcount) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (p_->switchMode(Impl::opWrite) != 0) return 0; return std::fwrite(data, 1, wcount, p_->fp_); @@ -312,7 +312,7 @@ namespace Exiv2 { size_t FileIo::write(BasicIo& src) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (static_cast(this) == &src) return 0; if (!src.isopen()) @@ -446,14 +446,14 @@ namespace Exiv2 { int FileIo::putb(byte data) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (p_->switchMode(Impl::opWrite) != 0) return EOF; return putc(data, p_->fp_); } int FileIo::seek( int64_t offset, Position pos ) { - assert(p_->fp_ != 0); + assert(p_->fp_); int fileSeek = 0; switch (pos) { @@ -472,7 +472,7 @@ namespace Exiv2 { long FileIo::tell() const { - assert(p_->fp_ != 0); + assert(p_->fp_); return std::ftell(p_->fp_); } @@ -531,7 +531,7 @@ namespace Exiv2 { DataBuf FileIo::read(size_t rcount) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (static_cast(rcount) > size()) throw Error(kerInvalidMalloc); DataBuf buf(rcount); @@ -545,7 +545,7 @@ namespace Exiv2 { size_t FileIo::read(byte* buf, size_t rcount) { - assert(p_->fp_ != 0); + assert(p_->fp_); if (p_->switchMode(Impl::opRead) != 0) { return 0; } @@ -554,7 +554,7 @@ namespace Exiv2 { int FileIo::getb() { - assert(p_->fp_ != 0); + assert(p_->fp_); if (p_->switchMode(Impl::opRead) != 0) return EOF; return getc(p_->fp_); } diff --git a/src/canonmn_int.hpp b/src/canonmn_int.hpp index 83b6fcae..ea6ba528 100644 --- a/src/canonmn_int.hpp +++ b/src/canonmn_int.hpp @@ -21,13 +21,9 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - class Value; - - namespace Internal { - -// ***************************************************************************** -// class definitions +namespace Exiv2::Internal { + // ***************************************************************************** + // class definitions //! MakerNote for Canon cameras class CanonMakerNote { @@ -205,7 +201,7 @@ namespace Exiv2 { */ float canonEv(int64_t val); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef CANONMN_INT_HPP_ diff --git a/src/casiomn_int.hpp b/src/casiomn_int.hpp index f80ad091..44ec65de 100644 --- a/src/casiomn_int.hpp +++ b/src/casiomn_int.hpp @@ -18,11 +18,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Casio cameras class CasioMakerNote { @@ -56,6 +55,6 @@ namespace Exiv2 { }; // class Casio2MakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef CasioMN_INT_HPP_ diff --git a/src/cr2header_int.hpp b/src/cr2header_int.hpp index db3a0ec7..e5e9d1e2 100644 --- a/src/cr2header_int.hpp +++ b/src/cr2header_int.hpp @@ -16,11 +16,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions /// @brief Canon CR2 header structure. class Cr2Header : public TiffHeaderBase { @@ -53,6 +52,6 @@ namespace Exiv2 { static constexpr auto cr2sig_ = "CR\2\0"; //!< Signature for CR2 type TIFF }; // class Cr2Header -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef CR2IMAGE_INT_HPP_ diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index 93465a08..914c3979 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -14,16 +14,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { +namespace Exiv2::Internal { -// ***************************************************************************** -// class declarations - class ExifData; - - namespace Internal { - -// ***************************************************************************** -// class declarations + // ***************************************************************************** + // class declarations class CiffHeader; class CiffComponent; struct CrwMapping; @@ -691,6 +685,6 @@ namespace Exiv2 { IfdId ifdId, ByteOrder byteOrder); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef CRWIMAGE_INT_HPP_ diff --git a/src/fujimn_int.hpp b/src/fujimn_int.hpp index 1ea8f869..513c3537 100644 --- a/src/fujimn_int.hpp +++ b/src/fujimn_int.hpp @@ -9,11 +9,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Fujifilm cameras class FujiMakerNote { @@ -24,9 +23,8 @@ namespace Exiv2 { private: //! Tag information static const TagInfo tagInfo_[]; - }; // class FujiMakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef FUJIMN_INT_HPP_ diff --git a/src/image_int.hpp b/src/image_int.hpp index 584dd2d2..783b7476 100644 --- a/src/image_int.hpp +++ b/src/image_int.hpp @@ -18,11 +18,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions /*! @brief format a string in the pattern of \em sprintf \em . @@ -106,6 +105,6 @@ namespace Exiv2 { /// @brief indent output for kpsRecursive in \em printStructure() \em . std::string indent(int32_t depth); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef IMAGE_INT_HPP_ diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp index 3ab6f5c0..934d7d23 100644 --- a/src/makernote_int.hpp +++ b/src/makernote_int.hpp @@ -11,23 +11,21 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { -// ***************************************************************************** -// function prototypes - /*! - @brief Determine the path to the Exiv2 configuration file - */ - std::string getExiv2ConfigPath(); - - /*! - @brief Read value from Exiv2 configuration file - */ - std::string readExiv2Config(const std::string& section,const std::string& value,const std::string& def); +namespace Exiv2::Internal { + // ***************************************************************************** + // function prototypes + /*! + @brief Determine the path to the Exiv2 configuration file + */ + std::string getExiv2ConfigPath(); + /*! + @brief Read value from Exiv2 configuration file + */ + std::string readExiv2Config(const std::string& section, const std::string& value, const std::string& def); -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! Type for a pointer to a function creating a makernote (image) using NewMnFct = TiffComponent* (*)(uint16_t tag, @@ -748,6 +746,6 @@ namespace Exiv2 { */ DataBuf nikonCrypt(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef MAKERNOTE_INT_HPP_ diff --git a/src/minoltamn_int.hpp b/src/minoltamn_int.hpp index 2cbcb3ab..d20dcc9b 100644 --- a/src/minoltamn_int.hpp +++ b/src/minoltamn_int.hpp @@ -13,11 +13,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Minolta cameras class MinoltaMakerNote { @@ -121,6 +120,6 @@ namespace Exiv2 { // TODO: Added shared methods here. -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef MINOLTAMN_INT_HPP_ diff --git a/src/nikonmn_int.hpp b/src/nikonmn_int.hpp index 46908fd8..d79f18f9 100644 --- a/src/nikonmn_int.hpp +++ b/src/nikonmn_int.hpp @@ -27,11 +27,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! A MakerNote format used by Nikon cameras, such as the E990 and D1. class Nikon1MakerNote { @@ -286,6 +285,6 @@ namespace Exiv2 { }; // class Nikon3MakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef NIKONMN_INT_HPP_ diff --git a/src/olympusmn_int.hpp b/src/olympusmn_int.hpp index 75c34f33..fd1e3e24 100644 --- a/src/olympusmn_int.hpp +++ b/src/olympusmn_int.hpp @@ -22,11 +22,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Olympus cameras class OlympusMakerNote { @@ -96,6 +95,6 @@ namespace Exiv2 { }; // class OlympusMakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef OLYMPUSMN_INT_HPP_ diff --git a/src/orfimage_int.hpp b/src/orfimage_int.hpp index 7bb74404..9051c47e 100644 --- a/src/orfimage_int.hpp +++ b/src/orfimage_int.hpp @@ -10,11 +10,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions /*! @brief Olympus ORF header structure. @@ -43,6 +42,6 @@ namespace Exiv2 { uint16_t sig_; // - } // namespace Internal -} // namespace Exiv2 - +} // namespace Exiv2::Internal #endif // #ifndef PENTAXMN_INT_HPP_ diff --git a/src/pngchunk_int.hpp b/src/pngchunk_int.hpp index 261259ee..b48acf00 100644 --- a/src/pngchunk_int.hpp +++ b/src/pngchunk_int.hpp @@ -10,16 +10,9 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - -// ***************************************************************************** -// class declarations - class Image; - - namespace Internal { - -// ***************************************************************************** -// class definitions +namespace Exiv2::Internal { + // ***************************************************************************** + // class definitions /*! @brief Stateless parser class for data in PNG chunk format. Images use this @@ -161,6 +154,6 @@ namespace Exiv2 { }; // class PngChunk -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef PNGCHUNK_INT_HPP_ diff --git a/src/rw2image_int.hpp b/src/rw2image_int.hpp index a45f3ecf..440fb043 100644 --- a/src/rw2image_int.hpp +++ b/src/rw2image_int.hpp @@ -9,11 +9,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions /*! @brief Panasonic RW2 header structure. @@ -36,6 +35,6 @@ namespace Exiv2 { }; // class Rw2Header -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef RW2IMAGE_INT_HPP_ diff --git a/src/samsungmn_int.hpp b/src/samsungmn_int.hpp index 49611568..d5c3879e 100644 --- a/src/samsungmn_int.hpp +++ b/src/samsungmn_int.hpp @@ -10,11 +10,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Samsung cameras class Samsung2MakerNote { @@ -32,6 +31,6 @@ namespace Exiv2 { }; // class Samsung2MakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef SAMSUNGMN_INT_HPP_ diff --git a/src/sigmamn_int.hpp b/src/sigmamn_int.hpp index 89d41312..7fe5dd23 100644 --- a/src/sigmamn_int.hpp +++ b/src/sigmamn_int.hpp @@ -10,11 +10,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Sigma (Foveon) cameras class SigmaMakerNote { @@ -38,6 +37,6 @@ namespace Exiv2 { }; // class SigmaMakerNote -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef SIGMAMN_INT_HPP_ diff --git a/src/sonymn_int.hpp b/src/sonymn_int.hpp index 76b5327a..0254906a 100644 --- a/src/sonymn_int.hpp +++ b/src/sonymn_int.hpp @@ -9,11 +9,10 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { - namespace Internal { +namespace Exiv2::Internal { -// ***************************************************************************** -// class definitions + // ***************************************************************************** + // class definitions //! MakerNote for Sony cameras class SonyMakerNote { @@ -83,6 +82,6 @@ namespace Exiv2 { DataBuf sonyTagDecipher(uint16_t, const byte*, uint32_t, TiffComponent* const); DataBuf sonyTagEncipher(uint16_t, const byte*, uint32_t, TiffComponent* const); -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef SONYMN_INT_HPP_ diff --git a/src/tags.cpp b/src/tags.cpp index 3ab23aa9..8badc90f 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -332,10 +332,7 @@ namespace Exiv2 { return p_->key_; } - const char* ExifKey::familyName() const - { - return p_->familyName_; - } + const char* ExifKey::familyName() const { return Exiv2::ExifKey::Impl::familyName_; } std::string ExifKey::groupName() const { diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 4fb378e6..6ca4e357 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -69,21 +69,10 @@ namespace Exiv2::Internal { if (pow_) pow_->setTarget(OffsetWriter::OffsetId(id), static_cast(target)); } - TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group), pStart_(nullptr) - { - } + TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) {} TiffEntryBase::TiffEntryBase(uint16_t tag, IfdId group, TiffType tiffType) - : TiffComponent(tag, group), - tiffType_(tiffType), - count_(0), - offset_(0), - size_(0), - pData_(nullptr), - idx_(0), - pValue_(nullptr) - { - } + : TiffComponent(tag, group), tiffType_(tiffType) {} TiffSubIfd::TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup) : TiffEntryBase(tag, group, ttUnsignedLong), newGroup_(newGroup) @@ -91,9 +80,7 @@ namespace Exiv2::Internal { } TiffMnEntry::TiffMnEntry(uint16_t tag, IfdId group, IfdId mnGroup) - : TiffEntryBase(tag, group, ttUndefined), mnGroup_(mnGroup), mn_(nullptr) - { - } + : TiffEntryBase(tag, group, ttUndefined), mnGroup_(mnGroup) {} TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, @@ -103,7 +90,6 @@ namespace Exiv2::Internal { : TiffComponent(tag, group), pHeader_(pHeader), ifd_(tag, mnGroup, hasNext), - mnOffset_(0), imageByteOrder_(invalidByteOrder) { } @@ -111,17 +97,9 @@ namespace Exiv2::Internal { TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg* arrayCfg, const ArrayDef* arrayDef, int defSize) : TiffEntryBase(tag, group, arrayCfg->elTiffType_), - cfgSelFct_(nullptr), - arraySet_(nullptr), arrayCfg_(arrayCfg), arrayDef_(arrayDef), - defSize_(defSize), - setSize_(0), - origData_(nullptr), - origSize_(0), - pRoot_(nullptr), - decoded_(false) - { + defSize_(defSize) { assert(arrayCfg != 0); } @@ -130,15 +108,7 @@ namespace Exiv2::Internal { : TiffEntryBase(tag, group), // Todo: Does it make a difference that there is no type? cfgSelFct_(cfgSelFct), arraySet_(arraySet), - arrayCfg_(nullptr), - arrayDef_(nullptr), - defSize_(0), - setSize_(setSize), - origData_(nullptr), - origSize_(0), - pRoot_(nullptr), - decoded_(false) - { + setSize_(setSize) { // We'll figure out the correct cfg later assert(cfgSelFct != 0); assert(arraySet_ != 0); @@ -203,9 +173,7 @@ namespace Exiv2::Internal { { } - TiffDirectory::TiffDirectory(const TiffDirectory& rhs) : TiffComponent(rhs), hasNext_(rhs.hasNext_), pNext_(nullptr) - { - } + TiffDirectory::TiffDirectory(const TiffDirectory& rhs) : TiffComponent(rhs), hasNext_(rhs.hasNext_) {} TiffSubIfd::TiffSubIfd(const TiffSubIfd& rhs) : TiffEntryBase(rhs), @@ -223,10 +191,7 @@ namespace Exiv2::Internal { setSize_(rhs.setSize_), origData_(rhs.origData_), origSize_(rhs.origSize_), - pRoot_(rhs.pRoot_), - decoded_(false) - { - } + pRoot_(rhs.pRoot_) {} TiffComponent::UniquePtr TiffComponent::clone() const { diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 3f487964..fed04db2 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -342,7 +342,7 @@ namespace Exiv2 { Pointer to the start of the binary representation of the component in a memory buffer. The buffer is allocated and freed outside of this class. */ - byte* pStart_; + byte* pStart_{}; }; // class TiffComponent @@ -535,23 +535,23 @@ namespace Exiv2 { // DATA TiffType tiffType_; //!< Field TIFF type - size_t count_; //!< The number of values of the indicated type - int64_t offset_; //!< Offset to the data area + size_t count_{}; //!< The number of values of the indicated type + int64_t offset_{}; //!< Offset to the data area /*! Size of the data buffer holding the value in bytes, there is no minimum size. */ - uint32_t size_; + uint32_t size_{}; // Notes on the ownership model of pData_: pData_ is a always a // pointer to a buffer owned by somebody else. Usually it is a // pointer into a copy of the image file, but if // TiffEntryBase::setData is used then it is a pointer into the // storage_ DataBuf below. - byte* pData_; //!< Pointer to the data area + byte* pData_{}; //!< Pointer to the data area - int idx_; //!< Unique id of the entry in the image - Value* pValue_; //!< Converted data value + int idx_{}; //!< Unique id of the entry in the image + Value* pValue_{}; //!< Converted data value // This DataBuf is only used when TiffEntryBase::setData is called. // Otherwise, it remains empty. It is wrapped in a shared_ptr because @@ -653,15 +653,7 @@ namespace Exiv2 { class TiffDataEntry : public TiffDataEntryBase { friend class TiffEncoder; public: - //! @name Creators - //@{ - //! Constructor - TiffDataEntry(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) - : TiffDataEntryBase(tag, group, szTag, szGroup), - pDataArea_(0), sizeDataArea_(0) {} - //! Virtual destructor. - ~TiffDataEntry() override = default; - //@} + using TiffDataEntryBase::TiffDataEntryBase; //! @name Manipulators //@{ @@ -706,8 +698,8 @@ namespace Exiv2 { private: // DATA - byte* pDataArea_; //!< Pointer to the data area (never alloc'd) - uint32_t sizeDataArea_; //!< Size of the data area + byte* pDataArea_{}; //!< Pointer to the data area (never alloc'd) + uint32_t sizeDataArea_{}; //!< Size of the data area }; // class TiffDataEntry @@ -725,16 +717,9 @@ namespace Exiv2 { */ class TiffImageEntry : public TiffDataEntryBase { friend class TiffEncoder; - public: - //! @name Creators - //@{ - //! Constructor - TiffImageEntry(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) - : TiffDataEntryBase(tag, group, szTag, szGroup) {} - //! Virtual destructor. - ~TiffImageEntry() override = default; - //@} + using TiffDataEntryBase::TiffDataEntryBase; + public: //! @name Manipulators //@{ void setStrips(const Value* pSize, const byte* pData, uint32_t sizeData, uint32_t baseOffset) override; @@ -844,8 +829,7 @@ namespace Exiv2 { //! @name Creators //@{ //! Default constructor - TiffDirectory(uint16_t tag, IfdId group, bool hasNext =true) - : TiffComponent(tag, group), hasNext_(hasNext), pNext_(0) {} + TiffDirectory(uint16_t tag, IfdId group, bool hasNext = true) : TiffComponent(tag, group), hasNext_(hasNext) {} //! Virtual destructor ~TiffDirectory() override; //@} @@ -932,11 +916,10 @@ namespace Exiv2 { uint32_t& imageIdx); //@} - private: // DATA Components components_; //!< List of components in this directory const bool hasNext_; //!< True if the directory has a next pointer - TiffComponent* pNext_; //!< Pointer to the next IFD + TiffComponent* pNext_{}; //!< Pointer to the next IFD }; // class TiffDirectory @@ -1083,7 +1066,7 @@ namespace Exiv2 { // DATA IfdId mnGroup_; //!< New group for concrete mn - TiffComponent* mn_; //!< The Makernote + TiffComponent* mn_{}; //!< The Makernote }; // class TiffMnEntry @@ -1237,7 +1220,7 @@ namespace Exiv2 { // DATA MnHeader* pHeader_; //!< Makernote header TiffDirectory ifd_; //!< Makernote IFD - uint32_t mnOffset_; //!< Makernote offset + uint32_t mnOffset_{}; //!< Makernote offset ByteOrder imageByteOrder_; //!< Byte order for the image }; // class TiffIfdMakernote @@ -1410,17 +1393,19 @@ namespace Exiv2 { //@} // DATA - const CfgSelFct cfgSelFct_; //!< Pointer to a function to determine which cfg to use (may be 0) - const ArraySet* arraySet_; //!< Pointer to the array set, if any (may be 0) - const ArrayCfg* arrayCfg_; //!< Pointer to the array configuration (must not be 0, except for unrecognized complex binary arrays) - const ArrayDef* arrayDef_; //!< Pointer to the array definition (may be 0) - int defSize_; //!< Size of the array definition array (may be 0) - int setSize_; //!< Size of the array set (may be 0) + const CfgSelFct cfgSelFct_{}; //!< Pointer to a function to determine which cfg to use (may be 0) + const ArraySet* arraySet_{}; //!< Pointer to the array set, if any (may be 0) + const ArrayCfg* arrayCfg_{}; //!< Pointer to the array configuration (must not be 0, except for unrecognized + //!< complex binary arrays) + const ArrayDef* arrayDef_{}; //!< Pointer to the array definition (may be 0) + int defSize_{}; //!< Size of the array definition array (may be 0) + int setSize_{}; //!< Size of the array set (may be 0) Components elements_; //!< List of elements in this composite - byte* origData_; //!< Pointer to the original data buffer (unencrypted) - uint32_t origSize_; //!< Size of the original data buffer - TiffComponent* pRoot_; //!< Pointer to the root component of the TIFF tree. (Only used for intrusive writing.) - bool decoded_; //!< Flag to indicate if the array was decoded + byte* origData_{}; //!< Pointer to the original data buffer (unencrypted) + uint32_t origSize_{}; //!< Size of the original data buffer + TiffComponent* + pRoot_{}; //!< Pointer to the root component of the TIFF tree. (Only used for intrusive writing.) + bool decoded_{}; //!< Flag to indicate if the array was decoded }; // class TiffBinaryArray /*! diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index ca077866..c50c4041 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -11,12 +11,11 @@ // ***************************************************************************** // namespace extensions -namespace Exiv2 { +namespace Exiv2::Internal { /*! @brief Contains internal objects which are not published and are not part of the libexiv2 API. */ - namespace Internal { // ***************************************************************************** // class definitions @@ -270,16 +269,9 @@ namespace Exiv2 { @return Byte order in which the data is encoded, invalidByteOrder if decoding failed. */ - static ByteOrder decode( - ExifData& exifData, - IptcData& iptcData, - XmpData& xmpData, - const byte* pData, - uint32_t size, - uint32_t root, - FindDecoderFct findDecoderFct, - TiffHeaderBase* pHeader =0 - ); + static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData, + uint32_t size, uint32_t root, FindDecoderFct findDecoderFct, + TiffHeaderBase* pHeader = nullptr); /*! @brief Encode TIFF metadata from the metadata containers into a memory block \em blob. @@ -423,12 +415,12 @@ namespace Exiv2 { //! Data structure for the offset list. struct OffsetData { //! Default constructor - OffsetData() : origin_(0), target_(0), byteOrder_(littleEndian) {} + OffsetData() : origin_(0), byteOrder_(littleEndian) {} //! Constructor - OffsetData(uint32_t origin, ByteOrder byteOrder) : origin_(origin), target_(0), byteOrder_(byteOrder) {} + OffsetData(uint32_t origin, ByteOrder byteOrder) : origin_(origin), byteOrder_(byteOrder) {} // DATA uint32_t origin_; //!< Origin address - uint32_t target_; //!< Target address + uint32_t target_{}; //!< Target address ByteOrder byteOrder_; //!< Byte order to use to encode target address }; //! Type of the list containing an identifier and an address pair. @@ -453,6 +445,6 @@ namespace Exiv2 { }; // class FindExifdatum -}} // namespace Internal, Exiv2 +} // namespace Exiv2::Internal #endif // #ifndef TIFFIMAGE_INT_HPP_ diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index cad91733..ddd5c5e6 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -669,10 +669,7 @@ namespace Exiv2::Internal { setGo(geTraverse, !flag); } - bool TiffEncoder::dirty() const - { - return dirty_ || exifData_.count() > 0; - } + bool TiffEncoder::dirty() const { return dirty_ || !exifData_.empty(); } void TiffEncoder::visitEntry(TiffEntry* object) { @@ -768,7 +765,7 @@ namespace Exiv2::Internal { } if (del_) { // Remove remaining synthesized tags - static const char* synthesizedTags[] = { + static constexpr auto synthesizedTags = std::array{ "Exif.MakerNote.Offset", }; for (auto&& synthesizedTag : synthesizedTags) { @@ -1636,9 +1633,7 @@ namespace Exiv2::Internal { if (cryptFct != nullptr) { const byte* pData = object->pData(); int32_t size = object->TiffEntryBase::doSize(); - std::shared_ptr buf = std::make_shared( - cryptFct(object->tag(), pData, size, pRoot_) - ); + auto buf = std::make_shared(cryptFct(object->tag(), pData, size, pRoot_)); if (!buf->empty()) object->setData(buf); } diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp index 025ea0b1..117aa26e 100644 --- a/src/tiffvisitor_int.hpp +++ b/src/tiffvisitor_int.hpp @@ -136,8 +136,7 @@ namespace Exiv2 { //! @name Creators //@{ //! Constructor, taking \em tag and \em group of the component to find. - TiffFinder(uint16_t tag, IfdId group) - : tag_(tag), group_(group), tiffComponent_(0) {} + TiffFinder(uint16_t tag, IfdId group) : tag_(tag), group_(group) {} //! Virtual destructor ~TiffFinder() override = default; //@} @@ -183,7 +182,7 @@ namespace Exiv2 { private: uint16_t tag_; IfdId group_; - TiffComponent* tiffComponent_; + TiffComponent* tiffComponent_{}; }; // class TiffFinder /*! @@ -324,7 +323,6 @@ namespace Exiv2 { const TiffEntryBase* object); //@} - private: // DATA ExifData& exifData_; //!< Exif metadata container IptcData& iptcData_; //!< IPTC metadata container @@ -415,10 +413,7 @@ namespace Exiv2 { @note Encoder functions may use metadata other than \em datum. */ - void encodeTiffComponent( - TiffEntryBase* object, - const Exifdatum* datum =0 - ); + void encodeTiffComponent(TiffEntryBase* object, const Exifdatum* datum = nullptr); //! Callback encoder function for an element of a binary array. void encodeBinaryElement(TiffBinaryElement* object, const Exifdatum* datum); @@ -520,7 +515,6 @@ namespace Exiv2 { bool isImageTag(uint16_t tag, IfdId group) const; //@} - private: // DATA ExifData exifData_; //!< Copy of the Exif data to encode const IptcData& iptcData_; //!< IPTC data to encode, just a reference @@ -645,7 +639,7 @@ namespace Exiv2 { Uses the \em state passed in, if any, and remembers it for use during subsequent calls without any argument. */ - void setMnState(const TiffRwState* state =0); + void setMnState(const TiffRwState* state = nullptr); //! Set the state to the original state as set in the constructor. void setOrigState(); //! Check IFD directory pointer \em start for circular reference From f0d23eca9b497f548c666ab72347c6cf152d95d9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 5 Mar 2022 18:50:53 -0800 Subject: [PATCH 2/2] clang-tidy: add some missing operators Signed-off-by: Rosen Penev --- src/basicio.cpp | 10 ++++++++++ src/exif.cpp | 14 ++------------ src/xmp.cpp | 8 ++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/basicio.cpp b/src/basicio.cpp index 471163dd..ddbc81f3 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -80,6 +80,7 @@ namespace Exiv2 { public: //! Constructor explicit Impl(std::string path); + ~Impl() = default; // Enumerations //! Mode of operation enum OpMode { opRead, opWrite, opSeek }; @@ -583,6 +584,7 @@ namespace Exiv2 { public: Impl() = default; //!< Default constructor Impl(const byte* data, size_t size); //!< Constructor 2 + ~Impl() = default; // DATA byte* data_{nullptr}; //!< Pointer to the start of the memory area @@ -623,6 +625,9 @@ namespace Exiv2 { delete [] data_; } + BlockMap(const BlockMap&) = delete; + BlockMap& operator=(const BlockMap&) = delete; + //! @brief Populate the block. //! @param source The data populate to the block //! @param num The size of data @@ -1038,6 +1043,9 @@ namespace Exiv2 { //! Destructor. Releases all managed memory. virtual ~Impl(); + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; + // DATA std::string path_; //!< (Standard) path size_t blockSize_; //!< Size of the block memory. @@ -1450,6 +1458,8 @@ namespace Exiv2 { HttpImpl(const std::string& url, size_t blockSize); Exiv2::Uri hostInfo_; //!< the host information extracted from the path + ~HttpImpl() override = default; + // METHODS /*! @brief Get the length (in bytes) of the remote file. diff --git a/src/exif.cpp b/src/exif.cpp index 2d1fa222..637b73eb 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -102,12 +102,7 @@ namespace { public: //! Shortcut for a %TiffThumbnail auto pointer. using UniquePtr = std::unique_ptr; - - //! @name Manipulators - //@{ - //! Assignment operator. - TiffThumbnail& operator=(const TiffThumbnail& rhs); - //@} + ~TiffThumbnail() override = default; //! @name Accessors //@{ @@ -123,12 +118,7 @@ namespace { public: //! Shortcut for a %JpegThumbnail auto pointer. using UniquePtr = std::unique_ptr; - - //! @name Manipulators - //@{ - //! Assignment operator. - JpegThumbnail& operator=(const JpegThumbnail& rhs); - //@} + ~JpegThumbnail() override = default; //! @name Accessors //@{ diff --git a/src/xmp.cpp b/src/xmp.cpp index fdaf7110..133d38d6 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -64,6 +64,9 @@ namespace { validator.check_internal(buf, buflen); } + XMLValidator(const XMLValidator&) = delete; + XMLValidator& operator=(const XMLValidator&) = delete; + private: // Private constructor, because this class is only constructed by // the (static) check method. @@ -253,6 +256,10 @@ namespace { { if (xmpLockFct_) xmpLockFct_(pLockData_, false); } + + AutoLock(const AutoLock&) = delete; + AutoLock& operator=(const AutoLock&) = delete; + private: Exiv2::XmpParser::XmpLockFct xmpLockFct_; void* pLockData_; @@ -268,6 +275,7 @@ namespace Exiv2 { Impl(const XmpKey& key, const Value* pValue); //!< Constructor Impl(const Impl& rhs); //!< Copy constructor Impl& operator=(const Impl& rhs); //!< Assignment + ~Impl() = default; // DATA XmpKey::UniquePtr key_; //!< Key