diff --git a/include/exiv2/basicio.hpp b/include/exiv2/basicio.hpp
index 42480d51..daada21b 100644
--- a/include/exiv2/basicio.hpp
+++ b/include/exiv2/basicio.hpp
@@ -201,25 +201,25 @@ class EXIV2API BasicIo {
@return Offset from the start of IO if successful;
-1 if failure;
*/
- virtual long tell() const = 0;
+ [[nodiscard]] virtual long tell() const = 0;
/*!
@brief Get the current size of the IO source in bytes.
@return Size of the IO source in bytes;
-1 if failure;
*/
- virtual size_t size() const = 0;
+ [[nodiscard]] virtual size_t size() const = 0;
//! Returns true if the IO source is open, otherwise false.
- virtual bool isopen() const = 0;
+ [[nodiscard]] virtual bool isopen() const = 0;
//! Returns 0 if the IO source is in a valid state, otherwise nonzero.
- virtual int error() const = 0;
+ [[nodiscard]] virtual int error() const = 0;
//! Returns true if the IO position has reached the end, otherwise false.
- virtual bool eof() const = 0;
+ [[nodiscard]] virtual bool eof() const = 0;
/*!
@brief Return the path to the IO resource. Often used to form
comprehensive error messages where only a BasicIo instance is
available.
*/
- virtual const std::string &path() const noexcept = 0;
+ [[nodiscard]] virtual const std::string &path() const noexcept = 0;
/*!
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
@@ -442,22 +442,22 @@ class EXIV2API FileIo : public BasicIo {
@return Offset from the start of the file if successful;
-1 if failure;
*/
- long tell() const override;
+ [[nodiscard]] long tell() const override;
/*!
@brief Flush any buffered writes and get the current file size
in bytes.
@return Size of the file in bytes;
-1 if failure;
*/
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
//! Returns true if the file is open, otherwise false.
- bool isopen() const override;
+ [[nodiscard]] bool isopen() const override;
//! Returns 0 if the file is in a valid state, otherwise nonzero.
- int error() const override;
+ [[nodiscard]] int error() const override;
//! Returns true if the file position has reached the end, otherwise false.
- bool eof() const override;
+ [[nodiscard]] bool eof() const override;
//! Returns the path of the file
- const std::string &path() const noexcept override;
+ [[nodiscard]] const std::string &path() const noexcept override;
/*!
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
@@ -624,21 +624,21 @@ class EXIV2API MemIo : public BasicIo {
@brief Get the current IO position.
@return Offset from the start of the memory block
*/
- long tell() const override;
+ [[nodiscard]] long tell() const override;
/*!
@brief Get the current memory buffer size in bytes.
@return Size of the in memory data in bytes;
-1 if failure;
*/
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
//! Always returns true
- bool isopen() const override;
+ [[nodiscard]] bool isopen() const override;
//! Always returns 0
- int error() const override;
+ [[nodiscard]] int error() const override;
//! Returns true if the IO position has reached the end, otherwise false.
- bool eof() const override;
+ [[nodiscard]] bool eof() const override;
//! Returns a dummy path, indicating that memory access is used
- const std::string &path() const noexcept override;
+ [[nodiscard]] const std::string &path() const noexcept override;
/*!
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
@@ -868,21 +868,21 @@ class EXIV2API RemoteIo : public BasicIo {
@brief Get the current IO position.
@return Offset from the start of the memory block
*/
- long tell() const override;
+ [[nodiscard]] long tell() const override;
/*!
@brief Get the current memory buffer size in bytes.
@return Size of the in memory data in bytes;
-1 if failure;
*/
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
//! Returns true if the memory area is allocated.
- bool isopen() const override;
+ [[nodiscard]] bool isopen() const override;
//! Always returns 0
- int error() const override;
+ [[nodiscard]] int error() const override;
//! Returns true if the IO position has reached the end, otherwise false.
- bool eof() const override;
+ [[nodiscard]] bool eof() const override;
//! Returns the URL of the file.
- const std::string &path() const noexcept override;
+ [[nodiscard]] const std::string &path() const noexcept override;
/*!
@brief Mark all the bNone blocks to bKnow. This avoids allocating memory
diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp
index f0ad35f0..94984a9e 100644
--- a/include/exiv2/bmffimage.hpp
+++ b/include/exiv2/bmffimage.hpp
@@ -26,7 +26,7 @@ struct Iloc {
uint32_t start_;
uint32_t length_;
- std::string toString() const;
+ [[nodiscard]] std::string toString() const;
}; // class Iloc
// *****************************************************************************
@@ -105,12 +105,12 @@ class EXIV2API BmffImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override /* override */;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override /* override */;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
- Exiv2::ByteOrder endian_{Exiv2::bigEndian};
+ const Exiv2::ByteOrder endian_{Exiv2::bigEndian};
private:
void openOrThrow();
@@ -123,7 +123,7 @@ class EXIV2API BmffImage : public Image {
@warning This function should only be called by readMetadata()
*/
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, const long pbox_end, int depth);
- std::string indent(int i) {
+ [[nodiscard]] std::string indent(int i) const {
return std::string(2 * i, ' ');
}
diff --git a/include/exiv2/bmpimage.hpp b/include/exiv2/bmpimage.hpp
index eb535227..3d3b1b9a 100644
--- a/include/exiv2/bmpimage.hpp
+++ b/include/exiv2/bmpimage.hpp
@@ -70,7 +70,7 @@ class EXIV2API BmpImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
}; // class BmpImage
diff --git a/include/exiv2/cr2image.hpp b/include/exiv2/cr2image.hpp
index efd948e2..fdf93a3e 100644
--- a/include/exiv2/cr2image.hpp
+++ b/include/exiv2/cr2image.hpp
@@ -66,9 +66,9 @@ class EXIV2API Cr2Image : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
//! @name NOT implemented
diff --git a/include/exiv2/crwimage.hpp b/include/exiv2/crwimage.hpp
index 7ce322a0..09f8278c 100644
--- a/include/exiv2/crwimage.hpp
+++ b/include/exiv2/crwimage.hpp
@@ -68,9 +68,9 @@ class EXIV2API CrwImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
//! @name NOT Implemented
diff --git a/include/exiv2/datasets.hpp b/include/exiv2/datasets.hpp
index e76e20a8..898724ac 100644
--- a/include/exiv2/datasets.hpp
+++ b/include/exiv2/datasets.hpp
@@ -272,21 +272,21 @@ class EXIV2API IptcKey : public Key {
//! @name Accessors
//@{
- std::string key() const override;
- const char* familyName() const override;
+ [[nodiscard]] std::string key() const override;
+ [[nodiscard]] const char* familyName() const override;
/*!
@brief Return the name of the group (the second part of the key).
For IPTC keys, the group name is the record name.
*/
- std::string groupName() const override;
- std::string tagName() const override;
- std::string tagLabel() const override;
- uint16_t tag() const override;
- UniquePtr clone() const;
+ [[nodiscard]] std::string groupName() const override;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] std::string tagLabel() const override;
+ [[nodiscard]] uint16_t tag() const override;
+ [[nodiscard]] UniquePtr clone() const;
//! Return the name of the record
- std::string recordName() const;
+ [[nodiscard]] std::string recordName() const;
//! Return the record id
- uint16_t record() const;
+ [[nodiscard]] uint16_t record() const;
//@}
protected:
@@ -309,7 +309,7 @@ class EXIV2API IptcKey : public Key {
private:
//! Internal virtual copy constructor.
- IptcKey* clone_() const override;
+ [[nodiscard]] IptcKey* clone_() const override;
uint16_t tag_; //!< Tag value
uint16_t record_; //!< Record value
diff --git a/include/exiv2/epsimage.hpp b/include/exiv2/epsimage.hpp
index 83573ed2..9da714a1 100644
--- a/include/exiv2/epsimage.hpp
+++ b/include/exiv2/epsimage.hpp
@@ -70,7 +70,7 @@ class EXIV2API EpsImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
//! @name NOT Implemented
diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp
index 90d18174..408eef0a 100644
--- a/include/exiv2/error.hpp
+++ b/include/exiv2/error.hpp
@@ -262,17 +262,17 @@ class EXIV2API Error : public std::exception {
}
//! Virtual destructor. (Needed because of throw())
- virtual ~Error() noexcept;
+ ~Error() noexcept override;
//@}
//! @name Accessors
//@{
- ErrorCode code() const noexcept;
+ [[nodiscard]] ErrorCode code() const noexcept;
/*!
@brief Return the error message as a C-string. The pointer returned by what()
is valid only as long as the BasicError object exists.
*/
- const char* what() const noexcept override;
+ [[nodiscard]] const char* what() const noexcept override;
//@}
private:
diff --git a/include/exiv2/exif.hpp b/include/exiv2/exif.hpp
index 9c212d34..c052513a 100644
--- a/include/exiv2/exif.hpp
+++ b/include/exiv2/exif.hpp
@@ -135,18 +135,18 @@ class EXIV2API Exifdatum : public Metadatum {
//! @name Accessors
//@{
//! Return the key of the %Exifdatum.
- std::string key() const override;
- const char* familyName() const override;
- std::string groupName() const override;
- std::string tagName() const override;
- std::string tagLabel() const override;
- uint16_t tag() const override;
+ [[nodiscard]] std::string key() const override;
+ [[nodiscard]] const char* familyName() const override;
+ [[nodiscard]] std::string groupName() const override;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] std::string tagLabel() const override;
+ [[nodiscard]] uint16_t tag() const override;
//! Return the IFD id as an integer. (Do not use, this is meant for library internal use.)
- int ifdId() const;
+ [[nodiscard]] int ifdId() const;
//! Return the name of the IFD
- const char* ifdName() const;
+ [[nodiscard]] const char* ifdName() const;
//! Return the index (unique id of this key within the original IFD)
- int idx() const;
+ [[nodiscard]] int idx() const;
/*!
@brief Write value to a data buffer and return the number
of bytes written.
@@ -161,25 +161,25 @@ class EXIV2API Exifdatum : public Metadatum {
size_t copy(byte* buf, ByteOrder byteOrder) const override;
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
//! Return the type id of the value
- TypeId typeId() const override;
+ [[nodiscard]] TypeId typeId() const override;
//! Return the name of the type
- const char* typeName() const override;
+ [[nodiscard]] const char* typeName() const override;
//! Return the size in bytes of one component of this type
- size_t typeSize() const override;
+ [[nodiscard]] size_t typeSize() const override;
//! Return the number of components in the value
- size_t count() const override;
+ [[nodiscard]] size_t count() const override;
//! Return the size of the value in bytes
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
//! Return the value as a string.
- std::string toString() const override;
- std::string toString(size_t n) const override;
- int64_t toInt64(size_t n = 0) const override;
- float toFloat(size_t n = 0) const override;
- Rational toRational(size_t n = 0) const override;
- Value::UniquePtr getValue() const override;
- const Value& value() const override;
+ [[nodiscard]] std::string toString() const override;
+ [[nodiscard]] std::string toString(size_t n) const override;
+ [[nodiscard]] int64_t toInt64(size_t n = 0) const override;
+ [[nodiscard]] float toFloat(size_t n = 0) const override;
+ [[nodiscard]] Rational toRational(size_t n = 0) const override;
+ [[nodiscard]] Value::UniquePtr getValue() const override;
+ [[nodiscard]] const Value& value() const override;
//! Return the size of the data area.
- size_t sizeDataArea() const;
+ [[nodiscard]] size_t sizeDataArea() const;
/*!
@brief Return a copy of the data area of the value. The caller owns
this copy and %DataBuf ensures that it will be deleted.
@@ -192,7 +192,7 @@ class EXIV2API Exifdatum : public Metadatum {
%DataBuf if the value does not have a data area assigned or the
value is not set.
*/
- DataBuf dataArea() const;
+ [[nodiscard]] DataBuf dataArea() const;
//@}
private:
@@ -227,7 +227,7 @@ class EXIV2API ExifThumbC {
@brief Return the thumbnail image in a %DataBuf. The caller owns the
data buffer and %DataBuf ensures that it will be deleted.
*/
- DataBuf copy() const;
+ [[nodiscard]] DataBuf copy() const;
/*!
@brief Write the thumbnail image to a file.
@@ -238,17 +238,17 @@ class EXIV2API ExifThumbC {
@param path File name of the thumbnail without extension.
@return The number of bytes written.
*/
- size_t writeFile(const std::string& path) const;
+ [[nodiscard]] size_t writeFile(const std::string& path) const;
/*!
@brief Return the MIME type of the thumbnail, either \c "image/tiff"
or \c "image/jpeg".
*/
- const char* mimeType() const;
+ [[nodiscard]] const char* mimeType() const;
/*!
@brief Return the file extension for the format of the thumbnail
(".tif" or ".jpg").
*/
- const char* extension() const;
+ [[nodiscard]] const char* extension() const;
//@}
private:
@@ -442,24 +442,24 @@ class EXIV2API ExifData {
//! @name Accessors
//@{
//! Begin of the metadata
- const_iterator begin() const {
+ [[nodiscard]] const_iterator begin() const {
return exifMetadata_.begin();
}
//! End of the metadata
- const_iterator end() const {
+ [[nodiscard]] const_iterator end() const {
return exifMetadata_.end();
}
/*!
@brief Find the first Exifdatum with the given \em key, return a const
iterator to it.
*/
- const_iterator findKey(const ExifKey& key) const;
+ [[nodiscard]] const_iterator findKey(const ExifKey& key) const;
//! Return true if there is no Exif metadata
- bool empty() const {
+ [[nodiscard]] bool empty() const {
return exifMetadata_.empty();
}
//! Get the number of metadata entries
- size_t count() const {
+ [[nodiscard]] size_t count() const {
return exifMetadata_.size();
}
//@}
diff --git a/include/exiv2/gifimage.hpp b/include/exiv2/gifimage.hpp
index 2b805753..f0df8677 100644
--- a/include/exiv2/gifimage.hpp
+++ b/include/exiv2/gifimage.hpp
@@ -73,7 +73,7 @@ class EXIV2API GifImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
}; // class GifImage
diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp
index 4887b988..5ec73227 100644
--- a/include/exiv2/image.hpp
+++ b/include/exiv2/image.hpp
@@ -200,13 +200,13 @@ class EXIV2API Image {
@brief Returns the status of the ICC profile in the image instance
*/
virtual bool iccProfileDefined() {
- return iccProfile_.size() != 0;
+ return !iccProfile_.empty();
}
/*!
@brief return iccProfile
*/
- virtual const DataBuf& iccProfile() const {
+ [[nodiscard]] virtual const DataBuf& iccProfile() const {
return iccProfile_;
}
@@ -337,12 +337,12 @@ class EXIV2API Image {
@brief Return the byte order in which the Exif metadata of the image is
encoded. Initially, it is not set (\em invalidByteOrder).
*/
- ByteOrder byteOrder() const;
+ [[nodiscard]] ByteOrder byteOrder() const;
/*! @brief Check if the Image instance is valid. Use after object construction.
@return true if the Image is in a valid state.
*/
- bool good() const;
+ [[nodiscard]] bool good() const;
/*!
@brief Return the MIME type of the image.
@@ -353,15 +353,15 @@ class EXIV2API Image {
and thus they all have MIME type "image/tiff", although a more
specific MIME type may exist (e.g., "image/x-nikon-nef").
*/
- virtual std::string mimeType() const = 0;
+ [[nodiscard]] virtual std::string mimeType() const = 0;
/*!
@brief Return the pixel width of the image.
*/
- virtual uint32_t pixelWidth() const;
+ [[nodiscard]] virtual uint32_t pixelWidth() const;
/*!
@brief Return the pixel height of the image.
*/
- virtual uint32_t pixelHeight() const;
+ [[nodiscard]] virtual uint32_t pixelHeight() const;
/*!
@brief Returns an ExifData instance containing currently buffered
Exif data.
@@ -373,7 +373,7 @@ class EXIV2API Image {
@return read only ExifData instance containing Exif values
*/
- virtual const ExifData& exifData() const;
+ [[nodiscard]] virtual const ExifData& exifData() const;
/*!
@brief Returns an IptcData instance containing currently buffered
IPTC data.
@@ -385,7 +385,7 @@ class EXIV2API Image {
@return modifiable IptcData instance containing IPTC values
*/
- virtual const IptcData& iptcData() const;
+ [[nodiscard]] virtual const IptcData& iptcData() const;
/*!
@brief Returns an XmpData instance containing currently buffered
XMP data.
@@ -397,15 +397,15 @@ class EXIV2API Image {
@return modifiable XmpData instance containing XMP values
*/
- virtual const XmpData& xmpData() const;
+ [[nodiscard]] virtual const XmpData& xmpData() const;
/*!
@brief Return a copy of the image comment. May be an empty string.
*/
- virtual std::string comment() const;
+ [[nodiscard]] virtual std::string comment() const;
/*!
@brief Return the raw XMP packet as a string.
*/
- virtual const std::string& xmpPacket() const;
+ [[nodiscard]] virtual const std::string& xmpPacket() const;
/*!
@brief Return a reference to the BasicIo instance being used for Io.
@@ -420,23 +420,23 @@ class EXIV2API Image {
Image class will not see those changes until the readMetadata()
method is called.
*/
- virtual BasicIo& io() const;
+ [[nodiscard]] virtual BasicIo& io() const;
/*!
@brief Returns the access mode, i.e., the metadata functions, which
this image supports for the metadata type \em metadataId.
@param metadataId The metadata identifier.
@return Access mode for the requested image type and metadata identifier.
*/
- AccessMode checkMode(MetadataId metadataId) const;
+ [[nodiscard]] AccessMode checkMode(MetadataId metadataId) const;
/*!
@brief Check if image supports a particular type of metadata.
This method is deprecated. Use checkMode() instead.
*/
- bool supportsMetadata(MetadataId metadataId) const;
+ [[nodiscard]] bool supportsMetadata(MetadataId metadataId) const;
//! Return the flag indicating the source when writing XMP metadata.
- bool writeXmpFromPacket() const;
+ [[nodiscard]] bool writeXmpFromPacket() const;
//! Return list of native previews. This is meant to be used only by the PreviewManager.
- const NativePreviewList& nativePreviews() const;
+ [[nodiscard]] const NativePreviewList& nativePreviews() const;
//@}
//! set type support for this image format
@@ -446,7 +446,7 @@ class EXIV2API Image {
}
//! set type support for this image format
- ImageType imageType() const {
+ [[nodiscard]] ImageType imageType() const {
return imageType_;
}
diff --git a/include/exiv2/ini.hpp b/include/exiv2/ini.hpp
index d6999be5..6845758a 100644
--- a/include/exiv2/ini.hpp
+++ b/include/exiv2/ini.hpp
@@ -133,7 +133,7 @@ class EXIV2API INIReader {
/*! @brief Return the result of ini_parse(), i.e., 0 on success, line number of
first error on parse error, or -1 on file open error.
*/
- int ParseError() const;
+ [[nodiscard]] int ParseError() const;
/*! @brief Get a string value from INI file, returning default_value if not found.
diff --git a/include/exiv2/iptc.hpp b/include/exiv2/iptc.hpp
index 69f9e328..56dde0e5 100644
--- a/include/exiv2/iptc.hpp
+++ b/include/exiv2/iptc.hpp
@@ -94,39 +94,39 @@ class EXIV2API Iptcdatum : public Metadatum {
is not necessarily unique, i.e., an IptcData object may contain
multiple metadata with the same key.
*/
- std::string key() const override;
+ [[nodiscard]] std::string key() const override;
/*!
@brief Return the name of the record (deprecated)
@return record name
*/
- std::string recordName() const;
+ [[nodiscard]] std::string recordName() const;
/*!
@brief Return the record id
@return record id
*/
- uint16_t record() const;
- const char* familyName() const override;
- std::string groupName() const override;
+ [[nodiscard]] uint16_t record() const;
+ [[nodiscard]] const char* familyName() const override;
+ [[nodiscard]] std::string groupName() const override;
/*!
@brief Return the name of the tag (aka dataset)
@return tag name
*/
- std::string tagName() const override;
- std::string tagLabel() const override;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] std::string tagLabel() const override;
//! Return the tag (aka dataset) number
- uint16_t tag() const override;
- TypeId typeId() const override;
- const char* typeName() const override;
- size_t typeSize() const override;
- size_t count() const override;
- size_t size() const override;
- std::string toString() const override;
- std::string toString(size_t n) const override;
- int64_t toInt64(size_t n = 0) const override;
- float toFloat(size_t n = 0) const override;
- Rational toRational(size_t n = 0) const override;
- Value::UniquePtr getValue() const override;
- const Value& value() const override;
+ [[nodiscard]] uint16_t tag() const override;
+ [[nodiscard]] TypeId typeId() const override;
+ [[nodiscard]] const char* typeName() const override;
+ [[nodiscard]] size_t typeSize() const override;
+ [[nodiscard]] size_t count() const override;
+ [[nodiscard]] size_t size() const override;
+ [[nodiscard]] std::string toString() const override;
+ [[nodiscard]] std::string toString(size_t n) const override;
+ [[nodiscard]] int64_t toInt64(size_t n = 0) const override;
+ [[nodiscard]] float toFloat(size_t n = 0) const override;
+ [[nodiscard]] Rational toRational(size_t n = 0) const override;
+ [[nodiscard]] Value::UniquePtr getValue() const override;
+ [[nodiscard]] const Value& value() const override;
//@}
private:
@@ -224,38 +224,38 @@ class EXIV2API IptcData {
//! @name Accessors
//@{
//! Begin of the metadata
- const_iterator begin() const {
+ [[nodiscard]] const_iterator begin() const {
return iptcMetadata_.begin();
}
//! End of the metadata
- const_iterator end() const {
+ [[nodiscard]] const_iterator end() const {
return iptcMetadata_.end();
}
/*!
@brief Find the first Iptcdatum with the given key, return a const
iterator to it.
*/
- const_iterator findKey(const IptcKey& key) const;
+ [[nodiscard]] const_iterator findKey(const IptcKey& key) const;
/*!
@brief Find the first Iptcdatum with the given record and dataset
number, return a const iterator to it.
*/
- const_iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2) const;
+ [[nodiscard]] const_iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2) const;
//! Return true if there is no IPTC metadata
- bool empty() const {
+ [[nodiscard]] bool empty() const {
return count() == 0;
}
//! Get the number of metadata entries
- size_t count() const {
+ [[nodiscard]] size_t count() const {
return iptcMetadata_.size();
}
//! @brief Return the exact size of all contained IPTC metadata
- size_t size() const;
+ [[nodiscard]] size_t size() const;
//! @brief Return the metadata charset name or 0
- const char* detectCharset() const;
+ [[nodiscard]] const char* detectCharset() const;
//! @brief dump iptc formatted binary data (used by printStructure kpsRecursive)
static void printStructure(std::ostream& out, const Slice& bytes, uint32_t depth);
diff --git a/include/exiv2/jp2image.hpp b/include/exiv2/jp2image.hpp
index 0955f8f0..1799311a 100644
--- a/include/exiv2/jp2image.hpp
+++ b/include/exiv2/jp2image.hpp
@@ -61,7 +61,7 @@ class EXIV2API Jp2Image : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
//! @name NOT Implemented
diff --git a/include/exiv2/jpgimage.hpp b/include/exiv2/jpgimage.hpp
index 4ffd0a8b..58a93b9d 100644
--- a/include/exiv2/jpgimage.hpp
+++ b/include/exiv2/jpgimage.hpp
@@ -241,7 +241,7 @@ class EXIV2API JpegBase : public Image {
@return the next Jpeg segment marker if successful;
throws an Error if not successful
*/
- byte advanceToMarker(ErrorCode err) const;
+ [[nodiscard]] byte advanceToMarker(ErrorCode err) const;
//@}
DataBuf readNextSegment(byte marker);
@@ -282,7 +282,7 @@ class EXIV2API JpegImage : public JpegBase {
//@}
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
// NOT Implemented
@@ -343,7 +343,7 @@ class EXIV2API ExvImage : public JpegBase {
//@}
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
// NOT Implemented
diff --git a/include/exiv2/metadatum.hpp b/include/exiv2/metadatum.hpp
index facc5d5c..8acfb51d 100644
--- a/include/exiv2/metadatum.hpp
+++ b/include/exiv2/metadatum.hpp
@@ -42,23 +42,23 @@ class EXIV2API Key {
key is not necessarily unique, e.g., an ExifData may contain
multiple metadata with the same key.
*/
- virtual std::string key() const = 0;
+ [[nodiscard]] virtual std::string key() const = 0;
//! Return an identifier for the type of metadata (the first part of the key)
- virtual const char* familyName() const = 0;
+ [[nodiscard]] virtual const char* familyName() const = 0;
//! Return the name of the group (the second part of the key)
- virtual std::string groupName() const = 0;
+ [[nodiscard]] virtual std::string groupName() const = 0;
//! Return the name of the tag (which is also the third part of the key)
- virtual std::string tagName() const = 0;
+ [[nodiscard]] virtual std::string tagName() const = 0;
//! Return a label for the tag
- virtual std::string tagLabel() const = 0;
+ [[nodiscard]] virtual std::string tagLabel() const = 0;
//! Return the tag number
- virtual uint16_t tag() const = 0;
+ [[nodiscard]] virtual uint16_t tag() const = 0;
/*!
@brief Return an auto-pointer to a copy of itself (deep copy).
The caller owns this copy and the auto-pointer ensures that it
will be deleted.
*/
- UniquePtr clone() const;
+ [[nodiscard]] UniquePtr clone() const;
/*!
@brief Write the key to an output stream. You do not usually have
to use this function; it is used for the implementation of
@@ -82,7 +82,7 @@ class EXIV2API Key {
private:
//! Internal virtual copy constructor.
- virtual Key* clone_() const = 0;
+ [[nodiscard]] virtual Key* clone_() const = 0;
}; // class Key
@@ -171,57 +171,57 @@ class EXIV2API Metadatum {
is not necessarily unique, e.g., an ExifData object may
contain multiple metadata with the same key.
*/
- virtual std::string key() const = 0;
+ [[nodiscard]] virtual std::string key() const = 0;
//! Return the name of the metadata family (which is also the first part of the key)
- virtual const char* familyName() const = 0;
+ [[nodiscard]] virtual const char* familyName() const = 0;
//! Return the name of the metadata group (which is also the second part of the key)
- virtual std::string groupName() const = 0;
+ [[nodiscard]] virtual std::string groupName() const = 0;
//! Return the name of the tag (which is also the third part of the key)
- virtual std::string tagName() const = 0;
+ [[nodiscard]] virtual std::string tagName() const = 0;
//! Return a label for the tag
- virtual std::string tagLabel() const = 0;
+ [[nodiscard]] virtual std::string tagLabel() const = 0;
//! Return the tag
- virtual uint16_t tag() const = 0;
+ [[nodiscard]] virtual uint16_t tag() const = 0;
//! Return the type id of the value
- virtual TypeId typeId() const = 0;
+ [[nodiscard]] virtual TypeId typeId() const = 0;
//! Return the name of the type
- virtual const char* typeName() const = 0;
+ [[nodiscard]] virtual const char* typeName() const = 0;
//! Return the size in bytes of one component of this type
- virtual size_t typeSize() const = 0;
+ [[nodiscard]] virtual size_t typeSize() const = 0;
//! Return the number of components in the value
- virtual size_t count() const = 0;
+ [[nodiscard]] virtual size_t count() const = 0;
//! Return the size of the value in bytes
- virtual size_t size() const = 0;
+ [[nodiscard]] virtual size_t size() const = 0;
//! Return the value as a string.
- virtual std::string toString() const = 0;
+ [[nodiscard]] virtual std::string toString() const = 0;
/*!
@brief Return the n-th component of the value converted to
a string. The behaviour of the method is undefined if there
is no n-th component.
*/
- virtual std::string toString(size_t n) const = 0;
+ [[nodiscard]] virtual std::string toString(size_t n) const = 0;
/*!
@brief Return the n-th component of the value converted to int64_t.
The return value is -1 if the value is not set and the behaviour
of the method is undefined if there is no n-th component.
*/
- virtual int64_t toInt64(size_t n = 0) const = 0;
+ [[nodiscard]] virtual int64_t toInt64(size_t n = 0) const = 0;
/*!
@brief Return the n-th component of the value converted to uint32_t.
*/
- uint32_t toUint32(size_t n = 0) const;
+ [[nodiscard]] uint32_t toUint32(size_t n = 0) const;
/*!
@brief Return the n-th component of the value converted to float.
The return value is -1 if the value is not set and the behaviour
of the method is undefined if there is no n-th component.
*/
- virtual float toFloat(size_t n = 0) const = 0;
+ [[nodiscard]] virtual float toFloat(size_t n = 0) const = 0;
/*!
@brief Return the n-th component of the value converted to Rational.
The return value is -1/1 if the value is not set and the behaviour
of the method is undefined if there is no n-th component.
*/
- virtual Rational toRational(size_t n = 0) const = 0;
+ [[nodiscard]] virtual Rational toRational(size_t n = 0) const = 0;
/*!
@brief Return an auto-pointer to a copy (clone) of the value. The
caller owns this copy and the auto-poiner ensures that it will
@@ -235,7 +235,7 @@ class EXIV2API Metadatum {
@return An auto-pointer containing a pointer to a copy (clone) of the
value, 0 if the value is not set.
*/
- virtual Value::UniquePtr getValue() const = 0;
+ [[nodiscard]] virtual Value::UniquePtr getValue() const = 0;
/*!
@brief Return a constant reference to the value.
@@ -249,7 +249,7 @@ class EXIV2API Metadatum {
@return A constant reference to the value.
@throw Error if the value is not set.
*/
- virtual const Value& value() const = 0;
+ [[nodiscard]] virtual const Value& value() const = 0;
//@}
protected:
diff --git a/include/exiv2/mrwimage.hpp b/include/exiv2/mrwimage.hpp
index 281473cc..2d860194 100644
--- a/include/exiv2/mrwimage.hpp
+++ b/include/exiv2/mrwimage.hpp
@@ -76,9 +76,9 @@ class EXIV2API MrwImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
}; // class MrwImage
diff --git a/include/exiv2/pgfimage.hpp b/include/exiv2/pgfimage.hpp
index 51d91866..f74477d4 100644
--- a/include/exiv2/pgfimage.hpp
+++ b/include/exiv2/pgfimage.hpp
@@ -49,7 +49,7 @@ class EXIV2API PgfImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override {
+ [[nodiscard]] std::string mimeType() const override {
return "image/pgf";
}
//@}
diff --git a/include/exiv2/pngimage.hpp b/include/exiv2/pngimage.hpp
index 22670766..14761580 100644
--- a/include/exiv2/pngimage.hpp
+++ b/include/exiv2/pngimage.hpp
@@ -57,7 +57,7 @@ class EXIV2API PngImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
//! @name NOT implemented
diff --git a/include/exiv2/preview.hpp b/include/exiv2/preview.hpp
index d42db292..06456407 100644
--- a/include/exiv2/preview.hpp
+++ b/include/exiv2/preview.hpp
@@ -45,6 +45,8 @@ class EXIV2API PreviewImage {
PreviewImage(const PreviewImage& rhs);
//@}
+ ~PreviewImage() = default;
+
//! @name Manipulators
//@{
//! Assignment operator
@@ -57,15 +59,15 @@ class EXIV2API PreviewImage {
@brief Return a copy of the preview image data. The caller owns
this copy and %DataBuf ensures that it will be deleted.
*/
- DataBuf copy() const;
+ [[nodiscard]] DataBuf copy() const;
/*!
@brief Return a pointer to the image data for read-only access.
*/
- const byte* pData() const;
+ [[nodiscard]] const byte* pData() const;
/*!
@brief Return the size of the preview image in bytes.
*/
- uint32_t size() const;
+ [[nodiscard]] uint32_t size() const;
/*!
@brief Write the thumbnail image to a file.
@@ -76,29 +78,29 @@ class EXIV2API PreviewImage {
@param path File name of the preview image without extension.
@return The number of bytes written.
*/
- size_t writeFile(const std::string& path) const;
+ [[nodiscard]] size_t writeFile(const std::string& path) const;
/*!
@brief Return the MIME type of the preview image, usually either
\c "image/tiff" or \c "image/jpeg".
*/
- std::string mimeType() const;
+ [[nodiscard]] std::string mimeType() const;
/*!
@brief Return the file extension for the format of the preview image
(".tif" or ".jpg").
*/
- std::string extension() const;
+ [[nodiscard]] std::string extension() const;
/*!
@brief Return the width of the preview image in pixels.
*/
- size_t width() const;
+ [[nodiscard]] size_t width() const;
/*!
@brief Return the height of the preview image in pixels.
*/
- size_t height() const;
+ [[nodiscard]] size_t height() const;
/*!
@brief Return the preview image type identifier.
*/
- PreviewId id() const;
+ [[nodiscard]] PreviewId id() const;
//@}
private:
@@ -128,11 +130,11 @@ class EXIV2API PreviewManager {
sorted by preview width * height, starting with the smallest
preview image.
*/
- PreviewPropertiesList getPreviewProperties() const;
+ [[nodiscard]] PreviewPropertiesList getPreviewProperties() const;
/*!
@brief Return the preview image for the given preview properties.
*/
- PreviewImage getPreviewImage(const PreviewProperties& properties) const;
+ [[nodiscard]] PreviewImage getPreviewImage(const PreviewProperties& properties) const;
//@}
private:
diff --git a/include/exiv2/properties.hpp b/include/exiv2/properties.hpp
index 12f6fd35..2823e597 100644
--- a/include/exiv2/properties.hpp
+++ b/include/exiv2/properties.hpp
@@ -65,19 +65,19 @@ struct EXIV2API XmpNsInfo {
//! XMP property reference, implemented as a static class.
class EXIV2API XmpProperties {
- //! Prevent construction: not implemented.
- XmpProperties();
- //! Prevent copy-construction: not implemented.
- XmpProperties(const XmpProperties& rhs);
- //! Prevent assignment: not implemented.
- XmpProperties& operator=(const XmpProperties& rhs);
-
private:
static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
static void unregisterNsUnsafe(const std::string& ns);
static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
public:
+ //! Prevent construction: not implemented.
+ XmpProperties() = delete;
+ //! Prevent copy-construction: not implemented.
+ XmpProperties(const XmpProperties&) = delete;
+ //! Prevent assignment: not implemented.
+ XmpProperties& operator=(const XmpProperties& rhs) = delete;
+
/*!
@brief Return the title (label) of the property.
@param key The property key
@@ -254,28 +254,28 @@ class EXIV2API XmpKey : public Key {
//! @name Accessors
//@{
- std::string key() const override;
- const char* familyName() const override;
+ [[nodiscard]] std::string key() const override;
+ [[nodiscard]] const char* familyName() const override;
/*!
@brief Return the name of the group (the second part of the key).
For XMP keys, the group name is the schema prefix name.
*/
- std::string groupName() const override;
- std::string tagName() const override;
- std::string tagLabel() const override;
+ [[nodiscard]] std::string groupName() const override;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] std::string tagLabel() const override;
//! Properties don't have a tag number. Return 0.
- uint16_t tag() const override;
+ [[nodiscard]] uint16_t tag() const override;
- UniquePtr clone() const;
+ [[nodiscard]] UniquePtr clone() const;
// Todo: Should this be removed? What about tagLabel then?
//! Return the schema namespace for the prefix of the key
- std::string ns() const;
+ [[nodiscard]] std::string ns() const;
//@}
private:
//! Internal virtual copy constructor.
- XmpKey* clone_() const override;
+ [[nodiscard]] XmpKey* clone_() const override;
// Pimpl idiom
struct Impl;
diff --git a/include/exiv2/psdimage.hpp b/include/exiv2/psdimage.hpp
index 1d070292..9a25e704 100644
--- a/include/exiv2/psdimage.hpp
+++ b/include/exiv2/psdimage.hpp
@@ -68,7 +68,7 @@ class EXIV2API PsdImage : public Image {
but Apple, as of Tiger (10.4.8), maps this official MIME type to a
dynamic UTI, rather than "com.adobe.photoshop-image" as it should.
*/
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
private:
diff --git a/include/exiv2/rafimage.hpp b/include/exiv2/rafimage.hpp
index 9b675116..613798f8 100644
--- a/include/exiv2/rafimage.hpp
+++ b/include/exiv2/rafimage.hpp
@@ -69,9 +69,9 @@ class EXIV2API RafImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
//! @name NOT implemented
diff --git a/include/exiv2/rw2image.hpp b/include/exiv2/rw2image.hpp
index 01cb3fea..272722d0 100644
--- a/include/exiv2/rw2image.hpp
+++ b/include/exiv2/rw2image.hpp
@@ -67,9 +67,9 @@ class EXIV2API Rw2Image : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
- uint32_t pixelWidth() const override;
- uint32_t pixelHeight() const override;
+ [[nodiscard]] std::string mimeType() const override;
+ [[nodiscard]] uint32_t pixelWidth() const override;
+ [[nodiscard]] uint32_t pixelHeight() const override;
//@}
//! @name NOT implemented
diff --git a/include/exiv2/slice.hpp b/include/exiv2/slice.hpp
index a7a282fa..2068339f 100644
--- a/include/exiv2/slice.hpp
+++ b/include/exiv2/slice.hpp
@@ -26,7 +26,7 @@ struct SliceBase {
/*!
* Return the number of elements in the slice.
*/
- inline size_t size() const noexcept {
+ [[nodiscard]] inline size_t size() const noexcept {
// cannot underflow, as we know that begin < end
return end_ - begin_;
}
diff --git a/include/exiv2/tags.hpp b/include/exiv2/tags.hpp
index 9e59a994..ea26f060 100644
--- a/include/exiv2/tags.hpp
+++ b/include/exiv2/tags.hpp
@@ -154,27 +154,27 @@ class EXIV2API ExifKey : public Key {
//! @name Accessors
//@{
- std::string key() const override;
- const char* familyName() const override;
- std::string groupName() const override;
+ [[nodiscard]] std::string key() const override;
+ [[nodiscard]] const char* familyName() const override;
+ [[nodiscard]] std::string groupName() const override;
//! Return the IFD id as an integer. (Do not use, this is meant for library internal use.)
- int ifdId() const;
- std::string tagName() const override;
- uint16_t tag() const override;
- std::string tagLabel() const override;
+ [[nodiscard]] int ifdId() const;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] uint16_t tag() const override;
+ [[nodiscard]] std::string tagLabel() const override;
//! Return the tag description.
- std::string tagDesc() const; // Todo: should be in the base class
+ [[nodiscard]] std::string tagDesc() const; // Todo: should be in the base class
//! Return the default type id for this tag.
- TypeId defaultTypeId() const; // Todo: should be in the base class
+ [[nodiscard]] TypeId defaultTypeId() const; // Todo: should be in the base class
- UniquePtr clone() const;
+ [[nodiscard]] UniquePtr clone() const;
//! Return the index (unique id of this key within the original Exif data, 0 if not set)
- int idx() const;
+ [[nodiscard]] int idx() const;
//@}
private:
//! Internal virtual copy constructor.
- ExifKey* clone_() const override;
+ [[nodiscard]] ExifKey* clone_() const override;
// Pimpl idiom
struct Impl;
diff --git a/include/exiv2/tgaimage.hpp b/include/exiv2/tgaimage.hpp
index 3485c21a..4cfd0fee 100644
--- a/include/exiv2/tgaimage.hpp
+++ b/include/exiv2/tgaimage.hpp
@@ -72,7 +72,7 @@ class EXIV2API TgaImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
}; // class TgaImage
diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp
index 30743fdc..a7827ab7 100644
--- a/include/exiv2/types.hpp
+++ b/include/exiv2/types.hpp
@@ -172,30 +172,30 @@ struct EXIV2API DataBuf {
inline iterator begin() noexcept {
return pData_.begin();
}
- inline const_iterator cbegin() const noexcept {
+ [[nodiscard]] inline const_iterator cbegin() const noexcept {
return pData_.cbegin();
}
inline iterator end() noexcept {
return pData_.end();
}
- inline const_iterator cend() const noexcept {
+ [[nodiscard]] inline const_iterator cend() const noexcept {
return pData_.end();
}
- size_t size() const {
+ [[nodiscard]] size_t size() const {
return pData_.size();
}
- uint8_t read_uint8(size_t offset) const;
+ [[nodiscard]] uint8_t read_uint8(size_t offset) const;
void write_uint8(size_t offset, uint8_t x);
- uint16_t read_uint16(size_t offset, ByteOrder byteOrder) const;
+ [[nodiscard]] uint16_t read_uint16(size_t offset, ByteOrder byteOrder) const;
void write_uint16(size_t offset, uint16_t x, ByteOrder byteOrder);
- uint32_t read_uint32(size_t offset, ByteOrder byteOrder) const;
+ [[nodiscard]] uint32_t read_uint32(size_t offset, ByteOrder byteOrder) const;
void write_uint32(size_t offset, uint32_t x, ByteOrder byteOrder);
- uint64_t read_uint64(size_t offset, ByteOrder byteOrder) const;
+ [[nodiscard]] uint64_t read_uint64(size_t offset, ByteOrder byteOrder) const;
void write_uint64(size_t offset, uint64_t x, ByteOrder byteOrder);
//! Equivalent to: memcmp(&pData_[offset], buf, bufsize)
@@ -205,12 +205,12 @@ struct EXIV2API DataBuf {
byte* data(size_t offset = 0);
//! Returns a (read-only) data pointer.
- const byte* c_data(size_t offset = 0) const;
+ [[nodiscard]] const byte* c_data(size_t offset = 0) const;
//! Returns a (read-only) C-style string pointer.
- const char* c_str(size_t offset = 0) const;
+ [[nodiscard]] const char* c_str(size_t offset = 0) const;
- bool empty() const {
+ [[nodiscard]] bool empty() const {
return pData_.empty();
}
diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp
index 012be3bb..458eb87c 100644
--- a/include/exiv2/value.hpp
+++ b/include/exiv2/value.hpp
@@ -1701,7 +1701,7 @@ size_t ValueType::sizeDataArea() const {
template
DataBuf ValueType::dataArea() const {
- return DataBuf(pDataArea_, sizeDataArea_);
+ return {pDataArea_, sizeDataArea_};
}
template
diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp
index 29fbf189..48567944 100644
--- a/include/exiv2/webpimage.hpp
+++ b/include/exiv2/webpimage.hpp
@@ -51,7 +51,7 @@ class EXIV2API WebPImage : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
//! Copy constructor
diff --git a/include/exiv2/xmp_exiv2.hpp b/include/exiv2/xmp_exiv2.hpp
index 8c8c367d..ec3d02c6 100644
--- a/include/exiv2/xmp_exiv2.hpp
+++ b/include/exiv2/xmp_exiv2.hpp
@@ -10,6 +10,8 @@
#include "metadatum.hpp"
#include "properties.hpp"
+#include
+
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
@@ -99,29 +101,29 @@ class EXIV2API Xmpdatum : public Metadatum {
key is not necessarily unique, i.e., an XmpData object may
contain multiple metadata with the same key.
*/
- std::string key() const override;
- const char* familyName() const override;
+ [[nodiscard]] std::string key() const override;
+ [[nodiscard]] const char* familyName() const override;
//! Return the (preferred) schema namespace prefix.
- std::string groupName() const override;
+ [[nodiscard]] std::string groupName() const override;
//! Return the property name.
- std::string tagName() const override;
- std::string tagLabel() const override;
+ [[nodiscard]] std::string tagName() const override;
+ [[nodiscard]] std::string tagLabel() const override;
//! Properties don't have a tag number. Return 0.
- uint16_t tag() const override;
- TypeId typeId() const override;
- const char* typeName() const override;
+ [[nodiscard]] uint16_t tag() const override;
+ [[nodiscard]] TypeId typeId() const override;
+ [[nodiscard]] const char* typeName() const override;
// Todo: Remove this method from the baseclass
//! The Exif typeSize doesn't make sense here. Return 0.
- size_t typeSize() const override;
- size_t count() const override;
- size_t size() const override;
- std::string toString() const override;
- std::string toString(size_t n) const override;
- int64_t toInt64(size_t n = 0) const override;
- float toFloat(size_t n = 0) const override;
- Rational toRational(size_t n = 0) const override;
- Value::UniquePtr getValue() const override;
- const Value& value() const override;
+ [[nodiscard]] size_t typeSize() const override;
+ [[nodiscard]] size_t count() const override;
+ [[nodiscard]] size_t size() const override;
+ [[nodiscard]] std::string toString() const override;
+ [[nodiscard]] std::string toString(size_t n) const override;
+ [[nodiscard]] int64_t toInt64(size_t n = 0) const override;
+ [[nodiscard]] float toFloat(size_t n = 0) const override;
+ [[nodiscard]] Rational toRational(size_t n = 0) const override;
+ [[nodiscard]] Value::UniquePtr getValue() const override;
+ [[nodiscard]] const Value& value() const override;
//@}
private:
@@ -209,21 +211,21 @@ class EXIV2API XmpData {
//! @name Accessors
//@{
//! Begin of the metadata
- const_iterator begin() const;
+ [[nodiscard]] const_iterator begin() const;
//! End of the metadata
- const_iterator end() const;
+ [[nodiscard]] const_iterator end() const;
/*!
@brief Find the first Xmpdatum with the given key, return a const
iterator to it.
*/
- const_iterator findKey(const XmpKey& key) const;
+ [[nodiscard]] const_iterator findKey(const XmpKey& key) const;
//! Return true if there is no XMP metadata
- bool empty() const;
+ [[nodiscard]] bool empty() const;
//! Get the number of metadata entries
- long count() const;
+ [[nodiscard]] long count() const;
//! are we to use the packet?
- bool usePacket() const {
+ [[nodiscard]] bool usePacket() const {
return usePacket_;
};
@@ -234,12 +236,12 @@ class EXIV2API XmpData {
return r;
};
//! setPacket
- void setPacket(const std::string& xmpPacket) {
- xmpPacket_ = xmpPacket;
+ void setPacket(std::string xmpPacket) {
+ xmpPacket_ = std::move(xmpPacket);
usePacket(false);
};
// ! getPacket
- const std::string& xmpPacket() const {
+ [[nodiscard]] const std::string& xmpPacket() const {
return xmpPacket_;
};
@@ -312,7 +314,7 @@ class EXIV2API XmpParser {
@param pLockData Pointer to the pLockData passed to initialize()
@param lockUnlock Indicates whether to lock (true) or unlock (false)
*/
- using XmpLockFct = void (*)(void* pLockData, bool lockUnlock);
+ using XmpLockFct = std::function;
/*!
@brief Initialize the XMP Toolkit.
diff --git a/include/exiv2/xmpsidecar.hpp b/include/exiv2/xmpsidecar.hpp
index 100e92c1..653ee8d8 100644
--- a/include/exiv2/xmpsidecar.hpp
+++ b/include/exiv2/xmpsidecar.hpp
@@ -51,7 +51,7 @@ class EXIV2API XmpSidecar : public Image {
//! @name Accessors
//@{
- std::string mimeType() const override;
+ [[nodiscard]] std::string mimeType() const override;
//@}
private:
diff --git a/samples/prevtest.cpp b/samples/prevtest.cpp
index 31ee35f1..4ef44141 100644
--- a/samples/prevtest.cpp
+++ b/samples/prevtest.cpp
@@ -29,7 +29,9 @@ int main(int argc, char* const argv[]) try {
<< "\n";
Exiv2::PreviewImage preview = loader.getPreviewImage(pos);
- preview.writeFile(filename + "_" + Exiv2::toString(pos.width_) + "x" + Exiv2::toString(pos.height_));
+ auto s = preview.writeFile(filename + "_" + Exiv2::toString(pos.width_) + "x" + Exiv2::toString(pos.height_));
+ if (s == 0)
+ return EXIT_FAILURE;
}
// Cleanup
diff --git a/samples/write-test.cpp b/samples/write-test.cpp
index b2662d54..d62c66da 100644
--- a/samples/write-test.cpp
+++ b/samples/write-test.cpp
@@ -148,7 +148,9 @@ void testCase(const std::string& file1, const std::string& file2, const std::str
std::cerr << "---> Writing Exif thumbnail to file " << thumb << ".*\n";
ExifThumbC et2(ed2);
- et2.writeFile(thumb);
+ auto s = et2.writeFile(thumb);
+ if (s == 0)
+ std::cerr << "---> Failed to write to file " << thumb << ".*\n";
}
// *****************************************************************************
diff --git a/src/cr2header_int.hpp b/src/cr2header_int.hpp
index 9ebcb301..2e012029 100644
--- a/src/cr2header_int.hpp
+++ b/src/cr2header_int.hpp
@@ -38,7 +38,7 @@ class Cr2Header : public TiffHeaderBase {
//! @name Accessors
//@{
- DataBuf write() const override;
+ [[nodiscard]] DataBuf write() const override;
bool isImageTag(uint16_t tag, IfdId group, const PrimaryGroups* pPrimaryGroups) const override;
//@}
diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp
index 887c7325..6da5ecfa 100644
--- a/src/crwimage_int.hpp
+++ b/src/crwimage_int.hpp
@@ -26,10 +26,10 @@ struct CrwSubDir;
// type definitions
//! Function pointer for functions to decode Exif tags from a CRW entry
-using CrwDecodeFct = void (*)(const CiffComponent&, const CrwMapping*, Image&, ByteOrder);
+using CrwDecodeFct = std::function;
//! Function pointer for functions to encode CRW entries from Exif tags
-using CrwEncodeFct = void (*)(const Image&, const CrwMapping*, CiffHeader*);
+using CrwEncodeFct = std::function;
//! Stack to hold a path of CRW directories
using CrwDirs = std::stack;
@@ -167,17 +167,17 @@ class CiffComponent {
*/
void writeDirEntry(Blob& blob, ByteOrder byteOrder) const;
//! Return the tag of the directory containing this component
- uint16_t dir() const {
+ [[nodiscard]] uint16_t dir() const {
return dir_;
}
//! Return the tag of this component
- uint16_t tag() const {
+ [[nodiscard]] uint16_t tag() const {
return tag_;
}
//! Return true if the component is empty, else false
- bool empty() const;
+ [[nodiscard]] bool empty() const;
/*!
@brief Return the data size of this component
@@ -187,32 +187,32 @@ class CiffComponent {
of data bytes this component can have. The actual size,
i.e., used data bytes, may be less than 8.
*/
- size_t size() const {
+ [[nodiscard]] size_t size() const {
return size_;
}
//! Return the offset to the data from the start of the directory
- size_t offset() const {
+ [[nodiscard]] size_t offset() const {
return offset_;
}
//! Return a pointer to the data area of this component
- const byte* pData() const {
+ [[nodiscard]] const byte* pData() const {
return pData_;
}
//! Return the tag id of this component
- uint16_t tagId() const {
+ [[nodiscard]] uint16_t tagId() const {
return tag_ & 0x3fff;
}
//! Return the type id of this component
- TypeId typeId() const {
+ [[nodiscard]] TypeId typeId() const {
return typeId(tag_);
}
//! Return the data location for this component
- DataLocId dataLocation() const {
+ [[nodiscard]] DataLocId dataLocation() const {
return dataLocation(tag_);
}
@@ -220,7 +220,7 @@ class CiffComponent {
@brief Finds \em crwTagId in directory \em crwDir, returning a pointer to
the component or 0 if not found.
*/
- CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir) const;
+ [[nodiscard]] CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir) const;
//@}
protected:
@@ -253,9 +253,9 @@ class CiffComponent {
//! Implements print(). The default implementation prints the entry.
virtual void doPrint(std::ostream& os, ByteOrder byteOrder, const std::string& prefix) const;
//! Implements empty(). Default implementation returns true if size is 0.
- virtual bool doEmpty() const;
+ [[nodiscard]] virtual bool doEmpty() const;
//! Implements findComponent(). The default implementation checks the entry.
- virtual CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const;
+ [[nodiscard]] virtual CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const;
//@}
private:
@@ -374,7 +374,7 @@ class CiffDirectory : public CiffComponent {
bool doEmpty() const override;
// See base class comment
- CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const override;
+ [[nodiscard]] CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const override;
//@}
private:
@@ -464,14 +464,14 @@ class CiffHeader {
void decode(Image& image) const;
//! Return the byte order (little or big endian).
- ByteOrder byteOrder() const {
+ [[nodiscard]] ByteOrder byteOrder() const {
return byteOrder_;
}
/*!
@brief Finds \em crwTagId in directory \em crwDir in the parse tree,
returning a pointer to the component or 0 if not found.
*/
- CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir) const;
+ [[nodiscard]] CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir) const;
//@}
private:
@@ -501,7 +501,7 @@ struct CrwMapping {
//@{
//! Default constructor
CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, Internal::IfdId ifdId,
- CrwDecodeFct toExif, CrwEncodeFct fromExif) :
+ const CrwDecodeFct& toExif, const CrwEncodeFct& fromExif) :
crwTagId_(crwTagId),
crwDir_(crwDir),
size_(size),
@@ -528,13 +528,13 @@ struct CrwMapping {
to image metadata and vice versa
*/
class CrwMap {
+ public:
//! @name Not implemented
//@{
//! Default constructor
- CrwMap();
+ CrwMap() = delete;
//@}
- public:
/*!
@brief Decode image metadata from a CRW entry, convert and add it
to the image metadata. This function converts only one CRW
diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp
index 84c6d112..25106e10 100644
--- a/src/makernote_int.hpp
+++ b/src/makernote_int.hpp
@@ -107,26 +107,26 @@ class MnHeader {
//! @name Accessors
//@{
//! Return the size of the header (in bytes).
- virtual size_t size() const = 0;
+ [[nodiscard]] virtual size_t size() const = 0;
//! Write the header to a data buffer, return the number of bytes written.
virtual size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const = 0;
/*!
@brief Return the offset to the start of the Makernote IFD from
the start of the Makernote (= the start of the header).
*/
- virtual size_t ifdOffset() const;
+ [[nodiscard]] virtual size_t ifdOffset() const;
/*!
@brief Return the byte order for the makernote. If the return value is
invalidByteOrder, this means that the byte order of the the
image should be used for the makernote.
*/
- virtual ByteOrder byteOrder() const;
+ [[nodiscard]] virtual ByteOrder byteOrder() const;
/*!
@brief Return the base offset for the makernote IFD entries relative
to the start of the TIFF header. \em mnOffset is the offset
to the makernote from the start of the TIFF header.
*/
- virtual uint32_t baseOffset(uint32_t mnOffset) const;
+ [[nodiscard]] virtual uint32_t baseOffset(uint32_t mnOffset) const;
//@}
}; // class MnHeader
@@ -147,9 +147,9 @@ class OlympusMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -176,10 +176,10 @@ class Olympus2MnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
- uint32_t baseOffset(uint32_t mnOffset) const override;
+ [[nodiscard]] size_t ifdOffset() const override;
+ [[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -207,11 +207,11 @@ class FujiMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
- ByteOrder byteOrder() const override;
- uint32_t baseOffset(uint32_t mnOffset) const override;
+ [[nodiscard]] size_t ifdOffset() const override;
+ [[nodiscard]] ByteOrder byteOrder() const override;
+ [[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -240,9 +240,9 @@ class Nikon2MnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -271,11 +271,11 @@ class Nikon3MnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
- ByteOrder byteOrder() const override;
- uint32_t baseOffset(uint32_t mnOffset) const override;
+ [[nodiscard]] size_t ifdOffset() const override;
+ [[nodiscard]] ByteOrder byteOrder() const override;
+ [[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -304,9 +304,9 @@ class PanasonicMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -334,10 +334,10 @@ class PentaxDngMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
- uint32_t baseOffset(uint32_t mnOffset) const override;
+ [[nodiscard]] size_t ifdOffset() const override;
+ [[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -364,9 +364,9 @@ class PentaxMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -391,9 +391,9 @@ class SamsungMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- uint32_t baseOffset(uint32_t mnOffset) const override;
+ [[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
//@}
}; // class SamsungMnHeader
@@ -414,9 +414,9 @@ class SigmaMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -445,9 +445,9 @@ class SonyMnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
@@ -475,10 +475,10 @@ class Casio2MnHeader : public MnHeader {
//@}
//! @name Accessors
//@{
- size_t size() const override;
+ [[nodiscard]] size_t size() const override;
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
- size_t ifdOffset() const override;
- ByteOrder byteOrder() const override;
+ [[nodiscard]] size_t ifdOffset() const override;
+ [[nodiscard]] ByteOrder byteOrder() const override;
//@}
//! Return the size of the makernote header signature
static size_t sizeOfSignature();
diff --git a/src/orfimage_int.hpp b/src/orfimage_int.hpp
index 42c16485..46d101f1 100644
--- a/src/orfimage_int.hpp
+++ b/src/orfimage_int.hpp
@@ -33,7 +33,7 @@ class OrfHeader : public TiffHeaderBase {
//! @name Accessors
//@{
- DataBuf write() const override;
+ [[nodiscard]] DataBuf write() const override;
//@}
private:
// DATA
diff --git a/src/rw2image_int.hpp b/src/rw2image_int.hpp
index 9405f371..0d74763f 100644
--- a/src/rw2image_int.hpp
+++ b/src/rw2image_int.hpp
@@ -29,7 +29,7 @@ class Rw2Header : public TiffHeaderBase {
//! @name Accessors
//@{
//! Not yet implemented. Does nothing and returns an empty buffer.
- DataBuf write() const override;
+ [[nodiscard]] DataBuf write() const override;
//@}
}; // class Rw2Header
diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp
index ce412879..6ac73297 100644
--- a/src/tiffcomposite_int.hpp
+++ b/src/tiffcomposite_int.hpp
@@ -71,15 +71,15 @@ class TiffPathItem {
//! @name Accessors
//@{
//! Return the tag corresponding to the extended tag
- uint16_t tag() const {
+ [[nodiscard]] uint16_t tag() const {
return static_cast(extendedTag_ & 0xffff);
}
//! Return the extended tag (32 bit so that it can contain special tags)
- uint32_t extendedTag() const {
+ [[nodiscard]] uint32_t extendedTag() const {
return extendedTag_;
}
//! Return the group
- IfdId group() const {
+ [[nodiscard]] IfdId group() const {
return group_;
}
//@}
@@ -228,15 +228,15 @@ class TiffComponent {
//! @name Accessors
//@{
//! Return the tag of this entry.
- uint16_t tag() const {
+ [[nodiscard]] uint16_t tag() const {
return tag_;
}
//! Return the group id of this component
- IfdId group() const {
+ [[nodiscard]] IfdId group() const {
return group_;
}
//! Return a pointer to the start of the binary representation of the component
- byte* start() const {
+ [[nodiscard]] byte* start() const {
return pStart_;
}
/*!
@@ -244,7 +244,7 @@ class TiffComponent {
without any children). The caller owns this copy and the
auto-pointer ensures that it will be deleted.
*/
- UniquePtr clone() const;
+ [[nodiscard]] UniquePtr clone() const;
/*!
@brief Write the IFD data of this component to a binary image.
Return the number of bytes written. Components derived from
@@ -262,31 +262,31 @@ class TiffComponent {
@brief Return the size in bytes of the IFD value of this component
when written to a binary image.
*/
- size_t size() const;
+ [[nodiscard]] size_t size() const;
/*!
@brief Return the number of components in this component.
*/
- size_t count() const;
+ [[nodiscard]] size_t count() const;
/*!
@brief Return the size in bytes of the IFD data of this component when
written to a binary image. This is a support function for
write(). Components derived from TiffEntryBase implement this
method corresponding to their implementation of writeData().
*/
- size_t sizeData() const;
+ [[nodiscard]] size_t sizeData() const;
/*!
@brief Return the size in bytes of the image data of this component
when written to a binary image. This is a support function for
write(). TIFF components implement this method corresponding to
their implementation of writeImage().
*/
- size_t sizeImage() const;
+ [[nodiscard]] size_t sizeImage() const;
/*!
@brief Return the unique id of the entry in the image.
*/
// Todo: This is only implemented in TiffEntryBase. It is needed here so that
// we can sort components by tag and idx. Something is not quite right.
- virtual int idx() const;
+ [[nodiscard]] virtual int idx() const;
//@}
protected:
@@ -309,20 +309,20 @@ class TiffComponent {
//! @name Protected Accessors
//@{
//! Internal virtual copy constructor, implements clone().
- virtual TiffComponent* doClone() const = 0;
+ [[nodiscard]] virtual TiffComponent* doClone() const = 0;
//! Implements writeData().
virtual uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const = 0;
//! Implements writeImage().
virtual uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const = 0;
//! Implements size().
- virtual size_t doSize() const = 0;
+ [[nodiscard]] virtual size_t doSize() const = 0;
//! Implements count().
- virtual size_t doCount() const = 0;
+ [[nodiscard]] virtual size_t doCount() const = 0;
//! Implements sizeData().
- virtual size_t doSizeData() const = 0;
+ [[nodiscard]] virtual size_t doSizeData() const = 0;
//! Implements sizeImage().
- virtual size_t doSizeImage() const = 0;
+ [[nodiscard]] virtual size_t doSizeImage() const = 0;
//@}
private:
@@ -350,7 +350,7 @@ struct TiffMappingInfo {
*/
bool operator==(const Key& key) const;
//! Return the tag corresponding to the extended tag
- uint16_t tag() const {
+ [[nodiscard]] uint16_t tag() const {
return static_cast(extendedTag_ & 0xffff);
}
@@ -393,6 +393,12 @@ class TiffEntryBase : public TiffComponent {
~TiffEntryBase() override;
//@}
+ //! @name NOT implemented
+ //@{
+ //! Assignment operator.
+ TiffEntryBase& operator=(const TiffEntryBase& rhs) = delete;
+ //@}
+
//! @name Manipulators
//@{
/*!
@@ -446,29 +452,29 @@ class TiffEntryBase : public TiffComponent {
//! @name Accessors
//@{
//! Return the TIFF type
- TiffType tiffType() const {
+ [[nodiscard]] TiffType tiffType() const {
return tiffType_;
}
/*!
@brief Return the offset to the data area relative to the base
for the component (usually the start of the TIFF header)
*/
- int64_t offset() const {
+ [[nodiscard]] int64_t offset() const {
return offset_;
}
/*!
@brief Return the unique id of the entry in the image
*/
- int idx() const override;
+ [[nodiscard]] int idx() const override;
/*!
@brief Return a pointer to the binary representation of the
value of this component.
*/
- const byte* pData() const {
+ [[nodiscard]] const byte* pData() const {
return pData_;
}
//! Return a const pointer to the converted value of this component
- const Value* pValue() const {
+ [[nodiscard]] const Value* pValue() const {
return pValue_;
}
//@}
@@ -504,7 +510,7 @@ class TiffEntryBase : public TiffComponent {
//! @name Protected Accessors
//@{
//! Implements count().
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
/*!
@brief Implements writeData(). Standard TIFF entries have no data:
write nothing and return 0.
@@ -517,27 +523,21 @@ class TiffEntryBase : public TiffComponent {
*/
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
//! Implements size(). Return the size of a standard TIFF entry
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
//! Implements sizeData(). Return 0.
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
//! Implements sizeImage(). Return 0.
- size_t doSizeImage() const override;
+ [[nodiscard]] size_t doSizeImage() const override;
//@}
//! Helper function to write an \em offset to a preallocated binary buffer
static uint32_t writeOffset(byte* buf, int64_t offset, TiffType tiffType, ByteOrder byteOrder);
//! Used (internally) to create another reference to the DataBuf reference by storage_.
- const std::shared_ptr& storage() {
+ [[nodiscard]] const std::shared_ptr& storage() const {
return storage_;
}
- //! @name NOT implemented
- //@{
- //! Assignment operator.
- TiffEntryBase& operator=(const TiffEntryBase& rhs) = delete;
- //@}
-
private:
// DATA
TiffType tiffType_; //!< Field TIFF type
@@ -585,7 +585,7 @@ class TiffEntry : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffEntry* doClone() const override;
+ [[nodiscard]] TiffEntry* doClone() const override;
//@}
}; // class TiffEntry
@@ -627,11 +627,11 @@ class TiffDataEntryBase : public TiffEntryBase {
//! @name Accessors
//@{
//! Return the group of the entry which has the size
- uint16_t szTag() const {
+ [[nodiscard]] uint16_t szTag() const {
return szTag_;
}
//! Return the group of the entry which has the size
- IfdId szGroup() const {
+ [[nodiscard]] IfdId szGroup() const {
return szGroup_;
}
//@}
@@ -687,7 +687,7 @@ class TiffDataEntry : public TiffDataEntryBase {
//! @name Protected Accessors
//@{
- TiffDataEntry* doClone() const override;
+ [[nodiscard]] TiffDataEntry* doClone() const override;
/*!
@brief Implements writeData(). Write the data area to the \em ioWrapper.
Return the number of bytes written.
@@ -697,7 +697,7 @@ class TiffDataEntry : public TiffDataEntryBase {
// Using doWriteImage from base class
// Using doSize() from base class
//! Implements sizeData(). Return the size of the data area.
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
// Using doSizeImage from base class
//@}
@@ -746,7 +746,7 @@ class TiffImageEntry : public TiffDataEntryBase {
//! @name Protected Accessors
//@{
- TiffImageEntry* doClone() const override;
+ [[nodiscard]] TiffImageEntry* doClone() const override;
/*!
@brief Implements writeData(). Write the image data area to the \em ioWrapper.
Return the number of bytes written.
@@ -763,11 +763,11 @@ class TiffImageEntry : public TiffDataEntryBase {
*/
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
//! Implements size(). Return the size of the strip pointers.
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
//! Implements sizeData(). Return the size of the image data area.
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
//! Implements sizeImage(). Return the size of the image data area.
- size_t doSizeImage() const override;
+ [[nodiscard]] size_t doSizeImage() const override;
//@}
private:
@@ -800,11 +800,11 @@ class TiffSizeEntry : public TiffEntryBase {
//! @name Accessors
//@{
//! Return the group of the related entry which has the data area
- uint16_t dtTag() const {
+ [[nodiscard]] uint16_t dtTag() const {
return dtTag_;
}
//! Return the group of the related entry which has the data area
- IfdId dtGroup() const {
+ [[nodiscard]] IfdId dtGroup() const {
return dtGroup_;
}
//@}
@@ -818,7 +818,7 @@ class TiffSizeEntry : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffSizeEntry* doClone() const override;
+ [[nodiscard]] TiffSizeEntry* doClone() const override;
//@}
private:
@@ -846,10 +846,16 @@ class TiffDirectory : public TiffComponent {
~TiffDirectory() override;
//@}
+ //! @name NOT implemented
+ //@{
+ //! Assignment operator.
+ TiffDirectory& operator=(const TiffDirectory&) = delete;
+ //@}
+
//! @name Accessors
//@{
//! Return true if the directory has a next pointer
- bool hasNext() const {
+ [[nodiscard]] bool hasNext() const {
return hasNext_;
}
//@}
@@ -879,7 +885,7 @@ class TiffDirectory : public TiffComponent {
//! @name Protected Accessors
//@{
- TiffDirectory* doClone() const override;
+ [[nodiscard]] TiffDirectory* doClone() const override;
/*!
@brief This class does not really implement writeData(), it only has
write(). This method must not be called; it commits suicide.
@@ -897,28 +903,22 @@ class TiffDirectory : public TiffComponent {
@brief Implements size(). Return the size of the TIFF directory,
values and additional data, including the next-IFD, if any.
*/
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
/*!
@brief Implements count(). Return the number of entries in the TIFF
directory. Does not count entries which are marked as deleted.
*/
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
/*!
@brief This class does not really implement sizeData(), it only has
size(). This method must not be called; it commits suicide.
*/
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
/*!
@brief Implements sizeImage(). Return the sum of the image sizes of
all components plus that of the next-IFD, if there is any.
*/
- size_t doSizeImage() const override;
- //@}
-
- //! @name NOT implemented
- //@{
- //! Assignment operator.
- TiffDirectory& operator=(const TiffDirectory&) = delete;
+ [[nodiscard]] size_t doSizeImage() const override;
//@}
private:
@@ -955,13 +955,14 @@ class TiffSubIfd : public TiffEntryBase {
~TiffSubIfd() override;
//@}
- protected:
//! @name Protected Creators
//@{
//! Copy constructor (used to implement clone()).
TiffSubIfd(const TiffSubIfd& rhs);
+ TiffSubIfd& operator=(const TiffSubIfd&) = delete;
//@}
+ protected:
//! @name Protected Manipulators
//@{
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
@@ -980,7 +981,7 @@ class TiffSubIfd : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffSubIfd* doClone() const override;
+ [[nodiscard]] TiffSubIfd* doClone() const override;
/*!
@brief Implements writeData(). Write the sub-IFDs to the \em ioWrapper.
Return the number of bytes written.
@@ -993,17 +994,11 @@ class TiffSubIfd : public TiffEntryBase {
*/
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
//! Implements size(). Return the size of the sub-Ifd pointers.
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
//! Implements sizeData(). Return the sum of the sizes of all sub-IFDs.
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
//! Implements sizeImage(). Return the sum of the image sizes of all sub-IFDs.
- size_t doSizeImage() const override;
- //@}
-
- //! @name NOT implemented
- //@{
- //! Assignment operator.
- TiffSubIfd& operator=(const TiffSubIfd&) = delete;
+ [[nodiscard]] size_t doSizeImage() const override;
//@}
private:
@@ -1037,6 +1032,14 @@ class TiffMnEntry : public TiffEntryBase {
~TiffMnEntry() override;
//@}
+ //! @name NOT implemented
+ //@{
+ //! Copy constructor.
+ TiffMnEntry(const TiffMnEntry&) = delete;
+ //! Assignment operator.
+ TiffMnEntry& operator=(const TiffMnEntry&) = delete;
+ //@}
+
protected:
//! @name Protected Manipulators
//@{
@@ -1056,28 +1059,20 @@ class TiffMnEntry : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffMnEntry* doClone() const override;
+ [[nodiscard]] TiffMnEntry* doClone() const override;
//! Implements count(). Return number of components in the entry.
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
// Using doWriteData from base class
// Using doWriteImage from base class
/*!
@brief Implements size() by forwarding the call to the actual
concrete Makernote, if there is one.
*/
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
// Using doSizeData from base class
// Using doSizeImage from base class
//@}
- //! @name NOT implemented
- //@{
- //! Copy constructor.
- TiffMnEntry(const TiffMnEntry&) = delete;
- //! Assignment operator.
- TiffMnEntry& operator=(const TiffMnEntry&) = delete;
- //@}
-
private:
// DATA
IfdId mnGroup_; //!< New group for concrete mn
@@ -1129,31 +1124,31 @@ class TiffIfdMakernote : public TiffComponent {
//! @name Accessors
//@{
//! Return the size of the header in bytes.
- size_t sizeHeader() const;
+ [[nodiscard]] size_t sizeHeader() const;
//! Write the header to a data buffer, return the number of bytes written.
size_t writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
/*!
@brief Return the offset to the makernote from the start of the
TIFF header.
*/
- uint32_t mnOffset() const;
+ [[nodiscard]] uint32_t mnOffset() const;
/*!
@brief Return the offset to the start of the Makernote IFD from
the start of the Makernote.
Returns 0 if there is no header.
*/
- size_t ifdOffset() const;
+ [[nodiscard]] size_t ifdOffset() const;
/*!
@brief Return the byte order for the makernote. Requires the image
byte order to be set (setImageByteOrder()). Returns the byte
order for the image if there is no header or the byte order for
the header is \c invalidByteOrder.
*/
- ByteOrder byteOrder() const;
+ [[nodiscard]] ByteOrder byteOrder() const;
/*!
@brief Return the byte order used for the image.
*/
- ByteOrder imageByteOrder() const {
+ [[nodiscard]] ByteOrder imageByteOrder() const {
return imageByteOrder_;
}
/*!
@@ -1161,7 +1156,7 @@ class TiffIfdMakernote : public TiffComponent {
relative to the start of the TIFF header.
Returns 0 if there is no header.
*/
- uint32_t baseOffset() const;
+ [[nodiscard]] uint32_t baseOffset() const;
//@}
protected:
@@ -1183,7 +1178,7 @@ class TiffIfdMakernote : public TiffComponent {
//! @name Protected Accessors
//@{
- TiffIfdMakernote* doClone() const override;
+ [[nodiscard]] TiffIfdMakernote* doClone() const override;
/*!
@brief This class does not really implement writeData(), it only has
write(). This method must not be called; it commits suicide.
@@ -1199,23 +1194,23 @@ class TiffIfdMakernote : public TiffComponent {
@brief Implements size(). Return the size of the Makernote header,
TIFF directory, values and additional data.
*/
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
/*!
@brief Implements count(). Return the number of entries in the IFD
of the Makernote. Does not count entries which are marked as
deleted.
*/
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
/*!
@brief This class does not really implement sizeData(), it only has
size(). This method must not be called; it commits suicide.
*/
- size_t doSizeData() const override;
+ [[nodiscard]] size_t doSizeData() const override;
/*!
@brief Implements sizeImage(). Return the total image data size of the
makernote IFD.
*/
- size_t doSizeImage() const override;
+ [[nodiscard]] size_t doSizeImage() const override;
//@}
private:
@@ -1257,7 +1252,7 @@ struct ArrayDef {
return idx_ == idx;
}
//! Get the size in bytes of a tag.
- uint32_t size(uint16_t tag, IfdId group) const;
+ [[nodiscard]] uint32_t size(uint16_t tag, IfdId group) const;
// DATA
uint32_t idx_; //!< Index in bytes from the start
TiffType tiffType_; //!< TIFF type of the element
@@ -1270,7 +1265,7 @@ struct ArrayCfg {
@brief Return the size of the default tag, which is used
to calculate tag numbers as idx/tagStep
*/
- uint32_t tagStep() const {
+ [[nodiscard]] uint32_t tagStep() const {
return elDefaultDef_.size(0, group_);
}
// DATA
@@ -1306,6 +1301,7 @@ class TiffBinaryArray : public TiffEntryBase {
TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, int setSize, CfgSelFct cfgSelFct);
//! Virtual destructor
~TiffBinaryArray() override;
+ TiffBinaryArray& operator=(const TiffBinaryArray&) = delete;
//@}
//! @name Manipulators
@@ -1348,19 +1344,19 @@ class TiffBinaryArray : public TiffEntryBase {
//! @name Accessors
//@{
//! Return a pointer to the configuration
- const ArrayCfg* cfg() const {
+ [[nodiscard]] const ArrayCfg* cfg() const {
return arrayCfg_;
}
//! Return a pointer to the definition
- const ArrayDef* def() const {
+ [[nodiscard]] const ArrayDef* def() const {
return arrayDef_;
}
//! Return the number of elements in the definition
- int defSize() const {
+ [[nodiscard]] int defSize() const {
return defSize_;
}
//! Return the flag which indicates if the array was decoded
- bool decoded() const {
+ [[nodiscard]] bool decoded() const {
return decoded_;
}
//@}
@@ -1372,8 +1368,6 @@ class TiffBinaryArray : public TiffEntryBase {
TiffBinaryArray(const TiffBinaryArray& rhs);
//@}
- TiffBinaryArray& operator=(const TiffBinaryArray&) = delete;
-
//! @name Protected Manipulators
//@{
/*!
@@ -1396,15 +1390,15 @@ class TiffBinaryArray : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffBinaryArray* doClone() const override;
+ [[nodiscard]] TiffBinaryArray* doClone() const override;
//! Implements count(). Todo: Document it!
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
// Using doWriteData from base class
// Using doWriteImage from base class
/*!
@brief Implements size(). Todo: Document it!
*/
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
// Using doSizeData from base class
// Using doSizeImage from base class
//@}
@@ -1459,13 +1453,13 @@ class TiffBinaryElement : public TiffEntryBase {
/*!
@brief Return the array definition of this element.
*/
- const ArrayDef* elDef() const {
+ [[nodiscard]] const ArrayDef* elDef() const {
return &elDef_;
}
/*!
@brief Return the byte order of this element.
*/
- ByteOrder elByteOrder() const {
+ [[nodiscard]] ByteOrder elByteOrder() const {
return elByteOrder_;
}
//@}
@@ -1484,18 +1478,18 @@ class TiffBinaryElement : public TiffEntryBase {
//! @name Protected Accessors
//@{
- TiffBinaryElement* doClone() const override;
+ [[nodiscard]] TiffBinaryElement* doClone() const override;
/*!
@brief Implements count(). Returns the count from the element definition.
*/
- size_t doCount() const override;
+ [[nodiscard]] size_t doCount() const override;
// Using doWriteData from base class
// Using doWriteImage from base class
/*!
@brief Implements size(). Returns count * type-size, both taken from
the element definition.
*/
- size_t doSize() const override;
+ [[nodiscard]] size_t doSize() const override;
// Using doSizeData from base class
// Using doSizeImage from base class
//@}
diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp
index 999dba78..58d4c124 100644
--- a/src/tiffimage_int.hpp
+++ b/src/tiffimage_int.hpp
@@ -62,7 +62,7 @@ class TiffHeaderBase {
@return Binary header data.
*/
- virtual DataBuf write() const;
+ [[nodiscard]] virtual DataBuf write() const;
/*!
@brief Print debug info for the image header to \em os.
@@ -71,13 +71,13 @@ class TiffHeaderBase {
*/
virtual void print(std::ostream& os, const std::string& prefix = "") const;
//! Return the byte order (little or big endian).
- virtual ByteOrder byteOrder() const;
+ [[nodiscard]] virtual ByteOrder byteOrder() const;
//! Return the offset to the start of the root directory.
- virtual uint32_t offset() const;
+ [[nodiscard]] virtual uint32_t offset() const;
//! Return the size (in bytes) of the image header.
- virtual uint32_t size() const;
+ [[nodiscard]] virtual uint32_t size() const;
//! Return the tag value (magic number) which identifies the buffer as TIFF data.
- virtual uint16_t tag() const;
+ [[nodiscard]] virtual uint16_t tag() const;
/*!
@brief Return \c true if the %Exif \em tag from \em group is an image tag.
@@ -171,7 +171,7 @@ struct TiffGroupStruct {
return key.g_ == group_ && (Tag::all == extendedTag_ || key.e_ == extendedTag_);
}
//! Return the tag corresponding to the extended tag
- uint16_t tag() const {
+ [[nodiscard]] uint16_t tag() const {
return static_cast(extendedTag_ & 0xffff);
}
diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp
index fc134ef0..1b6fae54 100644
--- a/src/tiffvisitor_int.hpp
+++ b/src/tiffvisitor_int.hpp
@@ -118,7 +118,7 @@ class TiffVisitor {
//! @name Accessors
//@{
//! Check if stop flag for \em event is clear, return true if it's clear.
- bool go(GoEvent event) const;
+ [[nodiscard]] bool go(GoEvent event) const;
//@}
}; // class TiffVisitor
@@ -175,7 +175,7 @@ class TiffFinder : public TiffVisitor {
@brief Return the search result. 0 if no TIFF component was found
for the tag and group combination.
*/
- TiffComponent* result() const {
+ [[nodiscard]] TiffComponent* result() const {
return tiffComponent_;
}
//@}
@@ -454,16 +454,16 @@ class TiffEncoder : public TiffVisitor {
@brief Return the applicable byte order. May be different for
the Makernote and the rest of the TIFF entries.
*/
- ByteOrder byteOrder() const {
+ [[nodiscard]] ByteOrder byteOrder() const {
return byteOrder_;
}
/*!
@brief True if any tag was deleted or allocated in the process of
visiting a TIFF composite tree.
*/
- bool dirty() const;
+ [[nodiscard]] bool dirty() const;
//! Return the write method used.
- WriteMethod writeMethod() const {
+ [[nodiscard]] WriteMethod writeMethod() const {
return writeMethod_;
}
//@}
@@ -501,7 +501,7 @@ class TiffEncoder : public TiffVisitor {
is considered an image tag of this image - whether or not
it's actually present in the existing image doesn't matter.
*/
- bool isImageTag(uint16_t tag, IfdId group) const;
+ [[nodiscard]] bool isImageTag(uint16_t tag, IfdId group) const;
//@}
// DATA
@@ -544,7 +544,7 @@ class TiffRwState {
@brief Return the applicable byte order. May be different for
the Makernote and the rest of the TIFF entries.
*/
- ByteOrder byteOrder() const {
+ [[nodiscard]] ByteOrder byteOrder() const {
return byteOrder_;
}
/*!
@@ -558,7 +558,7 @@ class TiffRwState {
case, base offset added to the start of the TIFF image header points
to the basis for such makernote offsets.
*/
- uint32_t baseOffset() const {
+ [[nodiscard]] uint32_t baseOffset() const {
return baseOffset_;
}
//@}
@@ -650,9 +650,9 @@ class TiffReader : public TiffVisitor {
//! @name Accessors
//@{
//! Return the byte order.
- ByteOrder byteOrder() const;
+ [[nodiscard]] ByteOrder byteOrder() const;
//! Return the base offset. See class TiffRwState for details
- uint32_t baseOffset() const;
+ [[nodiscard]] uint32_t baseOffset() const;
//@}
private: