From a6185d29c66113d7f2cac1ab3b2f258ffe07d405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Wed, 16 Feb 2022 19:25:59 +0100 Subject: [PATCH] Image::setComment now takes string_view --- include/exiv2/bmffimage.hpp | 2 +- include/exiv2/bmpimage.hpp | 2 +- include/exiv2/cr2image.hpp | 2 +- include/exiv2/epsimage.hpp | 2 +- include/exiv2/gifimage.hpp | 2 +- include/exiv2/image.hpp | 10 ++++------ include/exiv2/jp2image.hpp | 2 +- include/exiv2/mrwimage.hpp | 2 +- include/exiv2/orfimage.hpp | 2 +- include/exiv2/psdimage.hpp | 2 +- include/exiv2/rafimage.hpp | 2 +- include/exiv2/rw2image.hpp | 2 +- include/exiv2/tgaimage.hpp | 2 +- include/exiv2/tiffimage.hpp | 2 +- include/exiv2/webpimage.hpp | 2 +- include/exiv2/xmpsidecar.hpp | 2 +- src/bmffimage.cpp | 4 ++-- src/bmpimage.cpp | 2 +- src/cr2image.cpp | 2 +- src/epsimage.cpp | 2 +- src/gifimage.cpp | 2 +- src/image.cpp | 3 +-- src/jp2image.cpp | 4 ++-- src/mrwimage.cpp | 2 +- src/orfimage.cpp | 2 +- src/psdimage.cpp | 2 +- src/rafimage.cpp | 2 +- src/rw2image.cpp | 2 +- src/tgaimage.cpp | 2 +- src/tiffimage.cpp | 2 +- src/webpimage.cpp | 2 +- src/xmpsidecar.cpp | 2 +- 32 files changed, 37 insertions(+), 40 deletions(-) diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp index e5f8515b..b905e0cf 100644 --- a/include/exiv2/bmffimage.hpp +++ b/include/exiv2/bmffimage.hpp @@ -127,7 +127,7 @@ namespace Exiv2 //@{ void readMetadata() override /* override */; void writeMetadata() override /* override */; - void setComment(const std::string& comment) override /* override */; + void setComment(const std::string_view comment) override /* override */; void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override; //@} diff --git a/include/exiv2/bmpimage.hpp b/include/exiv2/bmpimage.hpp index 6fd46fdf..cb333904 100644 --- a/include/exiv2/bmpimage.hpp +++ b/include/exiv2/bmpimage.hpp @@ -85,7 +85,7 @@ namespace Exiv2 { void setIptcData(const IptcData& iptcData) override; /// @throws Error(kerInvalidSettingForImage) - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/cr2image.hpp b/include/exiv2/cr2image.hpp index 7fba1244..79253c9d 100644 --- a/include/exiv2/cr2image.hpp +++ b/include/exiv2/cr2image.hpp @@ -81,7 +81,7 @@ namespace Exiv2 { @brief Not supported. CR2 format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/epsimage.hpp b/include/exiv2/epsimage.hpp index 20360477..f37c6d4f 100644 --- a/include/exiv2/epsimage.hpp +++ b/include/exiv2/epsimage.hpp @@ -80,7 +80,7 @@ namespace Exiv2 @brief Not supported. Calling this function will throw an instance of Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/gifimage.hpp b/include/exiv2/gifimage.hpp index 97c33b6c..88dac6c4 100644 --- a/include/exiv2/gifimage.hpp +++ b/include/exiv2/gifimage.hpp @@ -86,7 +86,7 @@ namespace Exiv2 { @brief Not supported. Calling this function will throw an instance of Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index 3372fbb5..fc8a9130 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -199,12 +199,10 @@ namespace Exiv2 { writeXmpFromPacket(true) or setXmpPacket(). */ virtual void clearXmpData(); - /*! - @brief Set the image comment. The new comment is not written - to the image until the writeMetadata() method is called. - @param comment String containing comment. - */ - virtual void setComment(const std::string& comment); + + /// @brief Set the image comment. The comment is written to the image when writeMetadata() is called. + virtual void setComment(const std::string_view comment); + /*! @brief Erase any buffered comment. Comment is not removed from the actual image until the writeMetadata() method is called. diff --git a/include/exiv2/jp2image.hpp b/include/exiv2/jp2image.hpp index e303fb30..b53f92aa 100644 --- a/include/exiv2/jp2image.hpp +++ b/include/exiv2/jp2image.hpp @@ -80,7 +80,7 @@ namespace Exiv2 @brief Todo: Not supported yet(?). Calling this function will throw an instance of Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/mrwimage.hpp b/include/exiv2/mrwimage.hpp index c278b32f..d4d19387 100644 --- a/include/exiv2/mrwimage.hpp +++ b/include/exiv2/mrwimage.hpp @@ -89,7 +89,7 @@ namespace Exiv2 { @brief Not supported. MRW format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/orfimage.hpp b/include/exiv2/orfimage.hpp index 319e05f1..0f92a5f6 100644 --- a/include/exiv2/orfimage.hpp +++ b/include/exiv2/orfimage.hpp @@ -76,7 +76,7 @@ namespace Exiv2 { @brief Not supported. ORF format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/psdimage.hpp b/include/exiv2/psdimage.hpp index 9bcfb01e..fcd61db5 100644 --- a/include/exiv2/psdimage.hpp +++ b/include/exiv2/psdimage.hpp @@ -70,7 +70,7 @@ namespace Exiv2 { /*! @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/rafimage.hpp b/include/exiv2/rafimage.hpp index cab4b898..6cb0bea0 100644 --- a/include/exiv2/rafimage.hpp +++ b/include/exiv2/rafimage.hpp @@ -87,7 +87,7 @@ namespace Exiv2 { @brief Not supported. RAF format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/rw2image.hpp b/include/exiv2/rw2image.hpp index 2e3c3948..84411edf 100644 --- a/include/exiv2/rw2image.hpp +++ b/include/exiv2/rw2image.hpp @@ -80,7 +80,7 @@ namespace Exiv2 { @brief Not supported. RW2 format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/tgaimage.hpp b/include/exiv2/tgaimage.hpp index ce5f07bd..c19fc26c 100644 --- a/include/exiv2/tgaimage.hpp +++ b/include/exiv2/tgaimage.hpp @@ -86,7 +86,7 @@ namespace Exiv2 { @brief Not supported. Calling this function will throw an instance of Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/tiffimage.hpp b/include/exiv2/tiffimage.hpp index 11201b73..3364f267 100644 --- a/include/exiv2/tiffimage.hpp +++ b/include/exiv2/tiffimage.hpp @@ -77,7 +77,7 @@ namespace Exiv2 { @brief Not supported. TIFF format does not contain a comment. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp index d3280921..6a008cf0 100644 --- a/include/exiv2/webpimage.hpp +++ b/include/exiv2/webpimage.hpp @@ -65,7 +65,7 @@ namespace Exiv2 { /*! @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; void setIptcData(const IptcData& /*iptcData*/) override; //! @name Accessors diff --git a/include/exiv2/xmpsidecar.hpp b/include/exiv2/xmpsidecar.hpp index 5557a331..654cef4f 100644 --- a/include/exiv2/xmpsidecar.hpp +++ b/include/exiv2/xmpsidecar.hpp @@ -64,7 +64,7 @@ namespace Exiv2 { @brief Not supported. XMP sidecar files do not contain a comment. Calling this function will throw an instance of Error(kerInvalidSettingForImage). */ - void setComment(const std::string& comment) override; + void setComment(const std::string_view comment) override; //@} //! @name Accessors diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index ddce22a0..c5dbc148 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -627,11 +627,11 @@ namespace Exiv2 } } - void BmffImage::setComment(const std::string& /*comment*/) + void BmffImage::setComment(const std::string_view /*comment*/) { // bmff files are read-only throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF")); - } // BmffImage::setComment + } void BmffImage::openOrThrow() { diff --git a/src/bmpimage.cpp b/src/bmpimage.cpp index 0e3ea146..168db5d5 100644 --- a/src/bmpimage.cpp +++ b/src/bmpimage.cpp @@ -61,7 +61,7 @@ namespace Exiv2 throw(Error(kerInvalidSettingForImage, "IPTC metadata", "BMP")); } - void BmpImage::setComment(const std::string& /*comment*/) + void BmpImage::setComment(const std::string_view /*comment*/) { throw(Error(kerInvalidSettingForImage, "Image comment", "BMP")); } diff --git a/src/cr2image.cpp b/src/cr2image.cpp index 4bd9a0b9..73bc6dd3 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -81,7 +81,7 @@ namespace Exiv2 { printTiffStructure(io(),out,option,depth-1); } - void Cr2Image::setComment(const std::string& /*comment*/) + void Cr2Image::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "CR2")); diff --git a/src/epsimage.cpp b/src/epsimage.cpp index eba0c7fe..52556eae 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -1098,7 +1098,7 @@ namespace Exiv2 return "application/postscript"; } - void EpsImage::setComment(const std::string& /*comment*/) + void EpsImage::setComment(const std::string_view /*comment*/) { throw Error(kerInvalidSettingForImage, "Image comment", "EPS"); } diff --git a/src/gifimage.cpp b/src/gifimage.cpp index 22d1400c..98f81e64 100644 --- a/src/gifimage.cpp +++ b/src/gifimage.cpp @@ -58,7 +58,7 @@ namespace Exiv2 { throw(Error(kerInvalidSettingForImage, "IPTC metadata", "GIF")); } - void GifImage::setComment(const std::string& /*comment*/) + void GifImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "GIF")); diff --git a/src/image.cpp b/src/image.cpp index b37d3ac8..298f9d79 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -630,7 +630,6 @@ namespace Exiv2 { void Image::setXmpPacket(const std::string& xmpPacket) { - xmpPacket_ = xmpPacket; if ( XmpParser::decode(xmpData_, xmpPacket) ) { throw Error(kerInvalidXMP); } @@ -663,7 +662,7 @@ namespace Exiv2 { comment_.erase(); } - void Image::setComment(const std::string& comment) + void Image::setComment(const std::string_view comment) { comment_ = comment; } diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 5ba66117..0c2648ff 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -158,11 +158,11 @@ namespace Exiv2 return "image/jp2"; } - void Jp2Image::setComment(const std::string& /*comment*/) + void Jp2Image::setComment(const std::string_view /*comment*/) { // Todo: implement me! throw(Error(kerInvalidSettingForImage, "Image comment", "JP2")); - } // Jp2Image::setComment + } static void lf(std::ostream& out,bool& bLF) { diff --git a/src/mrwimage.cpp b/src/mrwimage.cpp index 129d6769..80decc04 100644 --- a/src/mrwimage.cpp +++ b/src/mrwimage.cpp @@ -79,7 +79,7 @@ namespace Exiv2 { throw(Error(kerInvalidSettingForImage, "IPTC metadata", "MRW")); } - void MrwImage::setComment(const std::string& /*comment*/) + void MrwImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "MRW")); diff --git a/src/orfimage.cpp b/src/orfimage.cpp index a6836ab6..8adb4680 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -72,7 +72,7 @@ namespace Exiv2 { return 0; } - void OrfImage::setComment(const std::string& /*comment*/) + void OrfImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "ORF")); diff --git a/src/psdimage.cpp b/src/psdimage.cpp index 9a159fe6..ccf21e98 100644 --- a/src/psdimage.cpp +++ b/src/psdimage.cpp @@ -127,7 +127,7 @@ namespace Exiv2 { return "image/x-photoshop"; } - void PsdImage::setComment(const std::string& /*comment*/) + void PsdImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "Photoshop")); diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 23bb0109..92c24a4c 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -81,7 +81,7 @@ namespace Exiv2 { throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RAF")); } - void RafImage::setComment(const std::string& /*comment*/) + void RafImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "RAF")); diff --git a/src/rw2image.cpp b/src/rw2image.cpp index 4d856326..7142960c 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -83,7 +83,7 @@ namespace Exiv2 { throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RW2")); } - void Rw2Image::setComment(const std::string& /*comment*/) + void Rw2Image::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "RW2")); diff --git a/src/tgaimage.cpp b/src/tgaimage.cpp index f5f9b3ca..0db1fff6 100644 --- a/src/tgaimage.cpp +++ b/src/tgaimage.cpp @@ -58,7 +58,7 @@ namespace Exiv2 { throw(Error(kerInvalidSettingForImage, "IPTC metadata", "TGA")); } - void TgaImage::setComment(const std::string& /*comment*/) + void TgaImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "TGA")); diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index 4a405b03..e7a6a81b 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -162,7 +162,7 @@ namespace Exiv2 { return pixelHeightPrimary_; } - void TiffImage::setComment(const std::string& /*comment*/) + void TiffImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "TIFF")); diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 95400819..c023cf0e 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -96,7 +96,7 @@ namespace Exiv2 { // throw(Error(kerInvalidSettingForImage, "IPTC metadata", "WebP")); } - void WebPImage::setComment(const std::string& /*comment*/) + void WebPImage::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "WebP")); diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index 28d405cd..c14e3fd2 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -61,7 +61,7 @@ namespace Exiv2 { return "application/rdf+xml"; } - void XmpSidecar::setComment(const std::string& /*comment*/) + void XmpSidecar::setComment(const std::string_view /*comment*/) { // not supported throw(Error(kerInvalidSettingForImage, "Image comment", "XMP"));