diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 65e86019..6f04e6e3 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -742,16 +742,15 @@ int Params::evalDelete(const std::string& optArg) { switch (action_) { case Action::none: action_ = Action::erase; - target_ = CommonTarget(0); + target_ = static_cast(0); // fallthrough case Action::erase: { const auto rc = parseCommonTargets(optArg, "erase"); if (rc > 0) { - target_ |= CommonTarget(rc); + target_ |= static_cast(rc); return 0; - } else { - return 1; } + return 1; } default: std::cerr << progname() << ": " << _("Option -d is not compatible with a previous option\n"); @@ -764,16 +763,15 @@ int Params::evalExtract(const std::string& optArg) { case Action::none: case Action::modify: action_ = Action::extract; - target_ = CommonTarget(0); + target_ = static_cast(0); // fallthrough case Action::extract: { const auto rc = parseCommonTargets(optArg, "extract"); if (rc > 0) { - target_ |= CommonTarget(rc); + target_ |= static_cast(rc); return 0; - } else { - return 1; } + return 1; } default: std::cerr << progname() << ": " << _("Option -e is not compatible with a previous option\n"); @@ -786,16 +784,15 @@ int Params::evalInsert(const std::string& optArg) { case Action::none: case Action::modify: action_ = Action::insert; - target_ = CommonTarget(0); + target_ = static_cast(0); // fallthrough case Action::insert: { const auto rc = parseCommonTargets(optArg, "insert"); if (rc > 0) { - target_ |= CommonTarget(rc); + target_ |= static_cast(rc); return 0; - } else { - return 1; } + return 1; } default: std::cerr << progname() << ": " << _("Option -i is not compatible with a previous option\n"); @@ -1139,7 +1136,7 @@ void printUnrecognizedArgument(const char argc, const std::string& action) { int64_t parseCommonTargets(const std::string& optArg, const std::string& action) { int64_t rc = 0; - Params::CommonTarget target = Params::CommonTarget(0); + auto target = static_cast(0); Params::CommonTarget all = Params::ctExif | Params::ctIptc | Params::ctComment | Params::ctXmp; Params::CommonTarget extra = Params::ctXmpSidecar | Params::ctExif | Params::ctIptc | Params::ctXmp; for (size_t i = 0; rc == 0 && i < optArg.size(); ++i) { @@ -1175,7 +1172,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action) target |= extra; // -eX if (i > 0) { // -eXX or -iXX target |= Params::ctXmpRaw; - target = Params::CommonTarget(target & ~extra); // turn off those bits + target = static_cast(target & ~extra); // turn off those bits } break; @@ -1196,7 +1193,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action) break; } } - return rc ? rc : int64_t(target); + return rc ? rc : static_cast(target); } int parsePreviewNumbers(Params::PreviewNumbers& previewNumbers, const std::string& optArg, int j) { diff --git a/app/exiv2app.hpp b/app/exiv2app.hpp index cae67770..5c278f9a 100644 --- a/app/exiv2app.hpp +++ b/app/exiv2app.hpp @@ -122,7 +122,7 @@ class Params : public Util::Getopt { static Params& instance(); //! Prevent copy-construction: not implemented. - ~Params() = default; + ~Params() override = default; Params(const Params&) = delete; Params& operator=(const Params&) = delete; diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp index d7963837..7fc29479 100644 --- a/include/exiv2/bmffimage.hpp +++ b/include/exiv2/bmffimage.hpp @@ -14,7 +14,7 @@ // namespace extensions namespace Exiv2 { EXIV2API bool enableBMFF(bool enable = true); -} +} // namespace Exiv2 #ifdef EXV_ENABLE_BMFF namespace Exiv2 { diff --git a/include/exiv2/properties.hpp b/include/exiv2/properties.hpp index 36dc8179..295306fb 100644 --- a/include/exiv2/properties.hpp +++ b/include/exiv2/properties.hpp @@ -8,6 +8,7 @@ // included header files #include + #include "datasets.hpp" // ***************************************************************************** diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp index 317e5986..dd59142f 100644 --- a/include/exiv2/webpimage.hpp +++ b/include/exiv2/webpimage.hpp @@ -54,7 +54,7 @@ class EXIV2API WebPImage : public Image { [[nodiscard]] std::string mimeType() const override; //@} - ~WebPImage() = default; + ~WebPImage() override = default; //! Copy constructor WebPImage(const WebPImage&) = delete; //! Assignment operator diff --git a/include/exiv2/xmp_exiv2.hpp b/include/exiv2/xmp_exiv2.hpp index ec3d02c6..f7e78a7c 100644 --- a/include/exiv2/xmp_exiv2.hpp +++ b/include/exiv2/xmp_exiv2.hpp @@ -58,16 +58,11 @@ class EXIV2API Xmpdatum : public Metadatum { Calls setValue(const std::string&). */ Xmpdatum& operator=(const std::string& value); - /*! - @brief Assign const char* \em value to the %Xmpdatum. - Calls operator=(const std::string&). - */ - Xmpdatum& operator=(const char* value); /*! @brief Assign a boolean \em value to the %Xmpdatum. Translates the value to a string "true" or "false". */ - Xmpdatum& operator=(const bool& value); + Xmpdatum& operator=(bool value); /*! @brief Assign a \em value of any type with an output operator to the %Xmpdatum. Calls operator=(const std::string&). @@ -227,23 +222,23 @@ class EXIV2API XmpData { //! are we to use the packet? [[nodiscard]] bool usePacket() const { return usePacket_; - }; + } //! set usePacket_ bool usePacket(bool b) { bool r = usePacket_; usePacket_ = b; return r; - }; + } //! setPacket void setPacket(std::string xmpPacket) { xmpPacket_ = std::move(xmpPacket); usePacket(false); - }; + } // ! getPacket [[nodiscard]] const std::string& xmpPacket() const { return xmpPacket_; - }; + } //@} @@ -404,11 +399,7 @@ class EXIV2API XmpParser { // ***************************************************************************** // free functions, template and inline definitions -inline Xmpdatum& Xmpdatum::operator=(const char* value) { - return Xmpdatum::operator=(std::string(value)); -} - -inline Xmpdatum& Xmpdatum::operator=(const bool& value) { +inline Xmpdatum& Xmpdatum::operator=(bool value) { return operator=(value ? "True" : "False"); } diff --git a/src/convert.cpp b/src/convert.cpp index fbe53d60..93f49182 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1284,7 +1284,7 @@ std::string Converter::computeExifDigest(bool tiff) { } #else std::string Converter::computeExifDigest(bool) { - return std::string(""); + return {}; } #endif diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index f636f03b..07e485ac 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -3226,9 +3226,9 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value, std::string d = s.empty() ? "" : "; "; const TagDetails* td = find(nikonRetouchHistory, l); if (td) { - s = std::string(exvGettext(td->label_)) + d + s; + s = std::string(exvGettext(td->label_)).append(d).append(s); } else { - s = std::string(_("Unknown")) + std::string(" (") + toString(l) + std::string(")") + d + s; + s = std::string(_("Unknown")).append(" (").append(toString(l)).append(")").append(d).append(s); } } return os << s; diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index e7aec605..2d7cdcbd 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -318,31 +318,25 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize, } // PngChunk::parseChunkContent std::string PngChunk::makeMetadataChunk(const std::string& metadata, MetadataId type) { - std::string chunk; std::string rawProfile; switch (type) { case mdComment: - chunk = makeUtf8TxtChunk("Description", metadata, true); - break; + return makeUtf8TxtChunk("Description", metadata, true); case mdExif: rawProfile = writeRawProfile(metadata, "exif"); - chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true); - break; + return makeAsciiTxtChunk("Raw profile type exif", rawProfile, true); case mdIptc: rawProfile = writeRawProfile(metadata, "iptc"); - chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true); - break; + return makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true); case mdXmp: - chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false); - break; + return makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false); case mdIccProfile: - break; case mdNone: - break; + return {}; } - return chunk; + return {}; } // PngChunk::makeMetadataChunk diff --git a/src/tags.cpp b/src/tags.cpp index f084dd9d..13c231c0 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -302,7 +302,7 @@ std::string ExifKey::tagLabel() const { std::string ExifKey::tagDesc() const { if (!p_->tagInfo_ || p_->tagInfo_->tag_ == 0xffff) - return ""; + return {}; return _(p_->tagInfo_->desc_); } diff --git a/src/types.cpp b/src/types.cpp index 1ec865e4..ff6bc48b 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -178,7 +178,8 @@ byte* Exiv2::DataBuf::data(size_t offset) { const byte* Exiv2::DataBuf::c_data(size_t offset) const { if (pData_.empty()) { return nullptr; - } else if (offset >= pData_.size()) { + } + if (offset >= pData_.size()) { throw std::out_of_range("Overflow in Exiv2::DataBuf::c_data"); } return &pData_[offset]; diff --git a/src/utils.hpp b/src/utils.hpp index 1e16648d..c385b07d 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -14,7 +14,7 @@ constexpr bool startsWith(std::string_view s, std::string_view start) { std::string upper(const std::string& str); /// @brief Returns the lowercase version of \b str -std::string lower(const std::string& str); +std::string lower(const std::string& a); } // namespace Exiv2::Internal diff --git a/src/xmp.cpp b/src/xmp.cpp index cb4f422d..ed54b340 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -53,7 +53,7 @@ class XMLValidator { // error out if the depth exceeds this limit. static const size_t max_recursion_limit_ = 1000; - const XML_Parser parser_; + XML_Parser parser_; public: // Runs an XML parser on `buf`. Throws an exception if the XML is invalid.