Improvements from code review

main
Luis Díaz Más 3 years ago
parent f774a3b25e
commit 8b3da36f42

@ -128,7 +128,7 @@ namespace Exiv2
//@{ //@{
void readMetadata() override /* override */; void readMetadata() override /* override */;
void writeMetadata() override /* override */; void writeMetadata() override /* override */;
void setComment(const std::string_view comment) override /* override */; void setComment(std::string_view comment) override /* override */;
void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override; void printStructure(std::ostream& out, Exiv2::PrintStructureOption option, int depth) override;
//@} //@}

@ -85,7 +85,7 @@ namespace Exiv2 {
void setIptcData(const IptcData& iptcData) override; void setIptcData(const IptcData& iptcData) override;
/// @throws Error(kerInvalidSettingForImage) /// @throws Error(kerInvalidSettingForImage)
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -81,7 +81,7 @@ namespace Exiv2 {
@brief Not supported. CR2 format does not contain a comment. @brief Not supported. CR2 format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -80,7 +80,7 @@ namespace Exiv2
@brief Not supported. @brief Not supported.
Calling this function will throw an instance of Error(kerInvalidSettingForImage). Calling this function will throw an instance of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -63,7 +63,7 @@ namespace Exiv2
@note Source: http://www.geekhideout.com/urlcode.shtml @note Source: http://www.geekhideout.com/urlcode.shtml
@todo This function can probably be hidden into the implementation details @todo This function can probably be hidden into the implementation details
*/ */
EXIV2API std::string urlencode(const std::string_view& str); EXIV2API std::string urlencode(std::string_view str);
/*! /*!
@brief Like urlencode(char* str) but accept the input url in the std::string and modify it. @brief Like urlencode(char* str) but accept the input url in the std::string and modify it.

@ -86,7 +86,7 @@ namespace Exiv2 {
@brief Not supported. Calling this function will throw an instance @brief Not supported. Calling this function will throw an instance
of Error(kerInvalidSettingForImage). of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -197,7 +197,7 @@ namespace Exiv2 {
virtual void clearXmpData(); virtual void clearXmpData();
/// @brief Set the image comment. The comment is written to the image when writeMetadata() is called. /// @brief Set the image comment. The comment is written to the image when writeMetadata() is called.
virtual void setComment(const std::string_view comment); virtual void setComment(std::string_view comment);
/*! /*!
@brief Erase any buffered comment. Comment is not removed @brief Erase any buffered comment. Comment is not removed

@ -80,7 +80,7 @@ namespace Exiv2
@brief Todo: Not supported yet(?). Calling this function will throw @brief Todo: Not supported yet(?). Calling this function will throw
an instance of Error(kerInvalidSettingForImage). an instance of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -89,7 +89,7 @@ namespace Exiv2 {
@brief Not supported. MRW format does not contain a comment. @brief Not supported. MRW format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -76,7 +76,7 @@ namespace Exiv2 {
@brief Not supported. ORF format does not contain a comment. @brief Not supported. ORF format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -70,7 +70,7 @@ namespace Exiv2 {
/*! /*!
@brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage). @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -82,7 +82,7 @@ namespace Exiv2 {
@brief Not supported. RAF format does not contain a comment. @brief Not supported. RAF format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -80,7 +80,7 @@ namespace Exiv2 {
@brief Not supported. RW2 format does not contain a comment. @brief Not supported. RW2 format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -86,7 +86,7 @@ namespace Exiv2 {
@brief Not supported. Calling this function will throw an instance @brief Not supported. Calling this function will throw an instance
of Error(kerInvalidSettingForImage). of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -77,7 +77,7 @@ namespace Exiv2 {
@brief Not supported. TIFF format does not contain a comment. @brief Not supported. TIFF format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage). Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -65,7 +65,7 @@ namespace Exiv2 {
/*! /*!
@brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage). @brief Not supported. Calling this function will throw an Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
void setIptcData(const IptcData& /*iptcData*/) override; void setIptcData(const IptcData& /*iptcData*/) override;
//! @name Accessors //! @name Accessors

@ -64,7 +64,7 @@ namespace Exiv2 {
@brief Not supported. XMP sidecar files do not contain a comment. @brief Not supported. XMP sidecar files do not contain a comment.
Calling this function will throw an instance of Error(kerInvalidSettingForImage). Calling this function will throw an instance of Error(kerInvalidSettingForImage).
*/ */
void setComment(const std::string_view comment) override; void setComment(std::string_view comment) override;
//@} //@}
//! @name Accessors //! @name Accessors

@ -385,7 +385,7 @@ namespace Exiv2 {
bool statOk = true; bool statOk = true;
mode_t origStMode = 0; mode_t origStMode = 0;
char* pf = const_cast<char*>(path().c_str()); auto pf = path().c_str();
Impl::StructStat buf1; Impl::StructStat buf1;
if (p_->stat(buf1) == -1) { if (p_->stat(buf1) == -1) {

@ -627,7 +627,7 @@ namespace Exiv2
} }
} }
void BmffImage::setComment(const std::string_view /*comment*/) void BmffImage::setComment(std::string_view /*comment*/)
{ {
// bmff files are read-only // bmff files are read-only
throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF")); throw(Error(kerInvalidSettingForImage, "Image comment", "BMFF"));

@ -61,7 +61,7 @@ namespace Exiv2
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "BMP")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "BMP"));
} }
void BmpImage::setComment(const std::string_view /*comment*/) void BmpImage::setComment(std::string_view /*comment*/)
{ {
throw(Error(kerInvalidSettingForImage, "Image comment", "BMP")); throw(Error(kerInvalidSettingForImage, "Image comment", "BMP"));
} }

@ -81,7 +81,7 @@ namespace Exiv2 {
printTiffStructure(io(),out,option,depth-1); printTiffStructure(io(),out,option,depth-1);
} }
void Cr2Image::setComment(const std::string_view /*comment*/) void Cr2Image::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "CR2")); throw(Error(kerInvalidSettingForImage, "Image comment", "CR2"));

@ -1094,7 +1094,7 @@ namespace Exiv2
return "application/postscript"; return "application/postscript";
} }
void EpsImage::setComment(const std::string_view /*comment*/) void EpsImage::setComment(std::string_view /*comment*/)
{ {
throw Error(kerInvalidSettingForImage, "Image comment", "EPS"); throw Error(kerInvalidSettingForImage, "Image comment", "EPS");
} }

@ -105,11 +105,11 @@ namespace Exiv2 {
return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10; return isdigit(ch) ? ch - '0' : tolower(ch) - 'a' + 10;
} }
std::string urlencode(const std::string_view& str) std::string urlencode(std::string_view str)
{ {
std::string encoded; std::string encoded;
encoded.reserve(str.size() * 3); encoded.reserve(str.size() * 3);
for (auto c : str) { for (uint8_t c : str) {
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
encoded += c; encoded += c;
else if (c == ' ') else if (c == ' ')

@ -58,7 +58,7 @@ namespace Exiv2 {
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "GIF")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "GIF"));
} }
void GifImage::setComment(const std::string_view /*comment*/) void GifImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "GIF")); throw(Error(kerInvalidSettingForImage, "Image comment", "GIF"));

@ -662,7 +662,7 @@ namespace Exiv2 {
comment_.erase(); comment_.erase();
} }
void Image::setComment(const std::string_view comment) void Image::setComment(std::string_view comment)
{ {
comment_ = comment; comment_ = comment;
} }

@ -158,7 +158,7 @@ namespace Exiv2
return "image/jp2"; return "image/jp2";
} }
void Jp2Image::setComment(const std::string_view /*comment*/) void Jp2Image::setComment(std::string_view /*comment*/)
{ {
// Todo: implement me! // Todo: implement me!
throw(Error(kerInvalidSettingForImage, "Image comment", "JP2")); throw(Error(kerInvalidSettingForImage, "Image comment", "JP2"));

@ -35,6 +35,7 @@
#include "utils.hpp" #include "utils.hpp"
// + standard includes // + standard includes
#include <array>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -1197,7 +1198,7 @@ namespace Exiv2 {
{ {
// Not valid for models beginning // Not valid for models beginning
std::string model = getExifModel(pRoot); std::string model = getExifModel(pRoot);
const std::vector<std::string> strs { "SLT-", "HV", "ILCA-"}; const std::array strs { "SLT-", "HV", "ILCA-"};
return std::any_of(strs.begin(), strs.end(), [&model](auto& m){return startsWith(model, m);}) ? -1 : 0; return std::any_of(strs.begin(), strs.end(), [&model](auto& m){return startsWith(model, m);}) ? -1 : 0;
} }

@ -79,7 +79,7 @@ namespace Exiv2 {
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "MRW")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "MRW"));
} }
void MrwImage::setComment(const std::string_view /*comment*/) void MrwImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "MRW")); throw(Error(kerInvalidSettingForImage, "Image comment", "MRW"));

@ -72,7 +72,7 @@ namespace Exiv2 {
return 0; return 0;
} }
void OrfImage::setComment(const std::string_view /*comment*/) void OrfImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "ORF")); throw(Error(kerInvalidSettingForImage, "Image comment", "ORF"));

@ -127,7 +127,7 @@ namespace Exiv2 {
return "image/x-photoshop"; return "image/x-photoshop";
} }
void PsdImage::setComment(const std::string_view /*comment*/) void PsdImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "Photoshop")); throw(Error(kerInvalidSettingForImage, "Image comment", "Photoshop"));

@ -81,7 +81,7 @@ namespace Exiv2 {
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RAF")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RAF"));
} }
void RafImage::setComment(const std::string_view /*comment*/) void RafImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "RAF")); throw(Error(kerInvalidSettingForImage, "Image comment", "RAF"));

@ -83,7 +83,7 @@ namespace Exiv2 {
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RW2")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "RW2"));
} }
void Rw2Image::setComment(const std::string_view /*comment*/) void Rw2Image::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "RW2")); throw(Error(kerInvalidSettingForImage, "Image comment", "RW2"));

@ -58,7 +58,7 @@ namespace Exiv2 {
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "TGA")); throw(Error(kerInvalidSettingForImage, "IPTC metadata", "TGA"));
} }
void TgaImage::setComment(const std::string_view /*comment*/) void TgaImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "TGA")); throw(Error(kerInvalidSettingForImage, "Image comment", "TGA"));

@ -162,7 +162,7 @@ namespace Exiv2 {
return pixelHeightPrimary_; return pixelHeightPrimary_;
} }
void TiffImage::setComment(const std::string_view /*comment*/) void TiffImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "TIFF")); throw(Error(kerInvalidSettingForImage, "Image comment", "TIFF"));

@ -96,7 +96,7 @@ namespace Exiv2 {
// throw(Error(kerInvalidSettingForImage, "IPTC metadata", "WebP")); // throw(Error(kerInvalidSettingForImage, "IPTC metadata", "WebP"));
} }
void WebPImage::setComment(const std::string_view /*comment*/) void WebPImage::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "WebP")); throw(Error(kerInvalidSettingForImage, "Image comment", "WebP"));

@ -62,7 +62,7 @@ namespace Exiv2 {
return "application/rdf+xml"; return "application/rdf+xml";
} }
void XmpSidecar::setComment(const std::string_view /*comment*/) void XmpSidecar::setComment(std::string_view /*comment*/)
{ {
// not supported // not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "XMP")); throw(Error(kerInvalidSettingForImage, "Image comment", "XMP"));

Loading…
Cancel
Save